我有一条带有wait_for的命令,如果该命令已执行,则机器人应将消息发送到特定频道。现在,机器人应该等待,直到添加了特定的反应。但是在某些消息中,如果添加了特定的反应,则机器人不会反应。而且我认为它超时,尽管我将其设置为None。 很有可能几个人同时使用Command。我不知道这是否有问题。
代码:
@bot.command(aliases=['Buy'])
async def buy(ctx, choice = None):
if ctx.guild.id == BlackTVServerID:
channel = bot.get_channel(705836078082424914)
channeluser = bot.get_channel(705146663135871106)
userauthor = ctx.message.author
vcrole1 = get(userauthor.guild.roles, id=703562188224331777)
guildemojisbtv = bot.get_guild(712671329123303504)
Evbucks = get(guildemojisbtv.emojis, id=713138458071269551)
Erotinfo = get(guildemojisbtv.emojis, id=712677573498372097)
Epositiv = get(guildemojisbtv.emojis, id=712679512873369610)
Echeck = get(guildemojisbtv.emojis, id=712726333058318417)
Eladen = get(guildemojisbtv.emojis, id=713168533416181879)
Eerror = get(guildemojisbtv.emojis, id=713187214586282054)
messagechannel = ctx.message.channel.id
if ctx.message.channel.id in [705146663135871106, 707209203755909190]:
if choice == '1':
if any(role.id == 703562188224331777 for role in ctx.message.author.roles):
with open(r'./buylimit.json', 'r')as f:
userslimitbuy = json.load(f)
if not f"{userauthor.id}" in userslimitbuy:
userslimitbuy[f"{userauthor.id}"] = f'{userauthor}'
with open(r'./buylimit.json', 'w') as f:
json.dump(userslimitbuy, f, indent=4)
embed = discord.Embed(color=farbegruen, description=
f'\n{Epositiv} **5.000{Evbucks} eingefordert!** `Geld wird innert 24 Stunden hinzugefügt`')
embed.set_author(name=f'{ctx.message.author}', icon_url=f'{ctx.message.author.avatar_url}')
await ctx.send(embed=embed)
try:
embedblock = discord.Embed(color=0xe02522,
description=f'{Erotinfo} Du kannst nur **einmal Casino-Geld pro Shop Öffnung** kaufen!'
'\nSomit ist der Command `!buy` nun für dich bis nächste Woche **gesperrt!**')
await userauthor.send(embed=embedblock)
except discord.Forbidden:
pass
embed = discord.Embed(color=0xe02522, title='**__Kauf von Casino Geld__**', description=
f'**User**: {userauthor.mention}'
f'\n_ _'
f"\n**Geld**: 5,000"
f"\n**Gekauft mit**: <@&703562188224331777>"
f"\n**Gekauft im**: <#{messagechannel}>"
f"\n"
f"\nReagiere mit {Echeck}, falls erledigt!!")
embed.set_footer(text=f'Gekauft am ')
embed.timestamp = datetime.datetime.utcnow()
mess1 = await channel.send(embed=embed)
await mess1.add_reaction(f'{Echeck}')
def check(reactionbuy, userbuy):
return str(
reactionbuy.emoji) == f'{Echeck}' and reactionbuy.message.channel.id == 705836078082424914 and not userbuy.bot and reactionbuy.message.id == mess1.id
reaction, user = await bot.wait_for('reaction_add', check=check, timeout=None)
checkreact = Echeck
await mess1.clear_reaction(checkreact)
print('registriert')
await mess1.edit(
embed=discord.Embed(color=farbegruen, title='__**Casino-Geld ausgezahlt**__', description=
f'**User**: {userauthor.mention}'
f'\n_ _'
f"\n**Geld**: 5,000"
f"\n**Gekauft mit**: <@&703562188224331777>"
f"\n**Gekauft im**: <#{messagechannel}>"
f"\n"
f"\n**CASINO-GELD AUSGEZAHLT** von {user.mention}"))
try:
embedgeld = discord.Embed(color=farbegelb,
description=f'{Eladen} `Dein angefordertes Casino-Geld ist in Bearbeitung...`'
f'\nBetrag: **5.000**{Evbucks}')
messembedgeld = await userauthor.send(embed=embedgeld)
await asyncio.sleep(10)
await messembedgeld.edit(embed=discord.Embed(color=farbegruen,
description=f'{Epositiv} `Dein angefordertes Casino-Geld wurde auf deine Bank überwiesen!`'
f'\nBetrag: **5.000**{Evbucks}'))
except discord.Forbidden:
pass
else:
embedschongekauft = discord.Embed(color=farberot, description=
f'{Eerror} {userauthor.mention} Du hast heute bereits gekauft!')
await ctx.send(embed=embedschongekauft)
自那段时间我在VPS上托管以来,我没有发现任何错误。