Better Command プラグイン v1.0
引数・説明・app_commands.Choice に対応したスラッシュコマンドブロックを追加します。
ブロック
説明
⚡ スラッシュコマンド / name 説明 desc
引数付きスラッシュコマンドを定義
ブロック
Python 型
📝 文字列引数
str
🔢 整数引数
int
☑ 真偽値引数
bool
👤 メンバー引数
discord.Member
💬 テキストch引数
discord.TextChannel
🎙 VCチャンネル引数
discord.VoiceChannel
🔽 選択肢引数
app_commands.Choice[str/int]
各引数ブロックに 名 / 説明 / 必須(チェックボックス) を設定できます。
🔽 選択肢引数 の「選択肢 ↓」欄に ・ 選択肢アイテム を並べる
ブロック
返す値
引数 XXX の値
str / int / bool / Member / Channel
選択肢引数 XXX の値
.value(文字列 or 整数)
@bot .tree .command (name = "vc" , description = "VCに参加します" )
@app_commands .describe (channel = "読み上げるテキストチャンネル" )
async def vc_cmd (interaction : discord .Interaction , channel : discord .TextChannel ):
ctx = interaction
user = interaction .user
# 処理...
@bot .tree .command (name = "color" , description = "色を選ぶ" )
@app_commands .describe (color = "好きな色" )
@app_commands .choices (color = [app_commands .Choice (name = "赤" , value = "red" ), app_commands .Choice (name = "青" , value = "blue" )])
async def color_cmd (interaction : discord .Interaction , color : app_commands .Choice [str ]):
ctx = interaction
user = interaction .user
chosen = color .value # "red" or "blue"