So, I found this question I want to make a multi-page help command using discord.py But the answer make me a doubt. I tried a similar code to just try this thing, but while the loop is going on I literally can't use any of the other commands. What should I do in order to permit all the commands work while the loop is going on?
import discord
import datetime
from datetime import timedelta
import pytz
from discord.ext import commands
client = discord.Client()
client = commands.Bot(command_prefix = "!")
prefix = "!"
id = client.get_guild(766402039495262218)
@client.event
async def on_ready():
print("Bot is ready")
game = discord.Game("Could I Destroy a Server...?")
await client.change_presence(status=discord.Status.idle, activity=game)
@client.event
async def on_message(message):
await client.process_commands(message)
@client.event
async def on_reaction_add(reaction, user):
channel = reaction.message.channel
if reaction.emoji == '➡':
if reaction.message.embeds == discord.embeds.Embed(title='Corsi Informatica I Anno'):
await channel.send("ok")
print("ok")
else:
print(reaction.message.embeds)
print("not ok")
else:
await channel.send("YOLO")
@client.command(pass_context = True)
async def test(ctx):
await ctx.message.channel.send("this is a testing test")
@client.command(pass_context=True)
async def corsi(ctx):
page = 1
left_arrow = '⬅'
right_arrow = '➡'
first_year = discord.Embed(
title = 'Corsi Informatica I Anno',
description = 'Lista dei corsi:',
colour = discord.Colour.dark_blue()
)
second_year = discord.Embed(
title = 'Corsi Informatica II Anno',
description = 'Lista dei corsi:',
colour = discord.Colour.dark_green()
)
third_year = discord.Embed(
title = 'Corsi Informatica III Anno',
description = 'Lista dei corsi:',
colour = discord.Colour.dark_red()
)
first_year.set_footer(text = datetime.datetime.now().strftime('%d/%m/%Y %H:%M') + "\t\t\t\t\t\t\t\t\t\t\t\t\t" + "pag." + " " + str(page)+"/3")
first_year.set_author(name = ctx.message.author)
first_year.add_field(name = 'Calcolo I', value = 'I Semestre', inline = True)
first_year.add_field(name = 'Algebra Lineare', value='I Semestre', inline = True)
first_year.add_field(name ='Programmazione I', value='I Semestre', inline=True)
first_year.add_field(name='--------------------------------------------------------------------------',value="**--------------------------------------------------------------------------**"
,inline=False)
first_year.add_field(name ='Elaboratori I', value='I Semestre', inline = True)
first_year.add_field(name ='Matematica Discreta', value='I Semestre', inline = True)
first_year.add_field(name ='Programmazione II', value='II Semestre', inline = True)
first_year.add_field(name='--------------------------------------------------------------------------',value="**--------------------------------------------------------------------------**",
inline=False)
first_year.add_field(name ='Elaboratori II', value='II Semestre', inline = True)
first_year.add_field(name ='Calcolo II', value='II Semestre', inline = True)
first_year.add_field(name ='Inglese', value='II Semestre', inline = True)
second_year.set_footer(text = datetime.datetime.now().strftime('%d/%m/%Y %H:%M') + "\t\t\t\t\t\t\t\t\t\t\t\t\t" + "pag." + " " + str(page)+"/3")
second_year.set_author(name = ctx.message.author)
third_year.set_footer(text = datetime.datetime.now().strftime('%d/%m/%Y %H:%M') + "\t\t\t\t\t\t\t\t\t\t\t\t\t" + "pag." + " " + str(page)+"/3")
third_year.set_author(name = ctx.message.author)
while True:
if page == 1:
sent = await ctx.message.channel.send(client.get_channel("795387716967333889"), embed=first_year)
await sent.add_reaction(right_arrow)
page = 4
# Do not do nothing until user use a reaction
elif page == 2:
sent = await ctx.message.channel.send(client.get_channel("795387716967333889"), embed=second_year)
await sent.add_reaction(left_arrow)
await sent.add_reaction(right_arrow)
elif page == 3:
sent = await ctx.message.channel.send(client.get_channel("795387716967333889"), embed=third_year)
await sent.add_reaction(left_arrow)