generated at
ユーザーの端末ごとのステータスを送信するボットのサンプル
ユーザーの端末ごとのステータスを取得する方法を使って、送信者の端末ごとのステータスを表示するサンプル
動作にはGUILD_PRESENCES Intentsが必要

js
const Discord = require('discord.js') const client = new Discord.Client({ intents: ["GUILD_PRESENCES","GUILDS","GUILD_MESSAGES",/*and more*/] }) client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`) }) client.on('message', message => { if (message.member) { return message.channel.send('サーバー内で実行してください。') } if (message.content === 'status') { const userStatus = message.member.presence.clientStatus if (!userStatus) { return message.channel.send('どのデバイスからもアクセスされていません。') } message.channel.send( [ 'desktop: ' + (userStatus.desktop || 'offline'), 'mobile: ' + (userStatus.mobile || 'offline'), 'web: ' + (userStatus.web || 'offline'), ].join('\n') ) } }) client.login('TOKEN')

js
const Discord = require('discord.js') const client = new Discord.Client() client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`) }) client.on('message', message => { if (message.content === 'status') { const userStatus = message.author.presence.clientStatus if (!userStatus) { return message.channel.send('どのデバイスからもアクセスされていません。') } message.channel.send( [ 'desktop: ' + (userStatus.desktop || 'offline'), 'mobile: ' + (userStatus.mobile || 'offline'), 'web: ' + (userStatus.web || 'offline'), ].join('\n') ) } }) client.login('TOKEN')