1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 21:02:38 +00:00
modufur/commands/master.py

44 lines
1.5 KiB
Python
Raw Normal View History

2022-02-21 07:10:57 +00:00
import os
2022-02-21 20:53:53 +00:00
2022-02-21 07:10:57 +00:00
import lightbulb
2022-02-21 21:50:05 +00:00
import config as c
2022-02-21 07:10:57 +00:00
2022-02-21 20:53:53 +00:00
plugin = lightbulb.Plugin("master")
2022-02-21 07:10:57 +00:00
@plugin.command
2022-02-21 21:50:05 +00:00
@lightbulb.option("command", "What is your command, master?", required=False, choices=("reload", "sleep", "invite"))
2022-02-21 20:53:53 +00:00
@lightbulb.command("master", "Commands my master can demand of me", ephemeral=True)
2022-02-21 07:10:57 +00:00
@lightbulb.implements(lightbulb.SlashCommand)
async def master(context):
if context.user.id == context.bot.application.owner.id:
match context.options.command:
2022-02-21 20:53:53 +00:00
case "reload":
2022-02-21 07:10:57 +00:00
context.bot.reload_extensions(*context.bot.extensions)
extensions = [os.path.splitext(extension)[1][1:] for extension in context.bot.extensions]
2022-02-21 20:53:53 +00:00
await context.respond(
2022-02-23 23:47:12 +00:00
f"**Reloaded `{'`, `'.join(extensions[:-1])}`, and `{extensions[-1]}` for you, master.**"
2022-02-21 20:53:53 +00:00
)
case "sleep":
await context.respond("**Goodnight, master.**")
2022-02-21 07:10:57 +00:00
await context.bot.close()
2022-02-21 21:50:05 +00:00
case "invite":
await context.respond(
f"https://discord.com/api/oauth2/authorize?client_id={c.config['client']}&permissions=0&scope=bot%20applications.commands"
)
2022-02-21 07:10:57 +00:00
case _:
2022-02-21 20:53:53 +00:00
await context.respond(f"**Hello, master.**")
2022-02-21 07:10:57 +00:00
else:
2022-02-21 20:53:53 +00:00
await context.respond(f"**{context.bot.application.owner.mention} is my master. 🐺**")
2022-02-21 07:10:57 +00:00
def load(bot):
bot.add_plugin(plugin)
2022-02-21 20:53:53 +00:00
2022-02-21 07:10:57 +00:00
def unload(bot):
bot.remove_plugin(plugin)