久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='QWQte'></tfoot>
    <bdo id='QWQte'></bdo><ul id='QWQte'></ul>
    <legend id='QWQte'><style id='QWQte'><dir id='QWQte'><q id='QWQte'></q></dir></style></legend>

    <i id='QWQte'><tr id='QWQte'><dt id='QWQte'><q id='QWQte'><span id='QWQte'><b id='QWQte'><form id='QWQte'><ins id='QWQte'></ins><ul id='QWQte'></ul><sub id='QWQte'></sub></form><legend id='QWQte'></legend><bdo id='QWQte'><pre id='QWQte'><center id='QWQte'></center></pre></bdo></b><th id='QWQte'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QWQte'><tfoot id='QWQte'></tfoot><dl id='QWQte'><fieldset id='QWQte'></fieldset></dl></div>

    <small id='QWQte'></small><noframes id='QWQte'>

    1. 將按鈕組件添加到消息(discord.py)

      Add button components to a message (discord.py)(將按鈕組件添加到消息(discord.py))
      • <legend id='4Fvhk'><style id='4Fvhk'><dir id='4Fvhk'><q id='4Fvhk'></q></dir></style></legend>

      • <i id='4Fvhk'><tr id='4Fvhk'><dt id='4Fvhk'><q id='4Fvhk'><span id='4Fvhk'><b id='4Fvhk'><form id='4Fvhk'><ins id='4Fvhk'></ins><ul id='4Fvhk'></ul><sub id='4Fvhk'></sub></form><legend id='4Fvhk'></legend><bdo id='4Fvhk'><pre id='4Fvhk'><center id='4Fvhk'></center></pre></bdo></b><th id='4Fvhk'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4Fvhk'><tfoot id='4Fvhk'></tfoot><dl id='4Fvhk'><fieldset id='4Fvhk'></fieldset></dl></div>

            <tbody id='4Fvhk'></tbody>

            • <bdo id='4Fvhk'></bdo><ul id='4Fvhk'></ul>
              1. <small id='4Fvhk'></small><noframes id='4Fvhk'>

                <tfoot id='4Fvhk'></tfoot>
                本文介紹了將按鈕組件添加到消息(discord.py)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                看到 this(消息組件)在 discord 的 API 參考中是否有任何方法可以使用 python 實現它?

                I was wondering after seeing this (message components) on discord's API reference if there was any way to implement it using python ?

                我嘗試創建一個 json 數組并將其傳遞到我的消息中,但無法使其工作.

                I tried making a json array and passing it in my message but couldn't make it work.

                我也嘗試查找 python 的參考,但找不到任何東西.

                I also tried looking on the reference for python but couldn't find anything.

                這是我的代碼

                components= [
                  {
                    "type": 2,
                    "label": "Clear les kick",
                    "style": 4,
                    "custom_id": "clear_kick_button"
                  }
                ]
                @slash.slash(name="kicked", description="Voir qui a été kick et combien de fois.", guild_ids=guild_id)
                async def kicked(ctx):
                  await ctx.send("test", components= components)
                

                如果你有任何信息謝謝你如果你分享它.

                If you have any informations thank you if you share it.

                推薦答案

                新答案


                Discord.py 2.0 允許使用按鈕和下拉菜單,盡管它不支持斜杠命令.請改用 Discord.py 2.0,但如果您需要斜線命令,請查看 discord_slash.

                升級到 Discord.py 2.0:

                To upgrade to Discord.py 2.0:

                窗戶:

                pip install -U git+https://github.com/Rapptz/discord.py
                

                MacOS 和 Linux:

                MacOS and Linux:

                pip3 install -U git+https://github.com/Rapptz/discord.py
                

                舊答案:

                (此答案已過時.)


                到目前為止,您可以獲得一個名為 discord_components 的庫來使用按鈕.

                要安裝這個庫,請使用 pip install --upgrade discord-components (有時命令是 pip3 install --upgrade discord-components).

                Old Answer:

                (This Answer is OUTDATED.)


                As of right now, you can get a library called discord_components to use buttons.

                To install this library, use pip install --upgrade discord-components (Sometimes the command would be pip3 install --upgrade discord-components).

                要導入 Discord 組件按鈕,請使用

                To import Discord Component Buttons, use

                from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
                

                然后只需將這段代碼添加到機器人的 on_ready() 中:

                Then just add this code in the bot's on_ready():

                DiscordComponents(bot, change_discord_methods=True)
                

                (確保將 bot 替換為您的機器人名稱,與 @something.command() 使用的名稱相同)

                (Make sure to replace bot with the name of your bot, the same one you use for @something.command())

                要為消息添加按鈕,請執行以下操作:

                To add a button to a message, do this:

                await ctx.send(type=InteractionType.ChannelMessageWithSource, content="Message Here", components=[Button(style=ButtonStyle.URL, label="Example Invite Button", url="https://google.com"), Button(style=ButtonStyle.blue, label="Default Button", custom_id="button")])
                

                (需要留言)

                要在單擊按鈕時執行某些操作,您可以執行以下操作:

                To do something when the button is clicked, you can do something like this:

                @bot.event
                async def on_button_click(interaction):
                    if interaction.component.label.startswith("Default Button"):
                        await interaction.respond(type=InteractionType.ChannelMessageWithSource, content='Button Clicked')
                

                這種方法甚至可以在重新啟動后繼續存在!

                This method even survives reboots!

                如果您需要,我為您整理了一個示例:

                Here's an example I put together for you if you need it:

                import discord
                from discord.ext import commands
                from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
                
                bot = commands.Bot(command_prefix=prefix, description="Desc", help_command=None)
                
                @bot.event
                async def on_ready():
                    DiscordComponents(bot, change_discord_methods=True)
                    await bot.change_presence(activity=discord.Game(name=f"{prefix}help"))
                    print("Bot has successfully logged in as: {}".format(bot.user))
                    print("Bot ID: {}
                ".format(bot.user.id))
                
                @bot.command()
                async def button(ctx):
                    await ctx.send(type=InteractionType.ChannelMessageWithSource, content="Message Here", components=[Button(style=ButtonStyle.URL, label="Example Invite Button", url="https://google.com"), Button(style=ButtonStyle.blue, label="Default Button", custom_id="button")])
                
                bot.run("token")
                

                希望對您有所幫助!

                提示:如果您希望按鈕在一行中,請使用 [[]] 而不是僅使用 [] 例如:[[btn1, btn2],[btn3, btn4]] 將導致:

                Tip: If you want the buttons to be in one row, use [[]] instead of just [] for Example: [[btn1, btn2],[btn3, btn4]] will result in:

                [btn 1][btn 2]
                [btn 3][btn 4]
                

                額外提示:您也可以將變量設置為按鈕然后發送變量

                Extra Tip: You can also set a variable as a button then send the variable

                這篇關于將按鈕組件添加到消息(discord.py)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                How to refresh sys.path?(如何刷新 sys.path?)
                Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
              2. <legend id='sVAG6'><style id='sVAG6'><dir id='sVAG6'><q id='sVAG6'></q></dir></style></legend>
              3. <tfoot id='sVAG6'></tfoot>

                  <tbody id='sVAG6'></tbody>
                  <bdo id='sVAG6'></bdo><ul id='sVAG6'></ul>

                        <small id='sVAG6'></small><noframes id='sVAG6'>

                          <i id='sVAG6'><tr id='sVAG6'><dt id='sVAG6'><q id='sVAG6'><span id='sVAG6'><b id='sVAG6'><form id='sVAG6'><ins id='sVAG6'></ins><ul id='sVAG6'></ul><sub id='sVAG6'></sub></form><legend id='sVAG6'></legend><bdo id='sVAG6'><pre id='sVAG6'><center id='sVAG6'></center></pre></bdo></b><th id='sVAG6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sVAG6'><tfoot id='sVAG6'></tfoot><dl id='sVAG6'><fieldset id='sVAG6'></fieldset></dl></div>
                        1. 主站蜘蛛池模板: 成人午夜影院 | 精品美女久久久 | 亚洲免费三区 | 欧美日韩亚洲一区 | 国产精品久久久 | 精品www| 午夜丰满少妇一级毛片 | 日韩精品1区2区3区 国产精品国产成人国产三级 | 国产精品污www一区二区三区 | 一区二区在线不卡 | 综合国产在线 | 日韩一区二区三区精品 | 亚洲色图第一页 | 日韩视频免费看 | 黑人巨大精品欧美一区二区免费 | 精品欧美一区免费观看α√ | 毛片毛片毛片毛片 | 国内精品久久久久久久 | 精品国产乱码久久久 | 国产欧美一区二区三区日本久久久 | 超碰在线网站 | 一区二区三区视频在线观看 | 亚洲欧美日韩精品久久亚洲区 | 麻豆精品一区二区三区在线观看 | 欧美亚洲视频在线观看 | 国产一在线观看 | 久久精品屋 | 成人精品国产 | 一区中文字幕 | 伊人久久伊人 | 成人亚洲片 | 成人高清视频在线观看 | 欧美一区二区三区视频在线观看 | 久久欧美精品 | 国产精品揄拍一区二区 | 国产一区二区三区四区 | 日韩精品一区二区三区视频播放 | 国产一在线观看 | 日韩在线精品视频 | 日日干综合 | 欧美日韩中文在线 |