【问题标题】:Sending welcome message in discord.py [@bot.event doesn't react?] [duplicate]在 discord.py 中发送欢迎消息 [@bot.event 没有反应?] [重复]
【发布时间】:2021-06-15 14:39:54
【问题描述】:

我在确保我的机器人在用户加入服务器时发送消息时遇到了一些问题,我的代码似乎没问题,但它既不发送也不打印任何东西

import discord
from discord.ext import commands


bot = commands.Bot(command_prefix=config.PREFIX, case_insensitive=True)


@bot.event
async def on_member_join(member):
    print("a member joined")
    await bot.get_channel(851883872186400812).send(f"<@!{member.id}> just joined the server! Welcome and enjoy your stay!")



bot.run(config.TOKEN)

【问题讨论】:

标签: discord discord.py


【解决方案1】:

您可能需要打开“成员”意图。转到http://discord.com/developers,选择您的机器人,然后在“机器人”部分打开它:

这样做之后。您还需要在代码中打开意图。真的很简单。

intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(command_prefix=config.PREFIX, case_insensitive=True, intents=intents)

【讨论】:

    猜你喜欢
    • 2021-08-17
    • 2021-06-14
    • 2021-03-28
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多