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

This commit is contained in:
Werru 2023-08-21 14:43:59 -04:00
parent f7108de78e
commit c78f2bc4a7

13
main.py
View file

@ -249,7 +249,7 @@ 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[0] command_typed = command[1]
target = message.author.name target = message.author.name
sender = message.author.name sender = message.author.name
@ -290,10 +290,15 @@ async def on_message(message: discord.Message):
if message.author.bot == True: if message.author.bot == True:
return return
# TODO: Do proper parsing of the message # Should prevent the bot from being accidentally triggered from now on. Also will make
message_as_command = message.content.split(" ") # the people here have to say nya more often which is always a bonus.
if message.content.startswith('nya') == False:
return
command = message_as_command[0] # TODO: Do proper parsing of the message
message_as_command = message.content.split("nya ")
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)