Skip to content

Instantly share code, notes, and snippets.

@pedroricardo
Last active December 20, 2021 19:23
Show Gist options
  • Save pedroricardo/10ae51a653a8b1a286e5766f61f41679 to your computer and use it in GitHub Desktop.
Save pedroricardo/10ae51a653a8b1a286e5766f61f41679 to your computer and use it in GitHub Desktop.
Criando Bot Discord #6 - Adicionar Cargos por Reação https://youtu.be/J833mDDFMLQ
const Discord = require("discord.js"); //baixar a lib
const client = new Discord.Client();
const config = require("./config.json");
client.on("ready", () => {
console.log('Olá mundo')
})
client.on('raw', async dados => {
if(dados.t !== "MESSAGE_REACTION_ADD" && dados.t !== "MESSAGE_REACTION_REMOVE") return
if(dados.d.message_id != "566982078625873931") return
let servidor = client.guilds.get("558703169903788057")
let membro = servidor.members.get(dados.d.user_id)
let cargo1 = servidor.roles.get('566986334242340864'),
cargo2 = servidor.roles.get('566986370363686943'),
cargo3 = servidor.roles.get('566986398989549632')
if(dados.t === "MESSAGE_REACTION_ADD"){
if(dados.d.emoji.id === "566966275578789888"){
if(membro.roles.has(cargo1)) return
membro.addRole(cargo1)
}else if(dados.d.emoji.name === "👌"){
if(membro.roles.has(cargo2)) return
membro.addRole(cargo2)
}else if(dados.d.emoji.id === "566966738013388821"){
if(membro.roles.has(cargo3)) return
membro.addRole(cargo3)
}
}
if(dados.t === "MESSAGE_REACTION_REMOVE"){
if(dados.d.emoji.id === "566966275578789888"){
if(membro.roles.has(cargo1)) return
membro.removeRole(cargo1)
}else if(dados.d.emoji.name === "👌"){
if(membro.roles.has(cargo2)) return
membro.removeRole(cargo2)
}else if(dados.d.emoji.id === "566966738013388821"){
if(membro.roles.has(cargo3)) return
membro.removeRole(cargo3)
}
}
})
client.login(config.token);
@NekoChan-157
Copy link

So uma pergunta, eu coloco isso na Index ou crio uma pasta e de registro.js aí eu boto lá?

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