Compare commits

...

3 commits

2 changed files with 18 additions and 5 deletions

View file

@ -11,6 +11,12 @@
# try searching the internet for "How to create a Discord bot token" or
# visit: https://discordpy.readthedocs.io/en/latest/discord.html
# Also don't forget to invite the bot onto your server(s).
#
# - botprefixes
# This is the prefix for commands when not using slash-commands.
# Can also contain several prefixes, define it like: botprefixes=['!', '?','.']
# (list of strings)
[General]
bottoken=BOTTOKEN_HERE
botprefixes=.

View file

@ -11,9 +11,6 @@ from logging import handlers
# Logging
#loghandler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w')
#discord.utils.setup_logging(handler=loghandler)
logger = logging.getLogger('discord')
logger.setLevel(logging.INFO)
@ -48,10 +45,20 @@ config.read('bot.ini')
bottoken = config['General']['bottoken']
botprefixes = config['General']['botprefixes']
def get_prefixes(bot, message):
"""
For setting the bots prefixes in addition to mentions.
"""
prefixes = botprefixes # Can be a list of strings
return commands.when_mentioned_or(*prefixes)(bot, message)
# Setting up commands.Bot
bot = commands.Bot(command_prefix='.', description=description, intents=intents)
bot = commands.Bot(command_prefix=get_prefixes, description=description, intents=intents)
@bot.event