Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
627 views
in Technique[技术] by (71.8m points)

python - Discord.py help command (react to edit message)

I'm trying to make a help command that if you react it changes the message (edits the message) to the next page (I have 4 help pages and a default page (showing what numbers = what page)).

I saw this post about this but it was an arrow reaction and I couldn't figure out how to change it to 0 1 2 3 4 reactions.

0 - help page
1 - fun commands
2 - Emoji commands
3 - admin commands
4 - misc commands

How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here I'm using a variable (i) to keep track of the page number. You'd initially send an embed (page 0) and grab the message object (msg).

def reac_check(r, u):
   return msg.id == r.message.id and u!=self.bot.user and r.emoji in ['1','2','3']
i = 0
while True:
     try:
        reaction, user = await self.bot.wait_for('reaction_add', timeout=20.0, check=reac_check)
        em = str(reaction.emoji)
     except TimeoutError:
         print("caught")
         break #we exit the loop
      
     if user!=self.bot.user:
        await msg.remove_reaction(emoji=em, member=user)

     if em == '1':
        #edit message with embed of page 1
     #other cases go here

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...