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透露您的机器人令牌。我敦促您尽快刷新您的代币