有谁知道如何使用 disnake slash 命令发送临时消息?
Does any one know how to send and ephemeral message with disnake slash commands?
def sendBank():
desc = """
Bei dieser Nachricht kannst du auf die angefügten Buttons klicken, und damit diverse Funktionen ausführen.
Wie zum Beispiel von der Bank Geld ausheben, Geld in die Bank einzahlen, wie auch anderen Spielern dein Geld überweisen.
"""
embed = createEmbed(title="Unser Bankingsystem", description=desc, color=0x00ff0)
return embed
@bot.slash_command(name="bank", description="Zeigt alle Commands von dem Bank System")
async def bank(inter):
pc = Button(style=ButtonStyle.red, label="Geld überweisen", custom_id="1", emoji="")
withdraw = Button(style=ButtonStyle.green, label="Geld auszahlen", custom_id="2", emoji="")
deposit = Button(style=ButtonStyle.green, label="Geld einzahlen", custom_id="3", emoji="")
show = Button(style=ButtonStyle.green, label="Geld anzeigen", custom_id="4", emoji="")
await inter.channel.send(embed=sendBank(), components=[[pc, withdraw, deposit, show]], ephemeral=True)
所以我正在尝试这样做,但它向我显示了这个错误:
TypeError: send() got an unexpected keyword argument 'ephemeral'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Elyes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1346, in process_application_commands
await app_command.invoke(interaction)
File "C:\Users\Elyes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\slash_core.py", line 594, in invoke raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() got an unexpected keyword argument 'ephemeral'
我已经尝试使用其他 inter.*** 方法(属性),但没有一个像实际那样工作得很好。我已经读到你只能在交互响应中发送临时消息,所以如果你点击一个按钮。
如果您能帮助我,我将不胜感激。
祝你有个愉快的一天。
将 inter.channel.send
替换为 inter.response.send_message
。所有参数都一样
def sendBank():
desc = """
Bei dieser Nachricht kannst du auf die angefügten Buttons klicken, und damit diverse Funktionen ausführen.
Wie zum Beispiel von der Bank Geld ausheben, Geld in die Bank einzahlen, wie auch anderen Spielern dein Geld überweisen.
"""
embed = createEmbed(title="Unser Bankingsystem", description=desc, color=0x00ff0)
return embed
@bot.slash_command(name="bank", description="Zeigt alle Commands von dem Bank System")
async def bank(inter):
pc = Button(style=ButtonStyle.red, label="Geld überweisen", custom_id="1", emoji="")
withdraw = Button(style=ButtonStyle.green, label="Geld auszahlen", custom_id="2", emoji="")
deposit = Button(style=ButtonStyle.green, label="Geld einzahlen", custom_id="3", emoji="")
show = Button(style=ButtonStyle.green, label="Geld anzeigen", custom_id="4", emoji="")
await inter.channel.send(embed=sendBank(), components=[[pc, withdraw, deposit, show]], ephemeral=True)
所以我正在尝试这样做,但它向我显示了这个错误:
TypeError: send() got an unexpected keyword argument 'ephemeral'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Elyes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1346, in process_application_commands
await app_command.invoke(interaction)
File "C:\Users\Elyes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\slash_core.py", line 594, in invoke raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() got an unexpected keyword argument 'ephemeral'
我已经尝试使用其他 inter.*** 方法(属性),但没有一个像实际那样工作得很好。我已经读到你只能在交互响应中发送临时消息,所以如果你点击一个按钮。
如果您能帮助我,我将不胜感激。 祝你有个愉快的一天。
将 inter.channel.send
替换为 inter.response.send_message
。所有参数都一样