我希望我的discord机器人能够根据用户的反应在服务器中返回特定的消息:?或?。
我对discord.py不是很熟悉,而且我读过的文档有点混乱,我按照youtube的教程进行了编辑。我可以在控制台中看到打印的反应,但是我得到了错误消息:
Instance of 'Bot' has no 'channel' member
下面是我的代码:
import os
import datetime
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_do
例如,机器人不会读取消息的任何其他反应,而只读取特定消息的反应。 将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
有没有办法从命令中捕捉反应。我已经做了一个命令,删除一个通道,但我想问用户,如果他们确定使用反应。我想阻止其他人对这条消息做出反应(只有上下文作者才能做出反应)。
到目前为止,我发现的只是使用on_reaction_add(),但这不能检测发送命令的用户。我只想更新命令,如果消息作者是对消息作出反应的人,其他人,忽略它。
Update:我发现wait_for()做了我想做的事情,但现在的问题是如何检查是否设置了错误的反应?(也就是说,如果我按下第二个反应,删除消息)
if is_admin:
msg = await ctx.send('Clear: Are yo
我正在寻找一个脚本来检查执行命令(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
我正在尝试让我的机器人响应接受规则的DM消息。
这是我到目前为止所知道的:
@bot.event
async def on_member_join(member):
role = discord.utils.get(member.servers.roles, name='Newcomers') #get role
await bot.add_roles(member, role) #give the role to the user
await bot.member.send("Welcome to the Moderator Bot Server! I w
我正在设计一个不和谐的机器人,它基本上可以在你的服务器上使用,用于不同的有用任务,比如获取服务器统计数据,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
我正在使用discord.py异步库上的wait_for_response,但是,我的代码 await self.Nao.say("What is your name? (Cannot exceed over 100 characters)")
usrname = await self.Nao.wait_for_message(author=ctx.message.author)
await self.Nao.say("What is your Age? (Cannot exceed over 100 characters)")
usrage = await
我一直在考虑在我的不和谐机器人中制作一个21点游戏,但我遇到了一个障碍。
显然,我有一个用命令.blackjack调用的游戏,它在生成随机值和发送消息方面工作得很好。但是,我不知道怎么做,所以玩家能够在发牌的消息发出后说点击或站立,例如。
@client.command()
async def blackjack(ctx):
# (insert all random number gens, etc. here)
await ctx.send(f"{dface1}{dsuit1} ({dvalue1}), {dface2}{dsuit2} ({dvalue2}
我有一个机器人,将打开一个关闭投票,其中使用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
我试图让我的不和谐机器人有一个更高或更低的游戏,玩家点击向上或向下箭头来猜测,但我正在努力找出如何检查反应是第一个反应还是第二个反应。
这是我到目前为止的代码(它在一个齿轮上):
@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
我试图从用户那里得到一条消息,然后将其发送到特定的文本频道。信息应嵌入其中。但是我不喜欢当您有一堆字段时,我希望discord.Embed()中的描述保存文本内容。但是它给了我一个错误TypeError: Object of type Message is not JSON serializable
这是我的密码:
class Changelog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_r
因此,我做了一个岩石剪刀布命令,它几乎完美地工作。然而,有一个错误,我非常需要修复它。但不幸的是,我无法从任何地方得到任何帮助。下面是代码的工作原理。当你输入'>rps‘时,它会发送一个embed,并要求对任何表情符号(石头、布或剪刀)做出反应。机器人已经选择了它的项目(在随机模块的帮助下)。当我对任何表情符号(石头、布和剪刀表情)做出反应时,它表明我赢了,输了,或者打成了平局。在这里之前一切都很好。但是,当您手动对同一消息做出反应时(使用3种表情符号中的任何一种),消息将再次更改为获胜、失败或抽签嵌入。我希望这种情况在成员完成一场比赛后停止发生。这是我的代码。 my code
这是我的代码:
#Ticket
@client.command(pass_context=True)
async def setuppartnership(ctx):
guild = ctx.guild
embed = discord.Embed(
title = 'Richiesta Partnership',
description = 'Vuoi fare partnership? Usa la reazione qui sotto per creare un nuovo ticket.',
我希望问一个问题,将两个反应添加到消息中,如果他们用某个反应来回应,而如果他们用另一个反应来回应,那么我就会做其他事情,但是等待im使用不会返回任何东西,就像它不接受任何输入一样。
我尝试了一个检查,检查它是否是私有通道,以及作者是否是用户,但这最初是为了消息等待,所以我停止使用它,并使用堆栈溢出中的某个人的反应检查,但这也不起作用
if seq is None:
return ()
if isinstance(seq, Sequence) and not isinstance(seq, str):
return
因此,关于bot.wait_for()协程的现代文档并不是非常详细,我在让它与反应一起工作时遇到了麻烦。希望能得到反馈。
带有Discord.py的Python3
## Test Role Add
@kelutralBot.command(name='testreaction')
async def testReaction(ctx):
member = ctx.message.author
message = await ctx.send("This is a test message.")
emojis = ['\u2642&
我试图为bot创建一个命令,当消息中提到的每个人都对bot的响应做出反应时,它就会提到原始消息作者
这就是我试过的
if msg.content.startswith('/iniciar'):
async with msg.channel.typing():
mentions = ""
for mention in msg.mentions:
mentions = mentions + " " + men
假设一个类似下面的命令: @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
大家好!
我目前正在尝试与我的Arduino (通过串行连接我的Raspberry Pi )进行通信,并使用我的Raspberry Pi上的Python脚本中的信息。
尽管如此,我的Python脚本必须等待Arduino报告它的数据才能让脚本继续运行,尽管我并不完全确定如何做到这一点。
到目前为止,这就是我所得到的:
#!/usr/bin/env python
import time
import serial
import RPi.GPIO as GPIO
ser = serial.Serial('/dev/ttyACM0', 9600)
GPIO.setmode(GPI
我已经编写了一个不和谐机器人,它为对消息做出反应的用户添加了一个角色。机器人还会回复消息“Hallo bot”。但当我关闭机器人并重新打开它时,在我对另一条消息做出反应之前,该机器人不会回复该消息。 async def on_raw_reaction_add(self, payload):
mitglied = discord.utils.get(payload.member.guild.roles, name="Mitglied")
if str(payload.emoji) == "?":
a