0
0

【Discord.js】BOTのステータスやアクティビティの設定方法解説

Last updated at Posted at 2024-09-16

こんにちは、りょうです。
まじで暑すぎて溶けながら書いてます。ではいきましょー🫠

ステータスとアクティビティ

ステータス
🟢オンライン(Online)、⛔取込み中(Dnd)、🌙退席中(Idle)、⚫オフライン(Offline)

アクティビティ
名前の下に表示されてるやつ(これでいうと/help || ping:39msの部分)
image.png

こいつらの設定方法の解説をします。

ステータスの設定

PresenceUpdateStatusを使います。
🟢オンライン→PresenceUpdateStatus.Online
⛔取込み中→PresenceUpdateStatus.DoNotDisturb
🌙退席中→PresenceUpdateStatus.Idle
⚫オフライン(オンライン状態を隠す)→PresenceUpdateStatus.Invisible

status.js
const { PresenceUpdateStatus } = require('discord.js');

client.user.setStatus(PresenceUpdateStatus.Online);
// client.user.setStatus(PresenceUpdateStatus.Idle);
// client.user.setStatus(PresenceUpdateStatus.DoNotDisturb);
// client.user.setStatus(PresenceUpdateStatus.Invisible);

アクティビティの設定

ActicityTypeを使います。
Playing,Watching,Listening,Competing,Streaming,Customから選択。

activity.js
const { ActivityType } = require('discord.js');

       // ...
       
        client.user.setActivity({ 
            name: 'BOTテスト',
            type: ActivityType.Playing
        });

〇〇をプレイ中(Playing)

        client.user.setActivity({ 
            name: 'BOTテスト',
            type: ActivityType.Playing
        });

image.png

〇〇を視聴中(Watching)

        client.user.setActivity({ 
            name: 'BOTテスト',
            type: ActivityType.Watching
        });

image.png

〇〇を再生中(Listening)

        client.user.setActivity({ 
            name: 'BOTテスト',
            type: ActivityType.Listening
        });

image.png

〇〇に参戦中(Competing)

        client.user.setActivity({ 
            name: 'BOTテスト',
            type: ActivityType.Competing
        });

image.png

〇〇を配信中(Streaming)
これは動画か配信のURLを設定していない又は無効な場合はOnlineで表示されます。

        client.user.setActivity({ 
            name: '配信内容', 
            url: 'YoutubeかTwitchの動画、配信URL', 
            type: ActivityType.Streaming 
        });

image.png
image.png

指定したものだけ(Custom)

        client.user.setActivity({ 
            name: 'BOTテスト',
            type: ActivityType.Custom
        });

image.png

まとめ

今回はステータス、アクティビティの設定方法の解説でした。
カスタムアクティビティやストリーミングなどは日本語の解説記事が少ないので参考になれば嬉しいです。

わからないことあったら書いてくれれば答えていきます。

Discordにいる荒らしの情報や対策方法の共有をしている自鯖です
ぜひ参加お願いします↓↓↓↓

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