我有一个机器人,将打开一个关闭投票,其中使用wait_for(reaction_add)功能。问题是,当我检查作者是否做出了反应时,我得到了一个TypeError。下面是命令: @bot.command()
async def closepoll(ctx):
if not ctx.author.guild_permissions.mute_members:
await ctx.send("You cannot use this")
else:
await ctx.send("React to the poll I mus
假设一个类似下面的命令: @bot.command()
async def test(ctx):
def check(r, u):
return u == ctx.message.author and r.message.channel == ctx.message.channel and str(r.emoji) == '✅'
await ctx.send("React to this with ✅")
try:
reaction, user = await bot.wait_for('rea
我希望问一个问题,将两个反应添加到消息中,如果他们用某个反应来回应,而如果他们用另一个反应来回应,那么我就会做其他事情,但是等待im使用不会返回任何东西,就像它不接受任何输入一样。
我尝试了一个检查,检查它是否是私有通道,以及作者是否是用户,但这最初是为了消息等待,所以我停止使用它,并使用堆栈溢出中的某个人的反应检查,但这也不起作用
if seq is None:
return ()
if isinstance(seq, Sequence) and not isinstance(seq, str):
return
例如,机器人不会读取消息的任何其他反应,而只读取特定消息的反应。 将reaction.message == msgg添加到这段代码中会有帮助吗?(我甚至不知道这个函数是否存在,我也测试了它,但对我来说不起作用) reaction, user = await client.wait_for("reaction_add")
if user == members.user and str(reaction.emoji) == "✔️":
await members.user.send("your answer is ✔️")
else:
re
因此,我编写了一段代码,用于在某人做出反应时向他们发送消息,但一旦我使用命令!war,它就会给出这个错误,(我的代码在错误下面)
**
Ignoring exception in command war:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await c
我刚开始用python做一个不和谐的机器人,我找不到我到底应该在这里写什么(参见代码),如果有人能给我看一个表格,所有的可能性,谢谢。(我主要在寻找一个等待select选项的选项)。例如: #What I know:
res = await bot.wait_for("button_click")
res = await bot.wait_for("message")
#What I want to do:
res = await bot.wait_for("when a option is select") 对了,我只知道"messa
我正在寻找一个脚本来检查执行命令(ctx.message.author)的用户是否使用了一个复选标记来响应消息,应该如下所示:
@client.command()
async def test(ctx):
message = await ctx.send("Test")
for emoji in ('✅'):
await message.add_reaction(emoji)
# Here it should detect if the ctx.message.author has reacted
我试图让我的不和谐机器人有一个更高或更低的游戏,玩家点击向上或向下箭头来猜测,但我正在努力找出如何检查反应是第一个反应还是第二个反应。
这是我到目前为止的代码(它在一个齿轮上):
@commands.command()
async def highlow(self, ctx, limit:int = 100, *args):
num = random.randint(0, limit)
msg = await ctx.reply("The number is {num} \nWHould you like to go (h)igher or (l)ower
当某人用表情符号对消息做出反应时,它会重复这个函数--试图在批处理文件中找到类似于goto的功能。
我输入了$randomcar
机器人发送:Your chosen car is the bmw!与反应。当我按下它时,它再次重复这个功能:
机器人将Your chosen car is the audi!发送给我可以再次按下的反应来重复这个功能。
@bot.command()
async def randomcar(ctx):
while True:
msg = await ctx.send("Your chosen car is the {}!".format(rand
我有一个机器人写在python中,我想在机器人中加入一个数字游戏。游戏代码如下。(nl是一个变量,表示为os.linesep) secret_number = random.randint(0, 100)
guess_count = 0
guess_limit = 5
print(f'Welcome to the number guessing game! The range is 0 - 100 and you have 5 attempts to guess the correct number.')
while guess_cou
我还在学习库,所以我为任何新手的错误道歉。
下面的代码是执行3个操作的函数的一部分:
连接到sqlite3数据库
询问要创建什么猫名并将其插入到sqlite3数据库中
询问用户是否愿意将卡片添加到他们的小猫名中。
#To create a new kit
@client.command(name="createkit")
async def createkit(message):
author = message.author
await author.send("What name would you like to give t
我正在设计一个不和谐的机器人,它基本上可以在你的服务器上使用,用于不同的有用任务,比如获取服务器统计数据,DMing用户,以及(这个问题的主题)进行投票。我的代码很长,所以我只会包括导入,重要的变量,我遇到问题的实际代码,以及我运行机器人的结尾:
from profanity import profanity
import os, random, discord, asyncio, praw
from discord.utils import get
from discord.ext import commands
from dotenv import load_dotenv
from di
我在做一个命令,如果你用同意的反应来回应机器人,它就会发送一个核弹。这很好,但我不能让机器人回答不同,如果你选择其他选项或超时。我现在的代码如下。谢谢你的帮忙
async def nuke(ctx):
yas = '✔️'
nay = '❌'
message = await ctx.send("Are you sure that you want to use your nukes?")
await message.add_reaction(yas)
await message
因此,我做了一个岩石剪刀布命令,它几乎完美地工作。然而,有一个错误,我非常需要修复它。但不幸的是,我无法从任何地方得到任何帮助。下面是代码的工作原理。当你输入'>rps‘时,它会发送一个embed,并要求对任何表情符号(石头、布或剪刀)做出反应。机器人已经选择了它的项目(在随机模块的帮助下)。当我对任何表情符号(石头、布和剪刀表情)做出反应时,它表明我赢了,输了,或者打成了平局。在这里之前一切都很好。但是,当您手动对同一消息做出反应时(使用3种表情符号中的任何一种),消息将再次更改为获胜、失败或抽签嵌入。我希望这种情况在成员完成一场比赛后停止发生。这是我的代码。 my code
我目前正在尝试创建一个不和谐的机器人,将人们随机分成两个团队。现在,我能够发送消息和反应,然后返回一个用户列表,对机器人的信息作出反应。但我面临以下问题:
列表包括机器人;列表只包括机器人和第一个对消息做出反应的人(我想随机选择10个玩家,不包括机器人),我需要把这个列表分成两个团队
if str(reaction.emoji) == '✅': ## right now this is just selecting the game
def check(reaction, user): ## this check is here but I was unable to
这是我的帮助命令:
@client.command(pass_context=True, aliases=['cmd', 'commands'])
async def help(ctx):
embed = discord.Embed(colour=discord.Colour.blurple())
embed=discord.Embed(title="", description="This is a list of everything Otay! can do! If you need additional hel