我正在制作一组简单的斜杠命令,使用pycord来表示不和谐。
import discord
bot = discord.Bot()
testingServer = [{server ID}]
@bot.slash_command(guild_ids = testingServer, name ="verify_help", description="blabla" )
async def verifyHelp(ctx):
embed=discord.Embed(title="Verify Your Wallet", description = "help goes here",color=0xffffff)
await ctx.respond(embed = embed, ephemeral=True)
bot.run({TOKEN})我相信创建多个单词斜杠命令是可能的,就像在不和谐API文档中看到的那样:
ie使用斜杠命令作为/verify帮助,而不是/验证-帮助
https://discord.com/developers/docs/interactions/application-commands
我认为我需要将“选项”部分转换为pycord,但不知道语法。它列出了建议和选项列表,因此选项= []。这就是我被困的地方。
用于斜杠命令的pycord手册如下:https://docs.pycord.dev/en/master/api.html#slashcommand
发布于 2022-02-18 00:53:19
解释
你要找的是斜杠命令组。您将创建一个SlashCommandGroup,然后不再使用标准bot.slash_command,而是使用SlashCommandGroup.command。
下面的代码显示了一个使用/verify help的示例
代码
verify = bot.create_group(name="verify", description="testing", guild_ids=[703732969160048731])
@verify.command(name="help", description="help me pls")
async def verify_help(inter: discord.Interaction):
print("Hello? How are you? I am under the water, please help me")注意:在cog中,您将通过构造函数(而不是通过SlashCommandGroup )实例化SlashCommandGroup。另外,斜杠命令将以self作为其第一个参数,以一个Interaction作为其第二个参数。
参考文献
https://stackoverflow.com/questions/71166643
复制相似问题