【问题标题】:Welcome message not being sent in discord.py未在 discord.py 中发送欢迎消息
【发布时间】:2021-08-17 22:39:55
【问题描述】:

所以我最近创建了一个新服务器并为它制作了一个自定义机器人,但欢迎消息似乎并没有真正起作用......它也应该为加入的成员赋予特定角色,但我删除了它代码和当前代码仍然不起作用。

遗憾的是,命令提示符没有给出任何错误。我现在不知道该怎么办。

这里是代码-

    @commands.Cog.listener()
    async def on_member_join(self, member):
        #GETTING THE GUILD, CHANNEL AND ROLE
        channel = self.client.get_channel(828481599057166356)
        name = member.name

        #CREATING THE WELCOME EMBED
        welcomeem = discord.Embed(title = f"Hey there {member.name}!", description = f"Welcome to {chanenl.guild.name}! Have a fun time here in TigerNinja's server!")
        welcomeem.add_field(name="1. Rules", value = f"{name}, before you start having fun here, make sure to check <#752474442650878002> and read all rules as they will come in handy in the server!", inline=False)
        welcomeem.add_field(name="2. Self-roles", value = f"{name}, be sure to check out <#776293478594379797> and get all roles you want!", inline=False)
        welcomeem.add_field(name="2. Help", value = f"{name}, need help with this bot then type `t.help`. If you need help relating to something else, contact the mods via dms, but don't ping them!!", inline=False)

        #SENDING THE PING, EMBDE AND ADDING ROLE
        await channel.send(f"Welcome, {member.mention}!")
        await channel.send(embed=welcomeem)

(顺便说一句,我正在使用齿轮)

【问题讨论】:

  • 你有会员意向吗?
  • 是的,我确实启用了所有意图。

标签: python python-3.x discord discord.py


【解决方案1】:

您是否将此命令设置为机器人事件?在添加此类命令之前,您应该添加 @bot.event(或您在代码中为 discord.Client 指定的任何名称 + .event,共享更多代码可能很有用,但请注意不要包含您的令牌或任何私人信息)。

有关更多信息,请查看此帖子,我相信这是您正在寻找的答案: Discord.py on_member_join not working, no error message

【讨论】:

  • 是的,我做到了...让我编辑问题中的代码使其再次正确
【解决方案2】:

按照 dicord.py docs:

channel = guild.get_channel(828481599057166356)

应该是:

channel = client.get_channel(828481599057166356)

编辑: 我发现了别的东西:

welcomeem = discord.Embed(title = f"Hey there {member.name}!", description = f"Welcome to {chanenl.guild.name}! Have a fun time here in TigerNinja's server!")

您在 {chanenl.guild.name} 中拼错了“频道”

【讨论】:

  • 我试过实现这个,但是不行,没有机会。它也没有显示错误。另外,我有所有的意图。
  • 感谢您发现这个错误,但它仍然不起作用!也没有错误!我不知道为什么!我在那里重新编辑了代码。请再次检查
猜你喜欢
  • 2021-06-14
  • 2021-06-10
  • 2021-10-07
  • 1970-01-01
  • 1970-01-01
  • 2020-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多