discord.js

Discord bot sends response twice

蓝咒 提交于 2021-02-11 13:39:19
问题 I'm coding a discord.js bot, and whenever I send a command, it gives a response twice. I've concluded it's because I have too many instances running. I try to delete the instances, but it doesn't delete. Sometimes it says "Some instances could not be deleted", and sometimes it doesn't delete at all. And through Terminal SERVICE VERSION ID VM_STATUS DEBUG_MODE default 20191208t223728 aef-default-20191208t223728-0l57 RUNNING default 20191208t223728 aef-default-20191208t223728-jb53 RUNNING

JS Can't query MySQL database. ERROR: connection.query is not a function

血红的双手。 提交于 2021-02-11 12:56:58
问题 Trying to query my mySQL database but I can't because i get a TypeError: connection.query is not a function error. Does anyone have any idea why? I don't have any clue as to why this is happening. database.js const fs = require('fs'); // node.js file system module require('dotenv').config(); // stores tokens, keys, passwords and other info const Discord = require('discord.js'); // links discord.js api to file const database = require('./database.js'); const client = new Discord.Client(); //

Discord.js guild.roles.cache.find returning undefined

余生颓废 提交于 2021-02-11 12:46:08
问题 Im trying to assign code a discord bot to give someone a role whenever they enter a server. This is my code right now: client.on('guildMemberAdd', (member) => { let role = guild.roles.cache.find(r => r.name === "Admin"); console.log(role); if(!role){ console.log("Role doesen't exist."); } member.roles.add(role); }); I tried running it, and this line executed: console.log("Role doesen't exist."); . I then went on to print the role variable, and it was undefined. What's the problem? 回答1: First

discord.js say command actually says “say”

人盡茶涼 提交于 2021-02-11 12:18:55
问题 I've never had a problem with the say command until I start using modules and cleaned up my code but since I have few my commands have bugged. I'm trying to figure out why it is saying the command. const commandFiles = fs .readdirSync("./commands/") .filter(file => file.endsWith(".js")); for (const file of commandFiles) { const command = require(`./commands/${file}`); bot.commands.set(command.name, command); } bot.on("message", async message => { if (!message.content.startsWith(PREFIX))

Check if command is ran in certain channel

时光怂恿深爱的人放手 提交于 2021-02-11 06:48:46
问题 I currently have this as my command: bot.on('message', function (message) { if (message.content == '!register') { message.member.send("Registered!"); let memberRole = message.member.guild.roles.find("name", "Verified"); message.member.addRole(memberRole); } }); I want it so this command can only be ran in a text channel called registration (I have the channel id if needed). 回答1: Here is the code if you only have one textchannel called registration : bot.on('message', function (message) { if

Check if command is ran in certain channel

做~自己de王妃 提交于 2021-02-11 06:48:19
问题 I currently have this as my command: bot.on('message', function (message) { if (message.content == '!register') { message.member.send("Registered!"); let memberRole = message.member.guild.roles.find("name", "Verified"); message.member.addRole(memberRole); } }); I want it so this command can only be ran in a text channel called registration (I have the channel id if needed). 回答1: Here is the code if you only have one textchannel called registration : bot.on('message', function (message) { if

heroku push rejected, failed to compile Node.js app

喜欢而已 提交于 2021-02-11 06:25:17
问题 I keep getting node-pre-gyp and gyp errors when I try to deploy my Node.js application to Heroku: $ git push -f heroku master Enumerating objects: 48, done. Counting objects: 100% (48/48), done. Delta compression using up to 4 threads Compressing objects: 100% (42/42), done. Writing objects: 100% (48/48), 3.33 MiB | 232.00 KiB/s, done. Total 48 (delta 3), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote:

heroku push rejected, failed to compile Node.js app

最后都变了- 提交于 2021-02-11 06:24:08
问题 I keep getting node-pre-gyp and gyp errors when I try to deploy my Node.js application to Heroku: $ git push -f heroku master Enumerating objects: 48, done. Counting objects: 100% (48/48), done. Delta compression using up to 4 threads Compressing objects: 100% (42/42), done. Writing objects: 100% (48/48), 3.33 MiB | 232.00 KiB/s, done. Total 48 (delta 3), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote:

Heroku build failing on dependency install

雨燕双飞 提交于 2021-02-10 19:51:52
问题 Node Canvas isn't installing on Heroku build, even though it works just fine on my own PC. I'm on nodejs version 12.16.3. I can't find a solution for this anywhere. Canvas is a must, and I've never seen this error before until Heroku. Is this a problem with Heroku or a problem with my package/package-lock files? My Discord is Tom Becker#0590 in case you need it. Here's my build log: -----> Node.js app detected -----> Creating runtime environment NPM_CONFIG_LOGLEVEL=error NODE_ENV=production

How to make the bot send personalized emojis?

…衆ロ難τιáo~ 提交于 2021-02-10 17:28:41
问题 Well, I'm currently using the emoji :x: , but on my server I have an emoji called :superbotxemoji : I just don't know how I get my bot to use it My code: const Discord = require('discord.js'); module.exports = { name: 'say', description: 'say', execute(message, args) { const { prefix, token } = require('../config.json'); if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send({ embed: { color: 16777201, description: `:x: | ${message.author}, You are not allowed to use