微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在服务器上本地工作失败,无法同时为两个用户运行

如何解决在服务器上本地工作失败,无法同时为两个用户运行

从本质上讲,代码功能齐全并且可以正常工作...除非它不是,有时它会检测到鬼消息并跳过用户消息输入。我不知道如何解决这个问题,我在不同的地方尝试了许多不同的 time.sleep()。

一个问题是,当两个人打开一个应用程序时,它不喜欢它。代码可能有点乱,对此我深表歉意。

一个问题是它从另一个频道接收消息,因为它正在等待用户回复

它在本地运行很顺利,所以我猜托管版本有更多的延迟。

我不确定问题是什么,所以如果有人有更干净的解决方案/(修复它的指南)那就太棒了!

@modapp.command(name="open")
async def open(ctx):
        await ctx.message.delete()
        channelname = "modapp-" + ctx.author.name
        guild = ctx.guild
        overwrite = discord.PermissionOverwrite()
        overwrite.send_messages = True
        overwrite.read_messages = True
        overwrite.view_channel = True
        userchannel = await guild.create_text_channel(channelname,category=bot.get_channel(823621817008390154))
        await userchannel.set_permissions(ctx.author,overwrite=overwrite)
        await userchannel.send("Welcome " + ctx.author.mention + ",please fill out all the answers for your moderator application.")
        questions = ["How old are you? If you do not feel comfortable answering this then feel free to type 'N/A' instead","How many hours on average would you be on the server per week?","Have you had any prevIoUs experience being a Moderator?","What is your English speaking level?","Do you think you would be comfortable answering technical questions relating to the bot? (Admins will always be on hand to provide support and training beforehand and thereafter)","What attributes of your personality do you think would be helpful for being a Moderator?","What would you consider a kickable/bannable offence?","Why should we choose you to be a moderator?"]
        answers = []
        confirm = False
        send = False
        while send == False:
            for i in questions:
                while confirm == False:
                    time.sleep(2)
                    await userchannel.send(i)
                    
                    ans = await bot.wait_for('message',check=None,timeout=None)

                    msg = await userchannel.send("Is this your final answer?")
                    await msg.add_reaction('✔️')
                    await msg.add_reaction('❌')

                    def check(reaction,user):
                        return str(reaction.emoji) == '✔️' or str(reaction.emoji) == '❌' and user != bot.user
                    
                    reaction,user = await bot.wait_for('reaction_add',timeout=None,check=check)
                    
                    if reaction.emoji == '✔️':
                        confirm = True
                        answers.append(ans.content)
                    else:
                        confirm = False
                confirm = False

            msg = await userchannel.send("Do you want to send your mod application? Note: Saying no means you will have to answer all the questions again!!")
            await msg.add_reaction('✔️')
            await msg.add_reaction('❌')

            def check(reaction,user):
                return str(reaction.emoji) == '✔️' or str(reaction.emoji) == '❌' and user != bot.user

            reaction,check=check)
                    
            if reaction.emoji == '✔️':
                send = True
                await userchannel.send("Your moderator application has been sent!")
            else:
                send = False
                
        modAppEmbed=discord.Embed(title="<:rocket:817428508435152926> New Mod Application! ",color=0xffc900)
        modAppEmbed.set_author(name="ModAppBot",url="https://www.quickpump.dev",icon_url="https://cdn.probot.io/dln4pop2iK.png")
        modAppEmbed.add_field(name="Username",value=ctx.author.name)
        
        counter = 0
        for i in questions:
            modAppEmbed.add_field(name=i,value=answers[counter],inline=False)
            counter += 1
        modchatchannel = bot.get_channel(818453573250842625)
        modapp = await modchatchannel.send(embed=modAppEmbed)
        await modapp.add_reaction('✔️')
        await modapp.add_reaction('❌')
        await userchannel.delete()
            ```

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。