【发布时间】:2021-05-15 01:41:22
【问题描述】:
我遇到了机器人没有在新用户到来时向特定频道发送消息的问题,我尝试了很多方法。代码如下:
import discord
from discord.ext import commands
TOKEN = "Random token string"
PREFIX = "!"
client = commands.Bot(command_prefix = PREFIX, case_insensitive = True)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_member_join(member):
print("it should work")
await client.get_channel(Int channel ID).send(f"{member.name} has joined")
client.run ("Some random token")
我没有收到任何错误,但是 on_member_join 函数没有向指定频道发送消息的原因是什么?
【问题讨论】:
-
您是否通过开发者门户启用了成员意图并在您的代码中进行了定义?即使您可能只是向频道发送消息,会员加入活动也需要这样做
-
是的,我启用了机器人的所有设置,基本上给了它完整的管理模式,但显然它与下面的评论者给我的 sn-p 有关,它只是神奇地工作。跨度>
标签: python discord discord.py bots