【发布时间】:2022-01-05 15:54:54
【问题描述】:
所以我一直在尝试制作一个解释其他机器人经济系统的机器人。 单击某个按钮后会出现一条消息,我想在该消息中添加另一个按钮。它不起作用,我不知道为什么。
代码如下:
from nextcord.ext import commands
from nextcord.ui import view
def Sbdrugs(self, ctx):
embed = nextcord.Embed(title="Drugs", description="Drugs play an important role in Slotbot. So make sure to remember what they do.")
embed.set_author(name = ctx.author.display_name, icon_url = ctx.author.avatar_url)
embed.add_field(name = "Weed", value = "Weed can be smoked to restart cooldowns of almost everything including drink. (*Doesnt include drugs.*) Remember, weed is the currency of the black market.", inline = False)
embed.add_field(name = "Drink", value = "Drinking beers basically restarts every cooldown except drugs.", inline = False)
embed.add_field(name = "Steroids", value = "Dosing steroids makes you immune against the ~hex command and gives you access to the ~beatup command. Steroids even decrease the chance of getting scammed from 30% to 10%. It shortens the feed cooldown too.", inline = False)
embed.add_field(name = "Opioids", value = "Make you immune against gun shots, makes you immune against beatup too and resets all cooldowns (except drugs) including smoke and drink.", inline = False)
embed.add_field(name = "Anesthesia **AKA** Anes", value = "Stuns yourself but also makes others not possible to interact with your slotbot stats (bal, goose etc they cant check anything from you).", inline = False)
embed.add_field(name = "LSD", value = "Shortens every cooldown to 15 secs but makes it very hard to do other cooldowns like bal or farm for example. LSD is mostly used for pill farming, constantly shooting people and for some other things but i currently cant remember.", inline = False)
def Helpmeembed(self, ctx):
embed = nextcord.Embed(title = "You called me...?", description= "What do you need help with?")
#still working on this
class SbDrugs(nextcord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@nextcord.ui.button(label = "1", style = nextcord.ButtonStyle.blurple)
async def helpb(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
await interaction.response.send_message({Sbdrugs}, ephemeral=False)
self.value = True
self.stop()
class Helpb(nextcord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@nextcord.ui.button(label = "1", style = nextcord.ButtonStyle.blurple)
async def helpb(self, ctx, button: nextcord.ui.Button, interaction: nextcord.Interaction):
view = Sbdrugs()
await interaction.response.send_message("What do you need help with on Slotbot?\n**1. Drugs**", ephemeral=False, view = view)
self.value = True
self.stop()
class Help(commands.Cog, name="Help"):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command()
async def helpme(self, ctx):
view = Helpb()
await ctx.send("Hey, I'm here, what do you need help with?\n\n**Slotbot**\n*Press 1 for more information.*", view = view)
await view.wait()
if view.value is None:
await ctx.send("Ay, where you at bruh")
def setup(bot: commands.Bot):
bot.add_cog(Help(bot))
这是我得到的错误:
Ignoring exception in view <Helpb timeout=180.0 children=1> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='1' emoji=None row=None>:
Traceback (most recent call last):
File "C:\Users\Windows\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\ui\view.py", line 359, in _scheduled_task
await item.callback(interaction)
TypeError: helpb() missing 1 required positional argument: 'interaction'
【问题讨论】:
标签: python button discord bots nextcord