【问题标题】:(Already resolved)The discord bot does not display the welcome message in discord, but it did not receive any errors [duplicate](已解决)discord bot不显示discord欢迎消息,但没有收到任何错误[重复]
【发布时间】:2022-01-04 17:57:39
【问题描述】:

我写了一个不和谐的机器人来显示欢迎和留言,但是当我启用它在有人进入公会时发送消息时,它不会显示欢迎信息。

    import discord
    from discord.ext import commands
    
    bot = commands.Bot(command_prefix = '[')
    
    @bot.event
    async def on_ready():
        print(" Bot is Online!")
    
    @bot.event
    async def on_member_join(member):
        channel = bot.get_channel(Token)
        
        await channel.send("{member}welcome to join!")
    
    @bot.event
    async def on_member_remove(member):
        channel = bot.get_channel(Token)
        await channel.send("{member} is leave the guild!")
    
    bot.run('Token')    

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    您应该使用频道的 ID,而不是机器人的 TOKEN。

    channel = bot.get_channel(channelid)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-16
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 2021-10-31
      相关资源
      最近更新 更多