added debug command
This commit is contained in:
parent
fbabb1254d
commit
31a4098476
21
fouras.py
21
fouras.py
@ -6,6 +6,7 @@ from datetime import datetime, timedelta, timezone
|
||||
import random
|
||||
from dotenv import load_dotenv
|
||||
import re
|
||||
import json
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
@ -99,6 +100,9 @@ async def on_message(message):
|
||||
if fouras_match:
|
||||
index = int(fouras_match.group(1)) - 1
|
||||
if index >= 0 and index < len(client.riddles):
|
||||
if random.random() <= 0.03:
|
||||
await message.channel.send("Non")
|
||||
else:
|
||||
await message.channel.send(new_riddle(message.channel, index))
|
||||
else:
|
||||
await message.channel.send("Numéro d'énigme invalide, merci de saisir un numéro entre 1 et {0}".format(len(client.riddles)))
|
||||
@ -106,8 +110,7 @@ async def on_message(message):
|
||||
if message_content == 'fouras':
|
||||
if random.random() <= 0.03:
|
||||
await message.channel.send("Non")
|
||||
return
|
||||
if len(client.riddles) > 0:
|
||||
elif len(client.riddles) > 0:
|
||||
index = random.randint(0, len(client.riddles) - 1)
|
||||
await message.channel.send(new_riddle(message.channel, index))
|
||||
return
|
||||
@ -118,6 +121,20 @@ async def on_message(message):
|
||||
await message.channel.send('Loaded {0} riddles'.format(len(client.riddles)))
|
||||
return
|
||||
|
||||
if message_content == 'debug':
|
||||
dump = {}
|
||||
for key, value in client.ongoing_riddles.items():
|
||||
dump_channel = value
|
||||
dump_channel.pop("message", None)
|
||||
dump_channel['answer'] = '||{0}||'.format(dump_channel['answer'])
|
||||
if isinstance(key, discord.DMChannel):
|
||||
dm_channel = await client.fetch_channel(key.id)
|
||||
dump['[DM={0}]'.format(dm_channel.recipient.name)] = dump_channel
|
||||
else:
|
||||
dump['[Server={0}] => [Channel={1}]'.format(key.guild.name, key.name)] = dump_channel
|
||||
await message.author.send(json.dumps(dump, ensure_ascii=False, indent=4))
|
||||
return
|
||||
|
||||
# if current channel has ongoing riddle
|
||||
if message.channel in client.ongoing_riddles:
|
||||
current_riddle = client.ongoing_riddles[message.channel]
|
||||
|
Loading…
x
Reference in New Issue
Block a user