discord.js

How to Play Audio File Into Channel?

我只是一个虾纸丫 提交于 2019-12-20 09:46:00
问题 How do you play an audio file from a Discord bot? Needs to play a local file, be in JS, and upon a certain message being sent it will join the user who typed the message, and will play the file to that channel. 回答1: GitHub Project: LINK In order to do this there are a few things you have to make sure of first. Have FFMPEG installed & the environment path set for it in Windows [link] Have Microsoft Visual Studio (VS) installed [link] Have Node.js installed.[link] Have Discord.js installed in

I am trying to make a discord.js avatar command, and the mentioning portion doesn't work correctly

流过昼夜 提交于 2019-12-20 07:35:17
问题 I have an avatar command in my discord bot. When the user uses h.avatar , it outputs their avatar, which works fine. Whenever they try to use h.avatar @user , nothing happens. Here is my code: } if (message.content.startsWith(config.prefix + "avatar")) { if (!message.mentions.users.size) { const avatarAuthor = new Discord.RichEmbed() .setColor(0x333333) .setAuthor(message.author.username) .setImage(message.author.avatarURL) message.channel.send(avatarAuthor); let mention = message.mentions

Overlapping commands?

自闭症网瘾萝莉.ら 提交于 2019-12-20 07:34:44
问题 I'm trying to make a fun little discord chat bot with JavaScript and node.js and I'd like to put in a specific command without it affecting another one I already have set up. She works wonderfully on all the servers I have her on, and I've got it set up so that when someone in the server says anything with "rei are", she responds with a constant from areResponses. //const!!! const areResponses = ["HELL yeah!", "Yep!", "I'm pretty sure that's true!", "I\'m not gonna put all the responses here

Overlapping commands?

你离开我真会死。 提交于 2019-12-20 07:34:22
问题 I'm trying to make a fun little discord chat bot with JavaScript and node.js and I'd like to put in a specific command without it affecting another one I already have set up. She works wonderfully on all the servers I have her on, and I've got it set up so that when someone in the server says anything with "rei are", she responds with a constant from areResponses. //const!!! const areResponses = ["HELL yeah!", "Yep!", "I'm pretty sure that's true!", "I\'m not gonna put all the responses here

How to fix discord.js-commando bot responding to unknown commands

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 04:35:56
问题 I'm creating the client with the unknownCommandResponse property set to false : const client = new CommandoClient({ commandPrefix: '$', unknownCommandResponse: false, owner: '291048060845424640', disableEveryone: true }); Yet when I try $kasopdkoakwdokapowkdo , it responds with: Unknown command. Use $help or @Mysticonomy#2670 help to view the command list. 回答1: That was the right way to do it until the 18th of January: they decided to make the bot "unknown command" and "error" replies

Cannot read property 'includes' of undefined

爱⌒轻易说出口 提交于 2019-12-20 04:33:14
问题 I am new to JavaScript, am I was trying to dissect an embedded message. Here's my code, it runs fine for a few mins, works accordingly but idk what goes wrong. bot.on('message', (message) => { for (var i = 0; i < message.embeds.length; i++) { if (message.embeds[i].title.includes("text!")) { message.channel.send('reply') } } }) 回答1: I think this code can fix this problem. bot.on('message', (message) => { for (var i = 0; i < message.embeds.length; i++) { if (message.embeds[i] && message.embeds

Embed message doesn't update

纵饮孤独 提交于 2019-12-19 09:56:40
问题 I want to make a vote with an embed message. When someone adds a reaction, I want to add a like and to show the number of likes in the embed. Here an example: Whenever someone clicks on like, all my code lines work and I finally change the Field value linked to like just like that : messageReaction.message.embeds[0].fields[0] = "Some much like"; But the embed message doesn't update. I've tried to update the message with this: function doAfakeEdit(message){ message.edit(message.content); } It

discord.js bot replies to itself

こ雲淡風輕ζ 提交于 2019-12-18 05:47:06
问题 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? 回答1: Use this in the

Send a message with Discord.js

本小妞迷上赌 提交于 2019-12-18 04:34:15
问题 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 ? 回答1: 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

How do I code event/command handlers for my Discord.js bot?

眉间皱痕 提交于 2019-12-17 20:54:25
问题 I've started creating a Discord bot in Node.js using the Discord.js library. However, all the code is contained within a single index file. How do I organize the commands and events each into separate files, and run them when needed? 回答1: An excellent, clean way to organize the code for your bot is to employ event and command handlers. In simple terms. You start out with a small index file to initialize the client and the rest of the code. An event handler keeps the files for each event, and