diff --git a/bot.ini.example b/bot.ini.example index ebc443f..6913281 100644 --- a/bot.ini.example +++ b/bot.ini.example @@ -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 \ No newline at end of file +bottoken=BOTTOKEN_HERE +botprefixes=. diff --git a/pybot-f.py b/pybot-f.py index bee0bf2..c073fe5 100644 --- a/pybot-f.py +++ b/pybot-f.py @@ -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