mirror of
https://github.com/Floriansylvain/Risitas_BOT.git
synced 2026-08-19 11:43:16 +02:00
✨ - The bot owner can now load and unload extensions with $loadext {ext} and $unloadext {ext}.
This commit is contained in:
+29
-4
@@ -12,10 +12,35 @@ async def on_ready():
|
|||||||
print('We have logged in as ' + bot.user.name + '.')
|
print('We have logged in as ' + bot.user.name + '.')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
@bot.command(hidden=True)
|
||||||
for extension in startup_extensions:
|
@commands.is_owner()
|
||||||
|
async def loadext(ctx, extension):
|
||||||
try:
|
try:
|
||||||
bot.load_extension(extension)
|
bot.load_extension(extension)
|
||||||
except Exception as e:
|
await ctx.send(str(extension) + ' successfully loaded.')
|
||||||
print(e)
|
except discord.ext.commands.ExtensionNotFound:
|
||||||
|
await ctx.send('Extension not found.')
|
||||||
|
except discord.ext.commands.ExtensionAlreadyLoaded:
|
||||||
|
await ctx.send('Extension already loaded.')
|
||||||
|
except discord.ext.commands.NoEntryPointError as a:
|
||||||
|
await ctx.send(a)
|
||||||
|
except ExtensionFailed as b:
|
||||||
|
await ctx.send(b)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command(hidden=True)
|
||||||
|
@commands.is_owner()
|
||||||
|
async def unloadext(ctx, extension):
|
||||||
|
try:
|
||||||
|
bot.unload_extension(extension)
|
||||||
|
await ctx.send(str(extension) + ' successfully unloaded.')
|
||||||
|
except discord.ext.commands.ExtensionNotFound:
|
||||||
|
await ctx.send('Extension not found.')
|
||||||
|
except discord.ext.commands.ExtensionNotLoaded:
|
||||||
|
await ctx.send('Extension not loaded.')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for extension in startup_extensions:
|
||||||
|
bot.load_extension(extension)
|
||||||
bot.run(TOKEN_BOT)
|
bot.run(TOKEN_BOT)
|
||||||
|
|||||||
Reference in New Issue
Block a user