mirror of
https://github.com/osmarks/autobotrobot
synced 2026-09-11 21:35:41 +00:00
refactoring, userdata module
This commit is contained in:
+12
-7
@@ -6,14 +6,15 @@ from discord.ext import commands
|
||||
import util
|
||||
|
||||
def setup(bot):
|
||||
@bot.group()
|
||||
@bot.group(help="Debug/random messing around utilities. Owner-only.")
|
||||
@commands.check(util.admin_check)
|
||||
async def magic(ctx):
|
||||
if ctx.invoked_subcommand == None:
|
||||
return await ctx.send("Invalid magic command.")
|
||||
|
||||
@magic.command(rest_is_raw=True)
|
||||
@magic.command(rest_is_raw=True, brief="Execute Python.")
|
||||
async def py(ctx, *, code):
|
||||
"Executes Python. You may supply a codeblock. Comments in the form #timeout:([0-9]+) will be used as a timeout specifier. React with :x: to stop, probably."
|
||||
timeout = 5.0
|
||||
timeout_match = re.search("#timeout:([0-9]+)", code, re.IGNORECASE)
|
||||
if timeout_match:
|
||||
@@ -49,8 +50,9 @@ def setup(bot):
|
||||
except BaseException as e:
|
||||
await ctx.send(embed=util.error_embed(util.gen_codeblock(traceback.format_exc())))
|
||||
|
||||
@magic.command(rest_is_raw=True)
|
||||
@magic.command(rest_is_raw=True, help="Execute SQL code against the database.")
|
||||
async def sql(ctx, *, code):
|
||||
"Executes SQL (and commits). You may use a codeblock, similarly to with py."
|
||||
code = util.extract_codeblock(code)
|
||||
try:
|
||||
csr = bot.database.execute(code)
|
||||
@@ -63,11 +65,14 @@ def setup(bot):
|
||||
except Exception as e:
|
||||
await ctx.send(embed=util.error_embed(util.gen_codeblock(traceback.format_exc())))
|
||||
|
||||
@magic.command()
|
||||
@magic.command(help="Reload configuration file.")
|
||||
async def reload_config(ctx):
|
||||
util.load_config()
|
||||
ctx.send("Done!")
|
||||
|
||||
@magic.command()
|
||||
async def reload_ext(ctx):
|
||||
for ext in util.extensions: bot.reload_extension(ext)
|
||||
@magic.command(help="Reload extensions (all or the specified one).")
|
||||
async def reload_ext(ctx, ext="all"):
|
||||
if ext == "all":
|
||||
for ext in util.extensions: bot.reload_extension(ext)
|
||||
else: bot.reload_extension(ext)
|
||||
await ctx.send("Done!")
|
||||
Reference in New Issue
Block a user