1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Discord.pyでスラッシュコマンドリセットする

Posted at

問題

古いスラッシュコマンドがDiscord上のサジェストで出てきてしまい邪魔になる。
これらをリセットしたい

解決方法

以下のソースを実行する
botが起動し次第がコマンドのリセット処理が走る。

import discord
from discord.ext import commands

intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents, help_command=None)


# bot起動時
@bot.event
async def on_ready():
    bot.tree.clear_commands(guild=None)
    await bot.tree.sync(guild=None)

bot.run("ここにbotのトークンを書く")

これだけで解決しない場合

対象のbotをサーバーからキックして招待し直す

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?