【发布时间】:2022-01-15 09:14:38
【问题描述】:
我试图简单地创建一个函数,在机器人运行时向特定频道发送不和谐消息。我想稍后在一个单独的 python 脚本中调用这个函数。 下面的代码似乎运行良好,并且机器人出现在线 - 但它无法发送消息:
import discord
client = discord.Client()
client.run("ABCDeFGHIjklMNOP.QrSTuV-HIjklMNOP") # the token
@client.event
async def on_ready():
logs_channel = client.get_channel(12345689123456789) # the channel ID
await logs_channel.send("Bot is up and running")
on_ready()
我确定我错过了一些基本的东西,但我无法弄清楚它是什么。我在 Node.js 中尝试了一个类似的函数,它工作正常,但是我更希望机器人在 python 中工作。 Discord.py 是最新的,python 是 v3.10。 任何帮助将不胜感激。
【问题讨论】:
标签: python discord discord.py