Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我试图在《不和谐》中扮演反应角色_Python_Discord_Bots - Fatal编程技术网

Python 我试图在《不和谐》中扮演反应角色

Python 我试图在《不和谐》中扮演反应角色,python,discord,bots,Python,Discord,Bots,我试图运行此代码(请参阅下面的代码) 代码: 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

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

代码:

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'
然而,我收到了如下错误 错误:

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'
client.send\u message()
已被弃用

将其替换为:
等待ctx.message.channel.send('message')
或者你可以把它缩短到
wait ctx.send('message')

此外,请不要向internet透露您的机器人令牌。我敦促您尽快刷新您的代币