Skip to content

Commit

Permalink
No permissions messaged handled by perms function
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed Jan 20, 2024
1 parent ee85a59 commit 075c8a1
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 38 deletions.
1 change: 0 additions & 1 deletion Cogs/Modules/adminpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ async def admin(self, ctx):
@admin.command(description="Manage a staff member.")
async def panel(self, ctx, staff: discord.Member):
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return


Expand Down
1 change: 0 additions & 1 deletion Cogs/Modules/applicationresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async def results(
return

if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return


Expand Down
4 changes: 1 addition & 3 deletions Cogs/Modules/forumutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async def modulecheck(self, ctx):
@forums.command(description="Lock a forum thread")
async def lock(self, ctx):
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")

return
if isinstance(ctx.channel, discord.Thread):
await ctx.channel.edit(locked=True, reason=f"{ctx.author.display_name}, locked the forum")
Expand All @@ -268,7 +268,6 @@ async def lock(self, ctx):
@forums.command(description="Unlock a forum thread")
async def unlock(self, ctx):
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
if isinstance(ctx.channel, discord.Thread):
await ctx.channel.edit(locked=False, reason=f"{ctx.author.display_name}, unlocked the forum")
Expand All @@ -279,7 +278,6 @@ async def unlock(self, ctx):
@forums.command(description="Archive a forum thread")
async def archive(self, ctx):
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
if isinstance(ctx.channel, discord.Thread):
await ctx.send(f"{tick} Forum **Archived.**")
Expand Down
4 changes: 1 addition & 3 deletions Cogs/Modules/infractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def infract(self, ctx, staff: discord.Member, reason: str, action, notes:
return

if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")

return

if ctx.author == staff:
Expand Down Expand Up @@ -197,7 +197,6 @@ async def infractions(self, ctx, staff: discord.Member):
return

if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return

print(f"Searching infractions for staff ID: {staff.id} in guild ID: {ctx.guild.id}")
Expand Down Expand Up @@ -254,7 +253,6 @@ async def void(self, ctx, id: str):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return

filter = {
Expand Down
3 changes: 0 additions & 3 deletions Cogs/Modules/loa.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ async def manage(self, ctx, user: discord.Member):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return

loa = loa_collection.find_one({"user": user.id, "guild_id": ctx.guild.id, 'active': True})
Expand Down Expand Up @@ -228,7 +227,6 @@ async def active(self, ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return

current_time = datetime.now()
Expand Down Expand Up @@ -267,7 +265,6 @@ async def request(self, ctx, duration: str, reason: str):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
if not re.match(r'^\d+[mhdw]$', duration):
await ctx.send(f"{no} **{ctx.author.display_name}**, invalid duration format. Please use a valid format like '1d' (1 day), '2h' (2 hours), etc.")
Expand Down
2 changes: 0 additions & 2 deletions Cogs/Modules/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ async def modmail(self, ctx):
@modmail.command(description="Reply to a modmail")
async def reply(self, ctx, *, content):
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
if isinstance(ctx.channel, discord.TextChannel):
channel_id = ctx.channel.id
Expand Down Expand Up @@ -97,7 +96,6 @@ async def reply(self, ctx, *, content):
@modmail.command(description="Close a modmail channel.")
async def close(self, ctx):
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
if isinstance(ctx.channel, discord.TextChannel):
channel_id = ctx.channel.id
Expand Down
2 changes: 0 additions & 2 deletions Cogs/Modules/partnerships.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ async def terminate(self, ctx, server, reason: str):
return

if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return


Expand Down Expand Up @@ -158,7 +157,6 @@ async def all(self, ctx):
return

if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return
partnership_data = partnerships.find({'guild_id': ctx.guild.id})
if not partnership_data:
Expand Down
1 change: 0 additions & 1 deletion Cogs/Modules/promotions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ async def promote(self, ctx, staff: discord.Member, new: discord.Role, reason: s
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return

if ctx.author == staff:
Expand Down
3 changes: 0 additions & 3 deletions Cogs/Modules/quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ async def manage(self, ctx, staff: discord.Member):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return
mccollection = db["messages"]
message_data = mccollection.find_one({'guild_id': ctx.guild.id, 'user_id': staff.id})
Expand Down Expand Up @@ -185,7 +184,6 @@ async def messages(self, ctx, staff: discord.Member):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_staff_role(ctx):
await ctx.send(f"**{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
message_data = mccollection.find_one({'guild_id': ctx.guild.id, 'user_id': staff.id})
if staff.id:
Expand Down Expand Up @@ -213,7 +211,6 @@ async def leaderboard(self, ctx):
return
await ctx.defer()
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return

filter = {
Expand Down
2 changes: 1 addition & 1 deletion Cogs/Modules/stafffeedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def feedback(self, ctx):
@feedback.command(description="Remove feedback from a staff member")
async def remove(self, ctx, id: int):
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")

return
result = stafffeedback.find_one({'feedbackid': id, 'guild_id': ctx.guild.id})
if result is None:
Expand Down
2 changes: 1 addition & 1 deletion Cogs/Modules/stafflist.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def stafflist(self, ctx, display: Optional[Literal['True', 'False']]):
return

if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")

return
if guild:
staff_role_ids = self.get_role_ids(guild, "staffrole")
Expand Down
8 changes: 4 additions & 4 deletions Cogs/Modules/suspension.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
from emojis import *
import os
from dotenv import load_dotenv
from Cogs.Modules.infractions import *

from datetime import datetime

MONGO_URL = os.getenv('MONGO_URL')
client = MongoClient(MONGO_URL)
db = client['astro']
suspensions = db['Suspensions']
infchannel = db['infraction channel']
appealable = db['Appeal Toggle']
from permissions import *

class Suspensions(commands.Cog):
Expand All @@ -40,7 +43,6 @@ async def suspend(self, ctx, staff: discord.Member, length: str, reason: str):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return


Expand Down Expand Up @@ -88,7 +90,6 @@ async def active(self, ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.")
return

filter = {'guild_id': ctx.guild.id, 'active': True}
Expand Down Expand Up @@ -126,7 +127,6 @@ async def manage(self, ctx, staff: discord.Member):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.")
return
filter = {'guild_id': ctx.guild.id, 'staff': staff.id}
suspension_requests = suspensions.find(filter)
Expand Down
5 changes: 0 additions & 5 deletions Cogs/Modules/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ async def create(self, ctx, name: str, content: str):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return

data = {
Expand All @@ -107,7 +106,6 @@ async def all(self, ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
filter = {
'guild_id': ctx.guild.id
Expand Down Expand Up @@ -138,7 +136,6 @@ async def info(self, ctx, name):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return

filter = {
Expand Down Expand Up @@ -166,7 +163,6 @@ async def send(self, ctx, name):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_staff_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return
filter = {
'guild_id': ctx.guild.id,
Expand All @@ -190,7 +186,6 @@ async def delete(self, ctx, name):
await ctx.send(f"{no} **{ctx.author.display_name}**, this module is currently disabled.")
return
if not await has_admin_role(ctx):
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return
filter = {
'guild_id': ctx.guild.id,
Expand Down
25 changes: 17 additions & 8 deletions permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ async def has_staff_role(ctx):
if ctx.author.guild_permissions.administrator:


await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role isn't set please run </config:1140463441136586784>")
await ctx.send(f"{no} **{ctx.author.display_name}**, the staff role isn't set please run </config:1140463441136586784>!", view=PermissionsButtons())
else:
await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role is not setup please tell an admin to run </config:1140463441136586784> to fix it.")
await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role is not setup please tell an admin to run </config:1140463441136586784> to fix it!", view=PermissionsButtons())
return

await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Staff Role`")
return False


Expand All @@ -79,10 +79,11 @@ async def has_admin_role(ctx):
if ctx.author.guild_permissions.administrator:


await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role isn't set please run </config:1140463441136586784>")
await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role isn't set please run </config:1140463441136586784>", view=PermissionsButtons())
else:
await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role is not setup please tell an admin to run </config:1140463441136586784> to fix it.")
await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role is not setup please tell an admin to run </config:1140463441136586784> to fix it.", view=PermissionsButtons())
return
await ctx.send(f"{no} **{ctx.author.display_name}**, you don't have permission to use this command.\n<:Arrow:1115743130461933599>**Required:** `Admin Role`")
return False


Expand All @@ -105,8 +106,16 @@ async def has_moderator_role(ctx):
if ctx.author.guild_permissions.administrator:


await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role isn't set please run </config:1140463441136586784>")
await ctx.send(f"{no} **{ctx.author.display_name}**, the reports moderator role isn't set please run </config:1140463441136586784>", view=PermissionsButtons())
else:
await ctx.send(f"{no} **{ctx.author.display_name}**, the admin role is not setup please tell an admin to run </config:1140463441136586784> to fix it.")
await ctx.send(f"{no} **{ctx.author.display_name}**, the reports moderator role isn't setup please tell an admin to run </config:1140463441136586784> to fix it.", view=PermissionsButtons())
return
return False
return False


class PermissionsButtons(discord.ui.View):
def __init__(self):
super().__init__()
url1 = f'https://discord.gg/DhWdgfh3hN'
self.add_item(discord.ui.Button(label='Support Server', url=url1, style=discord.ButtonStyle.blurple))
self.add_item(discord.ui.Button(label='Documentation', url="https://docs.astrobirb.dev/overview", style=discord.ButtonStyle.blurple))

0 comments on commit 075c8a1

Please sign in to comment.