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 be98ec9dd105d711dcd577f08d1436531014dba8
parent 3ce0bafc3942a6705b48105e253ba52b16bb53ec
Author: Asher Morgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Sat, 30 Mar 2024 19:53:54 -0700

Update to work with discord.py v2.0

Diffstat:
Msrc/bot.py | 14++++++++++----
Msrc/botUtilities.py | 2+-
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/bot.py b/src/bot.py @@ -13,8 +13,12 @@ from src.models import getSessionMaker, EmptyCountdownError class CountdownBot(commands.Bot): def __init__(self, settings): + # Get intents + intents = discord.Intents.default() + intents.message_content = True + # Initialize bot - commands.Bot.__init__(self, command_prefix=lambda bot, ctx: getPrefix(self.databaseSessionMaker, ctx, self.prefixes)) + commands.Bot.__init__(self, command_prefix=lambda bot, ctx: getPrefix(self.databaseSessionMaker, ctx, self.prefixes), intents=intents) # Set properties self.databaseSessionMaker = getSessionMaker(settings["database"]) @@ -25,9 +29,11 @@ class CountdownBot(commands.Bot): self.logger = logging.getLogger() self.logger.setLevel(getattr(logging, settings["log_level"].upper())) - # Add cogs - self.add_cog(analyticsCog.Analytics(self, self.databaseSessionMaker)) - self.add_cog(utilitiesCog.Utilities(self, self.databaseSessionMaker)) + + + async def setup_hook(self): + await self.add_cog(analyticsCog.Analytics(self, self.databaseSessionMaker)) + await self.add_cog(utilitiesCog.Utilities(self, self.databaseSessionMaker)) diff --git a/src/botUtilities.py b/src/botUtilities.py @@ -313,7 +313,7 @@ async def loadCountdown(bot, countdown): countdown.messages = [] # Get Discord messages - rawMessages = await bot.get_channel(countdown.id).history(limit=10100).flatten() + rawMessages = [message async for message in bot.get_channel(countdown.id).history(limit=10100)] rawMessages.reverse() # Add messages to countdown