簡體   English   中英

discord.py 是怎么做到的呢?

[英]How do you make it so there is an introduction embed in discord.py?

例如:

假設這是每個新機器人用戶的介紹嵌入: 在此處輸入圖像描述

假設有 BEG、HELP、WORK 等命令以及該機器人支持的所有這些命令……但是如果您是新的機器人用戶並且您鍵入“(前綴)乞求”,您將不會乞求,相反,您將得到上面顯示的這個嵌入,因為你是新的。 然后你就可以正常使用機器人了......

你會怎么做?

您可以使用以下內容嗎:

@client.event
async def on_new_user():
    await ctx.send(embed=introduction_embed)

或者有不同的方法嗎? 我如何確保每個用戶都先看到這個介紹嵌入,並確保他們只看到一次? 我正在使用 python 開發一個 discord 機器人。非常感謝您的幫助! 非常感謝

是這樣的:

on_command在找到命令時運行,如果我用before_invoke裝飾它,我可以在發送嵌入后引發錯誤,防止命令第一次為每個用戶運行。 不過,如何存儲用戶取決於您。

CommandError被捕獲並傳遞給on_command_error事件。

registered_users = []

@bot.before_invoke
@bot.event
async def on_command(ctx):
    global registered_users
    if ctx.author not in registered_users:
        registered_users.append(ctx.author)
        embed = discord.Embed(
            color=discord.Colour.random(),
            title="WELCOME",
            description="welcome message",
        )
        await ctx.send(embed=embed)
        raise commands.CommandError("Error")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM