【问题标题】:i am trying to do reaction role in discord py我正在尝试在 discord py 中扮演反应角色
【发布时间】:2021-02-11 15:01:25
【问题描述】:

我尝试运行此代码(请参阅下面的代码)。

代码:

import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!")
@client.event
async def on_ready():
    Channel = client.get_channel('406473869424328736')
    Text= "REACT TO ME"
    Moji = await Client.send_message(Channel, Text)
    await client.add_reaction(Moji, emoji='question')
@client.event
async def on_reaction_add(reaction, user):
    Channel = client.get_channel('406473869424328736')
    if reaction.message.channel.id != Channel:
        return
    if reaction.emoji == "question":
      Role = discord.utils.get(user.server.roles, name="test")
      await client.add_roles(user, Role)
client.run("NzcxMDQxMzcwNjU5MjI1NjMw.X5mWPA.oiEvo4otmA3lThVzCBxQHunugO4")
Moji = await client.send_message(Channel, Text)

但是,我收到如下错误 错误:

AttributeError: 'Client' object has no attribute 'send_message'

【问题讨论】:

    标签: python discord bots


    【解决方案1】:

    client.send_message() 已被弃用。

    替换为: await ctx.message.channel.send('message') 或者您可以将其缩短为 await ctx.send('message')

    另外,请不要在互联网上泄露您的机器人令牌。我敦促您尽快刷新令牌。

    【讨论】:

      猜你喜欢
      • 2021-04-27
      • 2020-01-25
      • 1970-01-01
      • 1970-01-01
      • 2021-05-17
      • 2020-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多