Questions tagged [discord.js]

0

votes
0

answer
5

Views

how to fix events not working after restarting the bot

i have a problem with the message reaction, i made the bot to delete any message sent on channel names appeal and send it to another channel names the appeals and react to the message with :white_check_mark: and if someone reacted to the message with the :white_check_mark:, the bot will automaticly...
iTzMuntadher
1

votes
2

answer
1.9k

Views

How to detect if a message is edited?

I am intending for my bot to allow only 'ew' to be sent in chat. I have resolved majority of the work-arounds, however, there is one I can't resolve independently. When someone posts 'ew' in chat and then edits the message to something else, it remains like that without being deleted. How could I re...
Brandon
1

votes
2

answer
518

Views

Regex Pattern for All Discord Tag Types

doing some discord.js bot development and I'm trying to create a regex that will filter out all types of discord tags (aka tagged users and custom emotes). I've tried a few different things, but none that will capture every case. The 5 main styles of tag are: (User) (User) (Emote without number in n...
R. Gillie
1

votes
1

answer
26

Views

addRole to a mentioned user isn't working

I'm trying to make a discord bot, which can add a specific role to an user. const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('message', (message) => { let allowedRole = message.guild....
Sir Cyborg
1

votes
3

answer
150

Views

Discord Bot “Status” from Playing to Watching?

I'm hoping to change my discord's bot status from 'Playing' to 'Watching' or any of the other options but can not understand where to declare this at, can someone please help me? This is the line of code I have for the current status: client.user.setActivity(`${client.users.size} in here buying the...
artvandelay
-2

votes
0

answer
27

Views

Is it possible to start a new line for a number of characters?

Is it possible to start a new line for a number of characters? I need to use it in any embed. For my discord bot.
Dave Tetenburg
1

votes
1

answer
44

Views

MySQL Query crashes my program even when in try statement

It errors out when the record couldn't be found Cannot read property 'id' of undefined How can I keep it from crashing out and handle 'undefined'? let blacklisted = false; let conStr = 'SELECT * FROM `blacklist` WHERE `id` = ''+message.author.id+'''; con.query(conStr, function(error, result, field)...
KillerDogeAlt
1

votes
1

answer
816

Views

How do I create a case statement in discord.js

This code is what i am using now to have a rough idea of what to do bot.on('message', (message) => { if (messege.content.includes) { int (num = 0); switch(num) { case 1: System.out.println('The IP of the server is .'); case 2: System.out.println('The Store is'); case 3: System.out.println('Disord in...
Jake Baalham
1

votes
1

answer
768

Views

Delete all messages in a channel from my bot

channel.fetchMessages() .then(messages => messages.array.forEach( message => message.author.equals(client.user) && message.delete() )); Tried to do this to delete from TextChannel channel all messages that my bot has sent. Doesn't work, errors: messages.array.forEach is not a function How can I get...
theonlygusti
1

votes
1

answer
753

Views

Mentioning a channel with message.mentions.channels

So I simply need a little help on how to do a thing on discord.js. I'm really confused on how to use message.mentions.channels and the Documentation isn't helping. I just need a command that console.log's the channel mentions (like #annoucements) Confused as to how. My code right now is if (args.joi...
Zetari
1

votes
1

answer
1.7k

Views

Add permissions to channel for user

I've recently added this Discord bot to my server: https://github.com/critcola/discord-auto-grouping It's working great and I've modified it slightly to ensure it creates a room based on the user's name, with a user limit and under a certain category in my server. My last edit — which I can't seem...
Dave Maltby
1

votes
2

answer
874

Views

Waiting till the promise is finished [duplicate]

This question already has an answer here: How do I return the response from an asynchronous call? 34 answers I'm creating a discord bot, and trying to structure a bit better. message.channel.send(require('./commands/' + inputs[0] + '.js')(inputs)); This will require a file and send the returned mes...
9349u8u3guhir
1

votes
1

answer
292

Views

Got “Unexpected end of input” in Javascript when making a Discord Bot

client.on('message', (message) => { message.channel.send({ embed: { color: 3447003, author: { name: client.user.username, icon_url: client.user.avatarURL }, title: 'commands', description: 'all current commands', fields: [{ name: 'admin only', value: 'ban' }, { name: 'moderator only', value: 'kick'...
isa belle
1

votes
1

answer
1.3k

Views

Way to check if a channel exists

module.exports.run = async (bot, message, args) => { let ticketreason = args[1]; let ticketname = 'ticket' + ticketreason; message.guild.createChannel('tickets', 'category') message.guild.createChannel(ticketname, 'text'); } So I've got this very simple and basic code here. I am trying to find a wa...
Josh Bowker
1

votes
0

answer
370

Views

Discord.js bot replies itself when awaiting messages

After the bot sends the message message.channel.send('Fortnite added!'); or another roles, the bot replies to itself with the default message until the 5 seconds ran out. const awaiting = await message.channel.send('Awaiting your role(s)...'); const roles = await message.channel.awaitMessages(msg =>...
Keolor
1

votes
2

answer
285

Views

bot keeps repeating

This discord bot keeps repeating what it just said concatenating two strings! Please help! const Discord = require('discord.js'); const client = new Discord.Client(); const prefix = '*'; client.on('message', (message) => { if (message.content == prefix + 'test') { message.channel.sendMessage('```Use...
Nathaniel Herron
1

votes
1

answer
1.3k

Views

Want to add a role when reacting to a message discord.js

I want to have someone get a role when they react to a message. I'm not sure how to start.
MilkyBob
1

votes
1

answer
6.6k

Views

Discord music bot not working

When I run the following script ('node musicbot.js' in cmd) and '!play ytlink' within discord itself, the bot joins the voice channel and logs both the command and the link in the console. Yet, the music does not start playing. I have installed ffmpeg, ytdl-core, and discord.js. Can someone help me...
1

votes
1

answer
114

Views

Skip function on Discord music bot removes all array entries

I can't get tracks to skip on our music bot without it panicking and deleting the entire playlist. More details below. On command, this bot will use YouTube-DL to download a video from YouTube or track from BandCamp and play it back through a voice channel. The track is downloaded, loaded into an a...
Bevan Edwards
1

votes
1

answer
1k

Views

Discord Bot shall delete “user pinned message to channel” message

I'm kinda new to programming a discord bot, but now I have a problem and can't find a solution. I'm not even sure which language I'm using - I work in Atom, start my bot with node index.js and use functions / classes / ... from here: https://discord.js.org/#/docs/main/stable/general/welcome My probl...
Nana Chan
1

votes
1

answer
4.3k

Views

Discord.js random image

Okay, so I have a reaction command that so far shows one image when the command is used like it is supposed to. However, I have multiple images that I want it to choose from and show one randomly. Like how a math.random will choose a random sentence from a list. Except I want images instead of sente...
Vampy Maria
1

votes
1

answer
4.5k

Views

Joining a voice channel on ready (discord.js)

I tried this: client.on('ready', () => { let channel = client.channels.get('432462518380789771'); channel.join() }); It doesnt work. I made sure that the ID is right and everything and its still not working.
ejer
1

votes
1

answer
438

Views

Discord.js It is necessary to have the message sent to Embed (so it could be the specified parameters

It is necessary to have the message sent to Embed (so it could be the specified parameters (color, author, title, description, addField, content message) Example: https://embedbuilder.nadekobot.me/ const arg = message.content.slice().trim().split(/ +/g); let name = arg[1]; if (!name) return message....
Muereta
1

votes
1

answer
873

Views

discord.js - Has role give permission

So basically I am trying to make a ticket sort of discord bot using discord.js. The concept: someone says +help then it DMs a member, who has said +onduty and has a role of something like 'Helper'. I need to work out how to detect the role and add them to a set who are 'on duty'. I was wondering i...
Ross
1

votes
1

answer
87

Views

Discord.js - Creating an Array to Dump Image Files

I am currently hosting a Discord.js bot, and have hit a snag whilst creating a command. I already have in place a command that uses a predefined array to select a random photo to send to the text channel (See code below). However, I wanted to know how to create a command that dumps all of the images...
Resistiv
1

votes
1

answer
2.3k

Views

How to list all members from a specific server?

My code is const list = client.guilds.find('id', '335507048017952771') for (user of list.users){ console.log(user[1].username); } This does literally nothing. There is no error or anything. I just want the bot to find a server and then log all members from said server. Displaying all connected users...
1

votes
1

answer
236

Views

Can't host Discord Bot on Raspberry Pi

I did everything in the tutorial(https://www.youtube.com/watch?time_continue=758&v=kpci6V8969g). When I run the pm2 command, the bot doesn't work. When I try the node index.js command, it displays me this error: async setProvider(provider) { ^^^^^^^^^^^ SyntaxError: Unexpected identifier at createSc...
1

votes
1

answer
1.2k

Views

Exporting/importing in node.js / discord.js

I am currently making a discord bot with discord.js and because I haven't programmed without an html file before I find using several js-files quite difficult. At first i thought using imports and exports was gonna work, but it isn't supported in Node yet. I did some snooping around and this is what...
Dubster
1

votes
1

answer
311

Views

Node.js GET request sometimes receives HTML document instead of JSON and crashes

I am using node.js (and discord.js) to make a discord bot. I am using a GET request with the npm request module. Code works as expected when user types '!cat' it gets data from https://aws.random.cat/meow and posts a cat picture HOWEVER sometimes the server will give a 403 forbidden error which resu...
Todgins
1

votes
1

answer
62

Views

Toggle Feature?

So i'm attempting to make my bot toggle on and off whether or not to send messages in all caps or not. My problem is that when I try to change the variable value it doesn't change. Could anyone help me? New to both stack overflow and programming(ish, know enough to get me this far)
NeedsHelp
1

votes
3

answer
2.1k

Views

Reload command discord.js

I'm making a discord bot with discord.js, but my reset command isn't working. //!reload if(command === `${botsettings.prefix}reload`) { console.clear(); bot.destroy() bot.login(botsettings.token); message.channel.send('Reloaded'); return; } It doesn't give any error; it restarts and goes back on but...
Tiniux
1

votes
1

answer
773

Views

Bot mention as a prefix in Discord.js

My prefix only works if I do not add spaces to the entire command, example: { 'token': '', 'prefix': '' } const Discord = require('discord.js'); module.exports.run = async (bot, message, args) => { let something = args.join(' '); message.delete().catch(); message.channel.send(something); } module.ex...
Jay
1

votes
1

answer
40

Views

javascript sets - adding value to array in object inside a set

I'm trying to make an array of sets to make something like this { 'user1': ['value#1', 'value#2',...'value#N'], 'user2': ['value#2',...'value#N'], 'userN': [...'value#N'] } and then remove the value#x after 5 seconds (for example). here is my code: var myset = new Set(); var ran = myset[USERID] = co...
Brian Harianja
1

votes
2

answer
817

Views

Create a group DM Discord.js

I am trying to get my bot to message two people but in the same chat window (like when you add a friend to a conversation). The only thing I've found is how to send to a single person by doing .send(message); How could I add a second person to that conversation? Any examples would be highly apprecia...
user2896438
1

votes
1

answer
642

Views

Make Discord Bot receive file and send the contents to the channel

So I want to make it so that if I do this: I use !command in the channel.. (The bot asks for a file) I send a file The bot should then read the file and send the contents. I tried: await message.channel.send('Send your file please..'); const MSG1 = await message.channel.awaitMessages(msg => { const...
1

votes
0

answer
444

Views

Cannot read property 'pipe' of undefined

I have little problem with my code ;/ I want to create bot that send random meme from a folder but every time when i try to send it I got error with Cannot read property 'pipe' of undefined This is my code (if u find any thing that will help in that code I will be glad to hear it!) const config = r...
Malutki Siwy
1

votes
2

answer
1.1k

Views

How do I use a local image on a discord.js rich embed?

I have this code: var datos = ['dato1','dato2','dato3'] console.log ('》' + message.author.username + ' introdujo el comando: ' + message.content + ' en ' + message.guild.name); let embed = new discord.RichEmbed() .setTitle('Datos sobre gatos 🐈') .setColor(12118406) .setDescription(datos[Mat...
dperales555
1

votes
1

answer
59

Views

(Discord) SQLite 2 values 1 column error

I'm a discord bot developer and switched to SQLite I previously had some errors and problems with it but that got fixed. After I created multiple tables I'm getting an error I can't seem to figure out this is the error: (node:17024) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje...
ChickenDev
1

votes
0

answer
174

Views

scaling a discord bot to potentially 100k plus concurrent users

So currently I'm struggling to find an efficient way to scale a discord bot written in node.It currently has music capabilities and over 100 chat commands plus moderation features. I'm in talks with large scale partnered discord servers to put my bot on their server but don't have a clue how id scal...
Bloxerman
1

votes
2

answer
33

Views

Check array and if one value missing every 2 elements

I have and array from string. When I get the values from string then I split the string so I get an array. If I give in command: .command 12 Test 1 Test1 2 Test3 and so on Then I get: ['12', 'Test', '1', 'Test1', '2', 'Test3'] This is good but I don't know how to check 12, 1, 2 if it is integer or n...

View additional questions