Enable commands globally if not sandboxing, add support for test guilds in env, monitor slash command & context menu usage, create error handler for slash commands, log slash commands in terminal

This commit is contained in:
Stijn De Clercq 2021-09-03 20:40:03 +02:00
parent ef547a7090
commit a28bd116f0
12 changed files with 117 additions and 62 deletions

View file

@ -13,8 +13,7 @@ class DefineSlash(commands.Cog):
description="Urban Dictionary",
options=[
Option("query", "Search query", OptionType.STRING, required=True)
],
guild_ids=[728361030404538488, 880175869841277008]
]
)
async def _define_slash(self, interaction: SlashInteraction, query):
embed = Definition(query).to_embed()

View file

@ -12,8 +12,7 @@ class GoogleSlash(commands.Cog):
description="Google search",
options=[
Option("query", "Search query", OptionType.STRING, required=True)
],
guild_ids=[728361030404538488, 880175869841277008]
]
)
async def _google_slash(self, interaction: SlashInteraction, query: str):
result = google_search(query)

View file

@ -14,11 +14,12 @@ class TranslateSlash(commands.Cog):
description="Google Translate",
options=[
Option("text", "Tekst om te vertalen", OptionType.STRING, required=True),
Option("to", "Taal om naar te vertalen (default NL)", OptionType.STRING)
Option("from_lang", "Taal om van te vertalen (default auto-detect)", OptionType.STRING),
Option("to_lang", "Taal om naar te vertalen (default NL)", OptionType.STRING)
]
)
async def _translate_slash(self, interaction: SlashInteraction, text: str, to: str = "nl"):
translation = Translation(text=text, to=to.lower())
async def _translate_slash(self, interaction: SlashInteraction, text: str, from_lang: str = "auto", to_lang: str = "nl"):
translation = Translation(text=text, fr=from_lang.lower(), to=to_lang.lower())
await interaction.reply(embed=translation.to_embed())