Skip to content

Instantly share code, notes, and snippets.

@waki285

waki285/auth.js Secret

Created October 17, 2021 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save waki285/8a2328f106f5d73648c5ad8c79ce0897 to your computer and use it in GitHub Desktop.
Save waki285/8a2328f106f5d73648c5ad8c79ce0897 to your computer and use it in GitHub Desktop.
認証
client.on('ready', () => {
client.channels.cache.get("リアクション付けるメッセージのチャンネルID").messages.fetch("リアクション付けるメッセージID");
});
client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.message.id !== "リアクション付けるメッセージID") return;
if (user.bot) return;
reaction.remove();
const num = Math.floor(Math.random() * 9000000000)+ 1000000000;
const msg = await user.send(`次の数字を送信してください → ${num}`);
msg.channel.awaitMessages((m) => true, { max: 1, time: 1000 * 60})
.then(collected => {
if (!collected.size) return;
const m = collected.first();
if (m.content === String(num)) {
msg.channel.send("認証完了");
reaction.guild.member(user.id).roles.add("メンバーロールのID");
} else {
msg.channel.send("コードが違います\nリアクションからやり直してください");
}
});
});
@tamagodayo
Copy link

メンバーロールのIDとは何ですか?

@waki285
Copy link
Author

waki285 commented Nov 27, 2021

メンバーロールのIDとは何ですか?

認証された後に付与されるロールのIDです

@tamagodayo
Copy link

DMに数字は送られてきましたがロールが付与されません、

@waki285
Copy link
Author

waki285 commented May 5, 2022

エラーは出ていますか?

@tamagodayo
Copy link

tamagodayo commented May 5, 2022

エラーは出ていません
ロールが付与できないだけです

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment