discord.pyでスラッシュコマンド
Discord.pyのスラッシュコマンドの例
これちょっと古いかも
application_idも必須?
上のGeneral Informationにある、APPLICATION ID
https://gyazo.com/fe6fd838a623deb4fd12c467c3214ab9
code:test.py
import discord
from discord import app_commands
TOKEN = 'TOKEN'
APPLICATION_ID = 'APPLICATION_ID'
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents, application_id=APPLICATION_ID)
tree = app_commands.CommandTree(client)
@tree.command(guild=discord.Object(id=myGuildId))
async def slash(interaction: discord.Interaction):
await interaction.response.send_message(f'hello world')
@client.event
async def on_ready():
await tree.sync()
client.run(TOKEN)
古い環境のため非推奨
気合いがありすぎる人だけ