我的机器人启动时如何在特定频道发送消息
How do i send a message in a specific channel when my bot start
我想在我的机器人启动时在频道中发送消息这里是我的代码
@client.event
async def on_ready():
print("Bot is running")
activity = discord.Game(name="!test", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)
#issue starts here
client.getchannel(944607968211652631)
await client.channel.send("I am online")
我也试过其他方法
async def on_ready():
print("Bot is running")
activity = discord.Game(name="!test", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)
on = client.getchannel(944607968211652631)
await on.channel.send("I am online")
但这也没有用
不要使用不存在的 client.getchannel,而是使用 Client.get_channel
。它 returns 一个可以用来发送消息的通道。
示例:
channel = client.get_channel(id)
await channel.send("hi i've started")
我想在我的机器人启动时在频道中发送消息这里是我的代码
@client.event
async def on_ready():
print("Bot is running")
activity = discord.Game(name="!test", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)
#issue starts here
client.getchannel(944607968211652631)
await client.channel.send("I am online")
我也试过其他方法
async def on_ready():
print("Bot is running")
activity = discord.Game(name="!test", type=3)
await client.change_presence(status=discord.Status.idle, activity=activity)
on = client.getchannel(944607968211652631)
await on.channel.send("I am online")
但这也没有用
不要使用不存在的 client.getchannel,而是使用 Client.get_channel
。它 returns 一个可以用来发送消息的通道。
示例:
channel = client.get_channel(id)
await channel.send("hi i've started")