Discord机器人命令不适用于反应角色(Discord PY) [英] Discord bot commands not working on reaction roles (Discord PY)
问题描述
当我执行脚本时,会显示此错误。不确定是什么,但是请帮我!
显示的错误这是我运行我的机器人时显示的错误。我不知道,但是我试图设置反应角色,并且弹出了
Error shown This was the error shown when i ran my bot. I have no clue but i was trying to set up reaction roles and this popped up
@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'
脚本的一部分出现错误:这是脚本的一部分,错误使我告诉我它在那里!
Part of script with error This is the part of the script the error directing me to telling me it was there!
@bot.event()
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 710694229554233344:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
if payload.emoji.name == 'thumbsup':
role = discord.utils.get(guild.roles, name="cpp")
elif payload.emoji.name == 'wink':
role = discord.utils.get(guild.roles, name="csharp")
else:
role = discord.utils.get(guild.roles, name=payload.emoji.name)
if role is not None:
print(role.name)
@bot.event
async def on_raw_reaction_remove(payload):
pass
完整脚本如果需要查看整个程序中的bug,这是完整的代码!
Full script if needed this is the full code if needed to look at the whole thing for bugs!
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='~')
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online)
print('The bot {0.user} has successfully been turned online!'.format(bot))
@bot.command()
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=2):
await ctx.channel.purge(limit=amount)
@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)
await ctx.channel.send(f"{Member} has been kicked")
@bot.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.channel.send(f"{user.name} has been banned")
await ctx.member.send(f"{ctx.guild.name} is the server you have been banned from!")
@bot.command()
async def latency(ctx):
await ctx.send(f"Latency of bot is {bot.latency}|ms")
@bot.command()
async def unban(ctx, *, member):
banned_users = await ctx.guilds.bans()
member_name, member_discriminator = member.split('#')
for banned_entry in banned_users:
user = banned_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.send(f"Unbanned {user.name}#{user.discriminator}!")
return
@bot.command()
async def test(ctx, *, member):
await ctx.send(f"Unbanned {user.name}.")
@bot.event()
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 710694229554233344:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
if payload.emoji.name == 'thumbsup':
role = discord.utils.get(guild.roles, name="cpp")
elif payload.emoji.name == 'wink':
role = discord.utils.get(guild.roles, name="csharp")
else:
role = discord.utils.get(guild.roles, name=payload.emoji.name)
if role is not None:
print(role.name)
@bot.event
async def on_raw_reaction_remove(payload):
pass
bot.run('<Token>')
推荐答案
您需要在事件发生后删除括号。 @ bot.event
,就像您的删除反应事件一样。请注意,您仍然在命令 @ bot.command()
You need to remove the parenthesis after event. It's @bot.event
, just like your remove reaction event. Please note that you still use them on the commands, @bot.command()
这篇关于Discord机器人命令不适用于反应角色(Discord PY)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!