0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Discord.jsで作成したbotのコマンドが使えない場合に確認したこと

Last updated at Posted at 2022-03-29

困っていたこと

テスト用のDiscordサーバーで使えていたスラッシュコマンドが
本番用のサーバーでは表示されなかった。

確認したこと1

[OAuth]-[SCOPES]の"applications.commands"にチェックが入っているか
スクリーンショット 2022-03-30 010601.png

確認したこと2

index.js
// コマンド登録
client.on('ready', async () => {
  const data = []
  for (const commandName in commands) {
      data.push(commands[commandName].data)
  }
  await client.application.commands.set(data, process.env.SERVER_ID);
})

コマンド登録時にサーバーIDを指定していました。
そのため、特定のサーバーでしかコマンドが登録されていなかったのが原因でした。

以下のようにサーバーIDを指定しないとグローバルコマンドとして登録されます。

index.js
client.on('ready', async () => {
 ・・・・
  // コマンド登録
  await client.application.commands.set(data);
})
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?