countdown-bot

A Discord bot that runs countdown games and generates analytics
git clone https://git.ashermorgan.net/countdown-bot/
Log | Files | Refs | README

commit a2661c25df0afb87e0017f313495d3d115bdde62
parent 17aee92b472e867e4a875505cfddca486e007fd1
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Sat, 27 Feb 2021 08:45:46 -0800

Ensure there is always at least one active prefix

Diffstat:
Mbot.py | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bot.py b/bot.py @@ -160,17 +160,17 @@ def getPrefix(bot, ctx): # Countdown channel global data - if (str(ctx.channel.id) in data["countdowns"]): + if (str(ctx.channel.id) in data["countdowns"] and len(data["countdowns"][str(ctx.channel.id)]["prefixes"]) > 0): return data["countdowns"][str(ctx.channel.id)]["prefixes"] # Server with countdown channels if (isinstance(ctx.channel, discord.channel.TextChannel)): serverChannels = [x for x in data["countdowns"] if data["countdowns"][x]["server"] == ctx.channel.guild.id] - if (len(serverChannels) > 0): - # Get list of prefixes - prefixes = [] - for channel in serverChannels: - prefixes += data["countdowns"][channel]["prefixes"] + # Get list of prefixes + prefixes = [] + for channel in serverChannels: + prefixes += data["countdowns"][channel]["prefixes"] + if (len(prefixes) > 0): return sorted(list(set(prefixes))) # Return default prefixes