Więc chciałem zrobić bota do discorda który zadaje użytkownikom wcześniej przygotowane przez innego użytkownika pytania. Cały syf z tworzeniem pytań jest gotowy, ale teraz trzeba zająć się zadawaniem pytań. Moim pomysłem jest wyłączanie możliwością pisania na 10 sekund i po tym zadać kolejne pytanie, ale zawsze się musi coś zepsuć:
- Nie mam zielonego pojęcia jak zmienić uprawnienia dla wszystkich użytkownika.
-
await ctx.channel.set_permissions(ctx.author, send_messages=False)
<- ta część kodu nie działa (ctx.author
było tymczasowe, chciałem przetestować tą funkcję)
Reszta kodu, jeśli jest potrzebna
@client.command()
async def start_xam(ctx, name_of_xam):
with open('xams.json') as file:
xams = json.loads(file.read())
current_xam = None
for xam in xams:
if xam['name'] == name_of_xam:
current_xam = xam
break
if current_xam == None:
await ctx.send('```This xam does not exist :-(```')
return
number_of_questions = 0
if len(current_xam['xercises']) <= 0:
await ctx.send("```This xam doesn't have any xercises :-(```")
return
elif len(current_xam['xercises']) < 2:
number_of_questions = 1
else:
number_of_questions = len(current_xam['xercises']) // 2
for i in range(number_of_questions):
question_index = random.randint(0, len(current_xam['xercises']))
current_question = current_xam['xercises'][question_index]
#Część stąd...
await ctx.channel.set_permissions(ctx.author, read_messages=True, send_messages=False)
time.sleep(10)
await ctx.channel.set_permissions(ctx.author, read_messages=True, send_messages=True)
time.sleep(10)
#...dotąd jest też tymczasowa, chciałem to przetestować