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-03-04 05:54:38 +00:00
|
|
|
plugin = lightbulb.Plugin("master", default_enabled_guilds=c.config["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):
|
2022-03-04 06:01:21 +00:00
|
|
|
owners = (
|
|
|
|
context.bot.application.team.members if context.bot.application.team else [context.bot.application.owner.id]
|
|
|
|
)
|
|
|
|
|
|
|
|
if context.user.id in owners:
|
2022-02-21 07:10:57 +00:00
|
|
|
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-03-04 05:57:35 +00:00
|
|
|
f"**Reloaded `{'`, `'.join(extensions[:-1])}`, and `{extensions[-1]}` for you, master**"
|
2022-02-21 20:53:53 +00:00
|
|
|
)
|
|
|
|
case "sleep":
|
2022-03-04 05:57:35 +00:00
|
|
|
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(
|
2022-02-23 23:48:08 +00:00
|
|
|
f"https://discord.com/api/oauth2/authorize?client_id={c.config['client']}&permissions=1024&scope=bot%20applications.commands"
|
2022-02-21 21:50:05 +00:00
|
|
|
)
|
2022-02-21 07:10:57 +00:00
|
|
|
case _:
|
2022-03-04 05:57:35 +00:00
|
|
|
await context.respond(f"**Hello, master**")
|
2022-02-21 07:10:57 +00:00
|
|
|
else:
|
2022-03-04 05:57:35 +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)
|