discord.js

Change user nickname with discord.js

跟風遠走 提交于 2019-11-30 04:50:44
问题 I wonder if you can help (I search it and nothing...) I am learning how to work with discord.js node and I want to change my user nickname (not the username itself) My code is const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log('I am ready!'); }); client.on('message', message => { if (message.content.includes('changeNick')) { client.setNickname({nick: message.content.replace('changeNick ', '')}); } }); client.login('token'); 回答1:

discord.js bot replies to itself

自古美人都是妖i 提交于 2019-11-29 09:42:40
I am currently coding my first discord bot, it can already play YouTube music. if (message.content.includes("Good Job") || message.content.includes("good job")) { message.channel.sendMessage("Good Job everyone :smirk:"); } As you see, if someone types "good job" (this is just an example) then the bot will reply with "good job everyone :smirk:), but then the spam will begin: the bot reads his own message and replies to it. How can I prevent the bot from answering itself? Use this in the on message event: if (message.author.bot) return; for more info: https://anidiotsguide.gitbooks.io/discord-js

Send a message with Discord.js

那年仲夏 提交于 2019-11-28 12:01:42
So. I am trying to make a discord bot, but i can't quite understand Discord.js. My code looks like this: client.on("message", function(message) { if(message.content === "ping") { client.message.send(author, "pong"); } }); And the problem is that I can't quite understand how to send a message. Can anybody help me ? You have an error in your .send() line. The current code that you have is used in an earlier version of the discord.js library, and the send function has been changed. To send a message, use this line: message.channel.send('My Message') If you get an error saying that message is not

Find out if someone has a role

风流意气都作罢 提交于 2019-11-27 06:14:06
问题 I made a simple quote bot for a server, but the admin only wants mod+ people to be able to add quotes to avoid spam. I went to the documentation and did everything, but I can't get this to work. Here's what I have: //other code else if (command === "addquote" && arg) { let adminRole = message.guild.roles.find("name", "Admin"); let modRole = message.guild.roles.find("name", "Mod"); if(message.member.roles.has(adminRole) || message.member.roles.has(modRole)){ const hasArr = arr.some((el) => {