diff --git a/bot.py b/bot.py index c4380a3..b042c59 100644 --- a/bot.py +++ b/bot.py @@ -7,17 +7,19 @@ load_dotenv() intents = discord.Intents.default() -intents.message = True +intents.messages = True intents.message_content = True bot = commands.Bot(command_prefix='!', intents=intents) def extract_number_and_sum(message): numbers = list(map(int, re.findall(r'\b\d+\b', message))) + total = 0 total += sum(numbers) return numbers, total @bot.event async def on_ready(): + await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="les nombres riglos")) print(f'{bot.user} has connected to Discord!') @bot.event @@ -26,14 +28,23 @@ async def on_message(message): return numbers, total = extract_number_and_sum(message.content) + print(f"{numbers}, {total}") if total == 69: - response = f"Super ! Tous les nombres de votre message s'additionnent à 69 !\n\n" + response = "Génial ! Tous les nombres de votre message s'additionnent à 69 !\n\n" response += "```" response += "\n".join([f"{n} + " for n in numbers]) response += f"\n= {total}" response += "```" + reactions = ["6️⃣", "9️⃣", "👀"] + for emoji in reactions: + await message.add_reaction(emoji) await message.channel.send(response) await bot.process_commands(message) -bot.run(os.getenv('DISCORD_TOKEN')) \ No newline at end of file +token = os.getenv('DISCORD_TOKEN') + +if token: + bot.run(token) +else: + print("No token found in .env file") \ No newline at end of file