【问题标题】:How can i create link button in nextcord?如何在 nextcord 中创建链接按钮?
【发布时间】:2022-01-25 09:10:20
【问题描述】:

这是我想要的链接按钮。

这是我的代码:

class helpcmd(nextcord.ui.View):
    def __init__(self):
        super().__init__()
    
    @nextcord.ui.button(label='create thread', style=nextcord.ButtonStyle.link ,url='https://github.com/lmjaedentai/KaiCheng-Bot#commands')
    async def help(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
        #my code

错误:

  File "d:\Desktop\coding\discordpy\main.py", line 226, in helpcmd
    @nextcord.ui.button(label='create thread', style=nextcord.ButtonStyle.link ,url='https://github.com/lmjaedentai/KaiCheng-Bot#commands')
TypeError: button() got an unexpected keyword argument 'url'

【问题讨论】:

    标签: python button discord.py nextcord


    【解决方案1】:

    你不能因为 Discord 不返回,或者不支持 URL 按钮的回调。相反,您可以在def __init__ 中执行此操作并在self.add_item 中执行此操作。您可以在文档中查看更多信息。

    class SomeView(View):
        def __init__(self):
            super().__init__() #you can do timeout here
            self.add_item(url = "some url", label = "This is a url button") #using this method doesn't have any callback.
    

    【讨论】:

    • 非常感谢。
    猜你喜欢
    • 2011-11-25
    • 2011-08-15
    • 1970-01-01
    • 2015-06-18
    • 2022-08-16
    • 2023-02-11
    • 1970-01-01
    • 2016-07-10
    • 2011-11-04
    相关资源
    最近更新 更多