簡體   English   中英

如何制作自定義 discord.py 機器人嵌入?

[英]How to make a custom discord.py bot embed?

我一直在嘗試讓機器人發送嵌入,但它不起作用,代碼執行沒有錯誤,但嵌入沒有在頻道中發送

@client.command()
async def embed(ctx):
    embed=discord.Embed(
        title='Title',
        description='Description',
        color=0x774dea
    )

    await ctx.send(embed=embed)

看來您可能沒有為您的機器人啟用正確的 Discord 意圖。

這里可能會解決您的問題:

  1. Go 到Discord 開發人員門戶並啟用 Bot -> Privileged Gateway Intents 下列出的選項

    注意:如果您的機器人達到 100 台以上的服務器,您將需要申請其中的每台

    圖片:這里

  2. 用類似這樣的東西替換你當前的commands.Bot實例化(關注_intentsintents=_intents部分):

     from discord import Intents from discord.ext import commands _intents = Intents.default() # Enable or disable the intents that are required for your project _intents.message_content = True bot = commands.Bot(command_prefix='*', intents=_intents) # code here bot.run(your_token_here)

    如果您對 Intent 的自定義以及您可以使用它們做什么感到好奇,請在此處閱讀更多信息。

暫無
暫無

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

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