From 336c3f7655f236cdbeb79e93ecb12bc488fbe0c9 Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Tue, 25 Oct 2022 19:39:02 +0200 Subject: [PATCH] fix initial async errors --- Points.py | 1 + Stroopwafel.py | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Points.py b/Points.py index 564f190..280ae5a 100644 --- a/Points.py +++ b/Points.py @@ -15,6 +15,7 @@ class Points(commands.Cog): self.voice_states = {} self.BANK_ID = 42 + self.init() def __check(self, ctx): return True diff --git a/Stroopwafel.py b/Stroopwafel.py index 1086b15..b6e4120 100644 --- a/Stroopwafel.py +++ b/Stroopwafel.py @@ -15,7 +15,15 @@ from discord.ext import commands logging.basicConfig(level=logging.INFO) -bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True) +async def add_cogs(bot): + await bot.add_cog(Shitpost.Shitpost(bot)) + await bot.add_cog(General.General(bot)) + await bot.add_cog(Cryptocoin.Cryptocoin(bot)) + await bot.add_cog(Chatbot.Chatbot(bot)) + await bot.add_cog(Points.Points(bot)) + + +bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=discord.Intents.default()) #Read configuration file: config = configparser.ConfigParser() @@ -24,6 +32,7 @@ bot.tokens = config["tokens"] bot.hdChannels = {} for channel in config["channels"]: #channelIDs must be integers bot.hdChannels[channel] = int(config["channels"][channel]) + #passwords are base64 encoded, which makes it like 1% safer bot.passwords = {} for pw in config["passwords"]: @@ -33,20 +42,9 @@ for pw in config["passwords"]: print("Problem with decoding password!") bot.passwords[pw] = config["passwords"][pw] -#bot.add_cog(Music.Music(bot)) -#TODO: Re-add music functions now that we require a stronger host -bot.add_cog(Shitpost.Shitpost(bot)) -bot.add_cog(General.General(bot)) -bot.add_cog(Cryptocoin.Cryptocoin(bot)) -bot.add_cog(Chatbot.Chatbot(bot)) -pointsBot = Points.Points(bot) -bot.add_cog(pointsBot) - @bot.event -@asyncio.coroutine -def on_ready(): +async def on_ready(): + await add_cogs(bot) print('Logged in as:\n{0} (ID: {0.id})'.format(bot.user)) - #TODO: find out how to do this properly: - pointsBot.init() bot.run(bot.tokens["discordbot"])