Skip to content

Commit

Permalink
Major improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Plexi09 committed Jan 3, 2025
1 parent 23a4f5a commit a80e268
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'))
token = os.getenv('DISCORD_TOKEN')

if token:
bot.run(token)
else:
print("No token found in .env file")

0 comments on commit a80e268

Please sign in to comment.