【问题标题】:How can I make a welcome message with a discord bot with python?如何使用带有 python 的不和谐机器人发出欢迎消息?
【发布时间】:2021-04-08 00:55:26
【问题描述】:

我是使用 python 制作 discord 机器人的新手,我想制作一个活动,当有人加入服务器时显示欢迎消息。

我用这段代码试过

import discord
import random
from discord.ext import commands

alfred = commands.Bot(command_prefix = '!', description = "Hey!, I'm Alfred, How can I assist you?")

#EVENT

@alfred.event
async def on_ready():

    print("I'm Alfred and I'm Online!")

@alfred.event
async def on_member_join(member):
    embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined")
    await message.channel.send(embed=embed)

但它不起作用,甚至不和谐的文档都说该事件是“on_member_join”。

我真的希望你能帮助我:)

【问题讨论】:

    标签: python discord bots discord.py


    【解决方案1】:

    试试这个,只需将 790274325533378682 替换为您的频道 ID

    @alfred.event
    async def on_member_join(member):
        channel = alfred.get_channel(790274325533378682)
        embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined")
        await channel.send(embed=embed)
    

    【讨论】:

      猜你喜欢
      • 2021-04-27
      • 2021-06-24
      • 1970-01-01
      • 2020-10-03
      • 2020-05-18
      • 2022-01-23
      • 2021-02-22
      • 2021-03-31
      • 2021-06-01
      相关资源
      最近更新 更多