forked from LAION-AI/Open-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelp.py
43 lines (32 loc) · 1.38 KB
/
help.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Custom help command."""
import lightbulb
from bot.messages import help_message, tutorial_message
from bot.settings import Settings
from hikari.permissions import Permissions
from lightbulb.utils import permissions_for
plugin = lightbulb.Plugin("HelpPlugin")
settings = Settings()
@plugin.command
@lightbulb.command("help", "Help for the bot.", ephemeral=True)
@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand)
async def help_command(ctx: lightbulb.Context) -> None:
"""Help for the bot."""
can_manage_guild = False
if ctx.guild_id:
member = ctx.bot.cache.get_member(ctx.guild_id, ctx.author.id) or await ctx.bot.rest.fetch_member(
ctx.guild_id, ctx.author.id
)
can_manage_guild = bool(permissions_for(member) & Permissions.MANAGE_GUILD)
await ctx.respond(help_message(can_manage_guild, ctx.author.id in settings.owner_ids))
@plugin.command
@lightbulb.command("tutorial", "A tutorial for completing tasks.", ephemeral=True)
@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand)
async def tutorial(ctx: lightbulb.Context) -> None:
"""Help for the bot."""
await ctx.respond(tutorial_message(True, True))
def load(bot: lightbulb.BotApp):
"""Add the plugin to the bot."""
bot.add_plugin(plugin)
def unload(bot: lightbulb.BotApp):
"""Remove the plugin to the bot."""
bot.remove_plugin(plugin)