【发布时间】:2020-06-29 20:37:36
【问题描述】:
我一直在尝试用一个命令在 discord.js 中编写一个不和谐机器人,该命令允许用户对消息做出反应并接收角色。这是我当前的代码。我不确定如何在用户添加反应时赋予角色以及当用户的反应移除它带走的角色时如何使其成为。
const { RichEmbed } = require('discord.js');
const Discord = require("discord.js");
const colors = require("../colors");
const botconfig = require("../botconfig");
exports.run = async (client, message, args) => {
await message.delete().catch(O_o=>{});
const role1 = message.guild.roles.get('688477558982836344'); // Replace with Updates ID
const role2 = message.guild.roles.get('688477690344374283'); // Replace with Events ID
const role3 = message.guild.roles.get('688477467840872452'); // Replace with QOTD ID
const role4 = message.guild.roles.get('688477868078137369'); // Replace with Polls ID
const role5 = message.guild.roles.get('687498488295981069'); // Replace with Social Media ID
const embed = new Discord.RichEmbed()
.setTitle('Pinged Roles')
.setDescription(`
Tip: *Double React to remove a role*
❤️ ${role1.toString()}
???? ${role2.toString()}
???? ${role3.toString()}
???? ${role4.toString()}
???? ${role5.toString()}
`)
.setColor(colors.purple)
.setFooter('mc.advancius.net')
message.channel.send(embed).then(async msg => {
await msg.react('❤️');
await msg.react('????');
await msg.react('????');
await msg.react('????');
await msg.react('????');
});
}
module.exports.help = {
name: "roles"
};
【问题讨论】:
标签: discord discord.js