main: Prevent the bot from being triggered accidentally by adding a prefix #1

Merged
Sugary merged 2 commits from werru/nyabot:master into master 2023-08-22 15:24:45 +00:00
Showing only changes of commit fa010d901c - Show all commits

View file

@ -249,13 +249,14 @@ async def help(ctx: discord.ApplicationContext):
async def gif_command_handler(message: discord.Message, command: list[str]): async def gif_command_handler(message: discord.Message, command: list[str]):
command_typed = command[1] command_typed = command[0]
target = message.author.name target = message.author.name
sender = message.author.name sender = message.author.name
if len(message.mentions) > 0: if len(message.mentions) > 0:
target = message.mentions[0].name target = message.mentions[0].name
if command_typed == "help": if command_typed == "help":
await message.reply(HELP_MESSAGE) await message.reply(HELP_MESSAGE)
return return
@ -297,8 +298,10 @@ async def on_message(message: discord.Message):
# TODO: Do proper parsing of the message # TODO: Do proper parsing of the message
message_as_command = message.content.split("nya ") message_as_command = message.content.split("nya ")
message_as_command = message_as_command[1].split(" ")
command = message_as_command[0]
command = message_as_command[1]
if command in GIF_COMMANDS: if command in GIF_COMMANDS:
await gif_command_handler(message, message_as_command) await gif_command_handler(message, message_as_command)