mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Make prefixes case insensitive, make Hmm? easter egg work with all prefixes
This commit is contained in:
parent
e364d964a2
commit
c897cebcd5
5 changed files with 46 additions and 20 deletions
|
|
@ -1,16 +1,15 @@
|
|||
from data import constants
|
||||
import random
|
||||
|
||||
from data import constants
|
||||
|
||||
|
||||
def control(message):
|
||||
def control(bot, message):
|
||||
if str(message.author.id) == constants.didierId:
|
||||
return ""
|
||||
elif didier(message.content):
|
||||
elif didier(bot, message.content):
|
||||
return "Hmm?"
|
||||
elif any(term in message.content for term in ["gib dink", "gib donk"]):
|
||||
return "No."
|
||||
elif didier(message.content.split(" ")[0]) and any(term in message.content.lower() for term in ["are you sure", "are u sure"]):
|
||||
elif didier(bot, message.content.split(" ")[0]) and any(term in message.content.lower() for term in ["are you sure", "are u sure"]):
|
||||
return "I'm not just sure, I'm HIV Positive."
|
||||
elif any(message.content.lower().startswith(term) for term in ["is this", "isthis", "isdis", "is dis"]):
|
||||
res = random.randint(0, 100)
|
||||
|
|
@ -24,6 +23,6 @@ def control(message):
|
|||
return ""
|
||||
|
||||
|
||||
def didier(message):
|
||||
def didier(bot, message):
|
||||
ml = message.lower()
|
||||
return ml == "didier" or ml == "<@!{}>".format(constants.didierId)
|
||||
return ml in constants.prefixes or ml == "<@!{}>".format(bot.user.id)
|
||||
|
|
|
|||
28
functions/prefixes.py
Normal file
28
functions/prefixes.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from data.constants import prefixes
|
||||
from discord.ext import commands
|
||||
import os
|
||||
|
||||
|
||||
fallback = os.urandom(32).hex()
|
||||
|
||||
|
||||
def get_prefix(bot: commands.Bot, message):
|
||||
content = message.content.lower()
|
||||
mention = "<@!{}>".format(bot.user.id)
|
||||
|
||||
# Used @Didier
|
||||
if content.startswith(mention):
|
||||
if content.startswith(mention + " "):
|
||||
return mention + " "
|
||||
return mention
|
||||
|
||||
# Used a prefix
|
||||
for prefix in prefixes:
|
||||
# Find correct prefix
|
||||
if content.startswith(prefix):
|
||||
# Check if a space has to be added to invoke commands
|
||||
if content.startswith(prefix + " "):
|
||||
return prefix + " "
|
||||
return prefix
|
||||
|
||||
return fallback
|
||||
Loading…
Add table
Add a link
Reference in a new issue