私はボットDMを(新しいメンバーだけでなく)すべての人にしようとしていますが、これをどのように行うのかわかりません。どんな助けでも大歓迎です。
// Async context (within async function), 'message' being the command message.
const members = message.guild.members.filter(m => !m.user.bot).array(); // Filter out bots.
let undelivered = 0;
for (let i = 0; i < members.length; i++) { // Using an array and a for loop rather than
const member = members[i]; // Collection.forEach() due to the fact that
await member.send('Hello there.') // the latter will move onto the proceeding
.catch(() => undelivered++); // code before waiting for the promises to
} // fulfill. https://stackoverflow.com/a/37576787
message.channel.send(`Messages sent. ${undelivered} members couldn't receive it.`)
.catch(console.error);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加