gpt4 book ai didi

python - discord.py Cog//如何向特定 channel 发送消息

转载 作者:行者123 更新时间:2023-12-04 08:06:06 24 4
gpt4 key购买 nike

@commands.Cog.listener()
async def on_message(self, message):
channel = self.client.get_channel(797863482380124170)
if message.channel.id in talk_channel:
stats = levelling.find_one({"id": message.author.id})
if not message.author.bot:
if stats is None:
newuser = {"id": message.author.id, "xp": 100}
levelling.insert_one(newuser)
else:
xp = stats["xp"] + 100
levelling.update_one({"id": message.author.id}, {"$set": {"xp": xp}})
lvl = 0
while True:
if xp < ((50 ** (lvl ** 2)) + (50 * lvl)):
break
lvl += 1
# lvl += 1
xp -= ((50 * ((lvl - 1) ** 2)) + (50 * (lvl - 1)))

if xp == 0:
await message.channel.send(f"{message.author.mention} Lvl Up!")
所以这是我的代码,但 等待 message.channel.send 不起作用请帮助我
我尝试了很多方法但它不起作用

最佳答案

await channel.send()应该没事。您可以在这里阅读更多信息:discordpy.readthedocs.io

关于python - discord.py Cog//如何向特定 channel 发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66218905/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com