1. <i id='MoXoC'><tr id='MoXoC'><dt id='MoXoC'><q id='MoXoC'><span id='MoXoC'><b id='MoXoC'><form id='MoXoC'><ins id='MoXoC'></ins><ul id='MoXoC'></ul><sub id='MoXoC'></sub></form><legend id='MoXoC'></legend><bdo id='MoXoC'><pre id='MoXoC'><center id='MoXoC'></center></pre></bdo></b><th id='MoXoC'></th></span></q></dt></tr></i><div id='MoXoC'><tfoot id='MoXoC'></tfoot><dl id='MoXoC'><fieldset id='MoXoC'></fieldset></dl></div>
    2. <legend id='MoXoC'><style id='MoXoC'><dir id='MoXoC'><q id='MoXoC'></q></dir></style></legend>

      <small id='MoXoC'></small><noframes id='MoXoC'>

      • <bdo id='MoXoC'></bdo><ul id='MoXoC'></ul>

      <tfoot id='MoXoC'></tfoot>

    3. discord.py 中的提醒命令问题

      Reminder Command Issue in discord.py(discord.py 中的提醒命令问题)

        <small id='JIiUB'></small><noframes id='JIiUB'>

          <legend id='JIiUB'><style id='JIiUB'><dir id='JIiUB'><q id='JIiUB'></q></dir></style></legend>
              <bdo id='JIiUB'></bdo><ul id='JIiUB'></ul>
              <i id='JIiUB'><tr id='JIiUB'><dt id='JIiUB'><q id='JIiUB'><span id='JIiUB'><b id='JIiUB'><form id='JIiUB'><ins id='JIiUB'></ins><ul id='JIiUB'></ul><sub id='JIiUB'></sub></form><legend id='JIiUB'></legend><bdo id='JIiUB'><pre id='JIiUB'><center id='JIiUB'></center></pre></bdo></b><th id='JIiUB'></th></span></q></dt></tr></i><div id='JIiUB'><tfoot id='JIiUB'></tfoot><dl id='JIiUB'><fieldset id='JIiUB'></fieldset></dl></div>
                <tbody id='JIiUB'></tbody>

                <tfoot id='JIiUB'></tfoot>
              1. 本文介绍了discord.py 中的提醒命令问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试发出不和谐的机器人提醒命令,但是,我遇到了一个问题.

                I am trying to make a discord bot reminder command, however, I am running through an issue.

                当我执行命令时,它完美地执行了睡眠时间,但是,它没有显示我设置的提醒.

                When I do the command, it executes the sleep time perfectly, however, it doesn't show the reminder that I have set.

                示例:当我执行/reminder 5m Fix the server时,它应该发送好吧,我会在5分钟后提醒你Fix the server.,但是,它正在发送此信息:好的,我会在 5 分钟内提醒您有关 {}.而且当我不包含提醒参数时,它应该发送一条错误消息,但它什么也不做.

                Example: When I do /reminder 5m Fix the server, it should send Alright, I will remind you about Fix the server in 5 minutes., However, it is sending this instead: Alright, I will remind you about {} in 5 minutes. And also when I don't include the reminder argument it should send an error message, but it does nothing instead.

                这是我的代码:

                @bot.command(case_insensitive = True, aliases = ["remind", "remindme", "remind_me"])
                @commands.bot_has_permissions(attach_files = True, embed_links = True)
                async def reminder(ctx, *time, **reminder):
                    user = ctx.message.author 
                    embed = discord.Embed(title="Please specify a proper duration, send `reminder_help` for more information.", description="", color=0x55a7f7, timestamp=datetime.utcnow())
                    embed.set_footer(text="If you have any questions, suggestions or bug reports, please join our support Discord Server: link hidden", icon_url=f"{bot.user.avatar_url}")
                    embed2 = discord.Embed(title="Please specify what do you want me to remind you about.", description="", color=0x55a7f7, timestamp=datetime.utcnow())
                    embed2.set_footer(text="If you have any questions, suggestions or bug reports, please join our support Discord Server: link hidden", icon_url=f"{bot.user.avatar_url}")    
                    embed3 = discord.Embed(title="You have specified a too long duration!
                Maximum duration is 90 days.", color=0x55a7f7, timestamp=datetime.utcnow())
                    embed3.set_footer(text="If you have any questions, suggestions or bug reports, please join our support Discord Server: link hidden", icon_url=f"{bot.user.avatar_url}")        
                    embed4 = discord.Embed(title="You have specified a too short duration!
                Minimum duration is 5 minutes.", color=0x55a7f7, timestamp=datetime.utcnow())
                    embed4.set_footer(text="If you have any questions, suggestions or bug reports, please join our support Discord Server: link hidden", icon_url=f"{bot.user.avatar_url}")      
                    seconds = 0
                    if reminder is None:
                        await ctx.send(embed=embed2) # Error message
                        return
                    for i in time:
                        if i.lower().endswith("d"):
                            seconds += int(i[:-1]) * 60 * 60 * 24
                            counter = f"{seconds//60//60//24} days"
                        if i.lower().endswith("h"):
                            seconds += int(i[:-1]) * 60 * 60  
                            counter = f"{seconds//60//60} hours"
                        elif i.lower().endswith("m"):
                            seconds += int(i[:-1]) * 60
                            counter = f"{seconds//60} minutes"
                        elif i.lower().endswith("s"):
                            seconds += int(i[:-1])  
                            counter = f"{seconds} seconds"
                        if seconds == 0:
                            await ctx.send(embed=embed) # Error message
                            return
                        elif seconds < 300:
                            await ctx.send(embed=embed4) # Error message
                            return
                        elif seconds > 7776000:
                            await ctx.send(embed=embed3) # Error message
                            return
                        else:
                            await ctx.send(f"Alright, I will remind you about {reminder} in {counter}.")
                            await asyncio.sleep(seconds)
                            await ctx.send(f"Hi, you asked me to remind you about {reminder} {counter} ago.")
                

                任何帮助将不胜感激,在此先感谢.

                Any help would be appreciated, thanks in advance.

                推荐答案

                我通过改变一些s"解决了你的问题在你的代码中.所以这是新代码:

                I solved your question with changing a few thing"s" in your code. So here is the new code:

                @client.command(case_insensitive = True, aliases = ["remind", "remindme", "remind_me"])
                @commands.bot_has_permissions(attach_files = True, embed_links = True)
                async def reminder(ctx, time, *, reminder):
                    print(time)
                    print(reminder)
                    user = ctx.message.author
                    embed = discord.Embed(color=0x55a7f7, timestamp=datetime.utcnow())
                    embed.set_footer(text="If you have any questions, suggestions or bug reports, please join our support Discord Server: link hidden", icon_url=f"{client.user.avatar_url}")
                    seconds = 0
                    if reminder is None:
                        embed.add_field(name='Warning', value='Please specify what do you want me to remind you about.') # Error message
                    if time.lower().endswith("d"):
                        seconds += int(time[:-1]) * 60 * 60 * 24
                        counter = f"{seconds // 60 // 60 // 24} days"
                    if time.lower().endswith("h"):
                        seconds += int(time[:-1]) * 60 * 60
                        counter = f"{seconds // 60 // 60} hours"
                    elif time.lower().endswith("m"):
                        seconds += int(time[:-1]) * 60
                        counter = f"{seconds // 60} minutes"
                    elif time.lower().endswith("s"):
                        seconds += int(time[:-1])
                        counter = f"{seconds} seconds"
                    if seconds == 0:
                        embed.add_field(name='Warning',
                                        value='Please specify a proper duration, send `reminder_help` for more information.')
                    elif seconds < 300:
                        embed.add_field(name='Warning',
                                        value='You have specified a too short duration!
                Minimum duration is 5 minutes.')
                    elif seconds > 7776000:
                        embed.add_field(name='Warning', value='You have specified a too long duration!
                Maximum duration is 90 days.')
                    else:
                        await ctx.send(f"Alright, I will remind you about {reminder} in {counter}.")
                        await asyncio.sleep(seconds)
                        await ctx.send(f"Hi, you asked me to remind you about {reminder} {counter} ago.")
                        return
                    await ctx.send(embed=embed)
                

                首先,我不知道是什么导致了问题,但是你无缘无故地使用了 for 循环,这是不必要的.然后你不必创建 4 次嵌入,你可以使用 add_field.所以它现在有效.如果仍有问题,请发表评论.

                First of all, I don't know what causes the problem but you use a for loop for no reason, it's unnecessary. Then you don't have to create embeds for 4 times, you can just use add_field. So it works now. If you still have problem, just comment.

                这篇关于discord.py 中的提醒命令问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                【网站声明】本站部分内容来源于互联网,旨在帮助大家更快的解决问题,如果有图片或者内容侵犯了您的权益,请联系我们删除处理,感谢您的支持!

                相关文档推荐

                How to make a discord bot that gives roles in Python?(如何制作一个在 Python 中提供角色的不和谐机器人?)
                Discord bot isn#39;t responding to commands(Discord 机器人没有响应命令)
                Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“关于我吗?Discord 机器人的功能?(不和谐.py))
                message.channel.id Discord PY(message.channel.id Discord PY)
                How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 机器人?)
                discord.py - Automaticaly Change an Role Color(discord.py - 自动更改角色颜色)

                  • <small id='KTLR0'></small><noframes id='KTLR0'>

                          <bdo id='KTLR0'></bdo><ul id='KTLR0'></ul>

                          <tfoot id='KTLR0'></tfoot>
                          <legend id='KTLR0'><style id='KTLR0'><dir id='KTLR0'><q id='KTLR0'></q></dir></style></legend>
                            <tbody id='KTLR0'></tbody>
                        • <i id='KTLR0'><tr id='KTLR0'><dt id='KTLR0'><q id='KTLR0'><span id='KTLR0'><b id='KTLR0'><form id='KTLR0'><ins id='KTLR0'></ins><ul id='KTLR0'></ul><sub id='KTLR0'></sub></form><legend id='KTLR0'></legend><bdo id='KTLR0'><pre id='KTLR0'><center id='KTLR0'></center></pre></bdo></b><th id='KTLR0'></th></span></q></dt></tr></i><div id='KTLR0'><tfoot id='KTLR0'></tfoot><dl id='KTLR0'><fieldset id='KTLR0'></fieldset></dl></div>