Update ServerCommands.py

This commit is contained in:
Elmon11 2020-10-28 04:16:53 +01:00 committed by GitHub
parent 024e459291
commit da68497218
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,33 +18,45 @@ def format_list_entry(embed, list, name):
embed.add_field(name="{} ({})".format(name, len(list)), value=", ".join(list), inline=False) embed.add_field(name="{} ({})".format(name, len(list)), value=", ".join(list), inline=False)
return embed return embed
def is_staff(ctx): class no_permission(commands.MissingPermissions):
pass
def is_staff():
def predicate(ctx):
user = ctx.message.author user = ctx.message.author
for role in user.roles: for role in user.roles:
if role.id in [admin, senior_admin]: if role.id in [admin, senior_admin]:
return True return True
return False else:
raise no_permission(['IS_STAFF_MEMBER'])
return commands.check(predicate)
def is_liaison(ctx): def is_liaison():
def predicate(ctx):
user = ctx.message.author user = ctx.message.author
for role in user.roles: for role in user.roles:
if role.id == server_liaison: if role.id == server_liaison:
return True return True
return False else:
raise no_permission(['IS_SERVER_LIAISON'])
return commands.check(predicate)
def is_senior(ctx): def is_senior():
def predicate(ctx):
user = ctx.message.author user = ctx.message.author
for role in user.roles: for role in user.roles:
if role.id == senior_admin: if role.id == senior_admin:
return True return True
return False else:
raise no_permission(['IS_SENIOR_ADMIN'])
return commands.check(predicate)
class ServerCommands(commands.Cog): class ServerCommands(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@commands.command() @commands.command()
@commands.check(is_liaison) @is_liaison()
async def eventhost(self, ctx, user: discord.Member): async def eventhost(self, ctx, user: discord.Member):
'Add or remove event host role - liaison only' 'Add or remove event host role - liaison only'
eventhostrole = ctx.guild.get_role(event_host) eventhostrole = ctx.guild.get_role(event_host)
@ -56,7 +68,7 @@ class ServerCommands(commands.Cog):
await ctx.send(f'```Succesfully added Event Host to {user.name}```') await ctx.send(f'```Succesfully added Event Host to {user.name}```')
@commands.command() @commands.command()
@commands.check(is_staff) @is_staff()
async def serverban(self, ctx, user: discord.Member): async def serverban(self, ctx, user: discord.Member):
'Add or remove server banned role' 'Add or remove server banned role'
serverbannedrole = ctx.guild.get_role(server_banned) serverbannedrole = ctx.guild.get_role(server_banned)
@ -68,38 +80,38 @@ class ServerCommands(commands.Cog):
await ctx.send(f'Added Server Banned role to {user.name}') await ctx.send(f'Added Server Banned role to {user.name}')
@commands.command() @commands.command()
@commands.check(is_staff) @is_staff()
async def start(self, ctx): async def start(self, ctx):
'Not currently working' 'Not currently working'
startEmbed = discord.Embed(description='start working out fatass') startEmbed = discord.Embed(description='start working out fatass')
await ctx.send(embed=startEmbed) await ctx.send(embed=startEmbed)
@commands.command() @commands.command()
@commands.check(is_staff) @is_staff()
async def stop(self, ctx): async def stop(self, ctx):
'Not currently working' 'Not currently working'
stopEmbed = discord.Embed(description='stop being so sus') stopEmbed = discord.Embed(description='stop being so sus')
await ctx.send(embed=stopEmbed) await ctx.send(embed=stopEmbed)
@commands.command() @commands.command()
@commands.check(is_senior) @is_senior()
async def kill(self, ctx): async def kill(self, ctx):
'Not currently working' 'Not currently working'
killEmbed = discord.Embed(description='kill youself') killEmbed = discord.Embed(description='kill youself')
await ctx.send(embed=killEmbed) await ctx.send(embed=killEmbed)
@commands.command() @commands.command()
@commands.check(is_staff) @is_staff()
async def restart(self, ctx): async def restart(self, ctx):
'Not currently working' 'Not currently working'
restartEmbed = discord.Embed(description='cant restart a dead server idiot') restartEmbed = discord.Embed(description='cant restart a dead server idiot')
await ctx.send(embed=restartEmbed) await ctx.send(embed=restartEmbed)
@commands.command() @commands.command()
@commands.check(is_senior) @is_senior()
async def console(self, ctx,*, command): async def console(self, ctx,*, command):
'Not currently working' 'Not currently working'
await ctx.send(f'```:[{str(datetime.datetime.utcnow().replace(microsecond=0))[11:]} INFO]: {ctx.author.name} issued server command: /{command}```') await ctx.send(f'```:[{str(datetime.utcnow().replace(microsecond=0))[11:]} INFO]: {ctx.author.name} issued server command: /{command}```')
@commands.command(aliases=['status']) @commands.command(aliases=['status'])
@ -157,7 +169,7 @@ class ServerCommands(commands.Cog):
await ctx.send(embed=em) await ctx.send(embed=em)
@commands.command() @commands.command()
@commands.check(is_staff) @is_staff()
async def archivereports(self, ctx): async def archivereports(self, ctx):
"""Archive all in-game reports older than 24 hours""" """Archive all in-game reports older than 24 hours"""
count = 0 count = 0