aboutsummaryrefslogtreecommitdiff
path: root/cogs/admin.py
diff options
context:
space:
mode:
authorAnInternetTroll <lucafulger@gmail.com>2020-05-10 10:57:29 +0000
committerAnInternetTroll <lucafulger@gmail.com>2020-05-10 10:57:29 +0000
commite56aee64210ebcb2603d1497bdc577670b7e0ed7 (patch)
tree2b31498d672aab1a86231abf02d981c7cd454496 /cogs/admin.py
parent7f15747e7689b9bc58105cc909f0d8b95081fbd9 (diff)
downloadsteve-bot-e56aee64210ebcb2603d1497bdc577670b7e0ed7.tar
steve-bot-e56aee64210ebcb2603d1497bdc577670b7e0ed7.tar.gz
steve-bot-e56aee64210ebcb2603d1497bdc577670b7e0ed7.tar.bz2
steve-bot-e56aee64210ebcb2603d1497bdc577670b7e0ed7.tar.lz
steve-bot-e56aee64210ebcb2603d1497bdc577670b7e0ed7.tar.xz
steve-bot-e56aee64210ebcb2603d1497bdc577670b7e0ed7.tar.zst
steve-bot-e56aee64210ebcb2603d1497bdc577670b7e0ed7.zip
General improvements
Diffstat (limited to '')
-rwxr-xr-xcogs/admin.py114
1 files changed, 57 insertions, 57 deletions
diff --git a/cogs/admin.py b/cogs/admin.py
index 4cf7df7..6cbaf52 100755
--- a/cogs/admin.py
+++ b/cogs/admin.py
@@ -1,70 +1,70 @@
from discord.ext import commands
import discord
-
import subprocess
-
import json
class Admin(commands.Cog):
- def __init__(self, bot):
- self.bot = bot
+ def __init__(self, bot):
+ self.bot = bot
+
+ async def is_mod(ctx):
+ return ctx.author.guild_permissions.manage_channels
- async def is_mod(ctx):
- return ctx.author.guild_permissions.manage_channels
+ async def is_host(ctx):
+ return ctx.author.id == 99457716614885376
- @commands.command(aliases=['addcommand', 'newcommand'])
- @commands.check(is_mod)
- async def setcommand(self, ctx, command, *, message):
- self.bot.custom_commands["/" + command] = message
- with open('custom_commands.json', 'w') as f:
- json.dump(self.bot.custom_commands, f)
+ @commands.command(aliases=['addcommand', 'newcommand'])
+ @commands.check(is_mod)
+ async def setcommand(self, ctx, command, *, message):
+ self.bot.custom_commands["/" + command] = message
+ with open('custom_commands.json', 'w') as f:
+ json.dump(self.bot.custom_commands, f)
- await ctx.send(f"Set message for command {command}")
+ await ctx.send(f"Set message for command {command}")
- @commands.command(aliases=['deletecommand'])
- @commands.check(is_mod)
- async def removecommand(self, ctx, command):
- del self.bot.custom_commands["/" + command]
- with open('custom_commands.json', 'w') as f:
- json.dump(self.bot.custom_commands, f)
+ @commands.command(aliases=['deletecommand'])
+ @commands.check(is_mod)
+ async def removecommand(self, ctx, command):
+ del self.bot.custom_commands["/" + command]
+ with open('custom_commands.json', 'w') as f:
+ json.dump(self.bot.custom_commands, f)
- await ctx.send(f"Removed command {command}")
-
-
- @commands.check(is_mod)
- @commands.command(name='reload', hidden=True, usage='<extension>')
- async def _reload(self, ctx, ext):
- """Reloads an extension"""
- try:
- self.bot.reload_extension(f'cogs.{ext}')
- await ctx.send(f'The extension {ext} was reloaded!')
- except commands.ExtensionNotFound:
- await ctx.send(f'The extension {ext} doesn\'t exist.')
- except commands.ExtensionNotLoaded:
- await ctx.send(f'The extension {ext} is not loaded! (use /load)')
- except commands.NoEntryPointError:
- await ctx.send(f'The extension {ext} doesn\'t have an entry point (try adding the setup function) ')
- except commands.ExtensionFailed:
- await ctx.send(f'Some unknown error happened while trying to reload extension {ext} (check logs)')
- self.bot.logger.exception(f'Failed to reload extension {ext}:')
-
- @commands.check(is_mod)
- @commands.command(name='load', hidden=True, usage='<extension>')
- async def _load(self, ctx, ext):
- """Loads an extension"""
- try:
- self.bot.load_extension(f'cogs.{ext}')
- await ctx.send(f'The extension {ext} was loaded!')
- except commands.ExtensionNotFound:
- await ctx.send(f'The extension {ext} doesn\'t exist!')
- except commands.ExtensionAlreadyLoaded:
- await ctx.send(f'The extension {ext} is already loaded.')
- except commands.NoEntryPointError:
- await ctx.send(f'The extension {ext} doesn\'t have an entry point (try adding the setup function)')
- except commands.ExtensionFailed:
- await ctx.send(f'Some unknown error happened while trying to reload extension {ext} (check logs)')
- self.bot.logger.exception(f'Failed to reload extension {ext}:')
-
+ await ctx.send(f"Removed command {command}")
+
+
+ @commands.check(is_mod)
+ @commands.command(name='reload', hidden=True, usage='<extension>')
+ async def _reload(self, ctx, ext):
+ """Reloads an extension"""
+ try:
+ self.bot.reload_extension(f'cogs.{ext}')
+ await ctx.send(f'The extension {ext} was reloaded!')
+ except commands.ExtensionNotFound:
+ await ctx.send(f'The extension {ext} doesn\'t exist.')
+ except commands.ExtensionNotLoaded:
+ await ctx.send(f'The extension {ext} is not loaded! (use /load)')
+ except commands.NoEntryPointError:
+ await ctx.send(f'The extension {ext} doesn\'t have an entry point (try adding the setup function) ')
+ except commands.ExtensionFailed:
+ await ctx.send(f'Some unknown error happened while trying to reload extension {ext} (check logs)')
+ self.bot.logger.exception(f'Failed to reload extension {ext}:')
+
+ @commands.check(is_mod)
+ @commands.command(name='load', hidden=True, usage='<extension>')
+ async def _load(self, ctx, ext):
+ """Loads an extension"""
+ try:
+ self.bot.load_extension(f'cogs.{ext}')
+ await ctx.send(f'The extension {ext} was loaded!')
+ except commands.ExtensionNotFound:
+ await ctx.send(f'The extension {ext} doesn\'t exist!')
+ except commands.ExtensionAlreadyLoaded:
+ await ctx.send(f'The extension {ext} is already loaded.')
+ except commands.NoEntryPointError:
+ await ctx.send(f'The extension {ext} doesn\'t have an entry point (try adding the setup function)')
+ except commands.ExtensionFailed:
+ await ctx.send(f'Some unknown error happened while trying to reload extension {ext} (check logs)')
+ self.bot.logger.exception(f'Failed to reload extension {ext}:')
def setup(bot):
- bot.add_cog(Admin(bot))
+ bot.add_cog(Admin(bot))