News Articles discord.js

time returns negative numbers

I am trying to create a 24hr timer on a database using quick.db, but my timer isn’t ticking, and time logs negative number. const db = require(‘quick.db’); const Discord = require(‘discord.js’); const ms = require(‘parse-ms’); let timer = await db.fetch(`daily_timer`); let timeout = 86400000; if (timer !== null && timeout – ( * -2 – […]

Error TypeError: Cannot read properties of undefined (reading ‘users’)

I’m making my Discord bot mute function and then it throws a weird error: TypeError: Cannot read properties of undefined (reading ‘users’) at line 5 Here’s my code: module.exports = { name: ‘mute’, description: ‘Mute users’, execute: (message, args, client) => { const target = message.mentions.users.first() if (target) { var reason; if (!message.member.permissions.has(‘MANAGE_CHANNELS’, true)) return […]

How do I send this message to another specific channel?

I have this code which advertises to server admins and mods when someone tags an important user on the server (a user who should not be tagged). Here’s the code. client.on(‘messageCreate’, message => { if( || === `DM`) return; if(message.mentions.members.get(`332599069027598336`)){ message.reply(`The user ${} has mentioned ${message.mentions.members.get(`332599069027598336`).user.tag}`); } }); Source: JavaSript – Stack Overflow

Discord.js slash commands TypeError: Cannot read property ‘get’ of undefined

Ok so I was tryna register some slash commands for my bot… But after making a slash command handler I came accross this error (node:34268) ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time (Use `node –trace-warnings …` to show where the warning was created) Bagel’s testbot#0147 has started, […]

Bot status without WATCHING/STREAMING/etc in discord.js?

who reads this), I tried to set a custom status for my Bot in discord.js and it worked. But now I want to set this status without a type of word like WATCHING/STREAMING and so on. Is that possible? Thank you for answering! Source: JavaSript – Stack Overflow

I have this error when i execute my lyrics command : DiscordAPIError: Cannot send an empty message

Hi can someone help me I have this error when I run my command lyrics: DiscordAPIError: Cannot send an empty message (it’s a music bot that uses a command handler) you can contact me on discord : R Λ Z#9217 const { MessageEmbed } = require("discord.js"); const lyricsFinder = require("lyrics-finder"); module.exports = { name: "lyrics", […]

Node.js application doesnt start up on heroku

I am trying to understand why is my heroku application not working anymore. It worked before, but suddenly it started showing an error in its logs: 2021-11-20T17:43:09.447233+00:00 heroku[Worker.1]: Process exited with status 1 2021-11-20T17:43:09.592799+00:00 heroku[Worker.1]: State changed from up to crashed 2021-11-20T17:55:53.598178+00:00 heroku[Worker.1]: State changed from crashed to starting 2021-11-20T17:55:55.576714+00:00 heroku[Worker.1]: Starting process with command […]

Connecting code to MongoDB database gives error: Error: querySrv ENODATA

I’m coding a discord bot and I want to connect it to a mongoDB database. However when doing this, I get this error, Error: querySrv ENODATA at QueryReqWrap.onresolve [as oncomplete] (node:dns:228:19) { errno: undefined, code: ‘ENODATA’, syscall: ‘querySrv’, hostname: ‘’ } Here is my code: client.on(‘ready’, () => { console.log(‘The bot is ready!’) const […]

how can someone mention me and the bot says something, in discord js v12

So if people mention me, I want the bot to say "yo sup", I’ve used this code but the bot doesn’t say anything I want the bot to say something back, I don’t know what’s wrong here what should i fix in this code ? client.on("message", (message) => { if( return; if(message.content.startsWith("<@myid> ")) {‘yo […]

Discord js bot: Cannot send DM to users with specific role

I seem to be having serious trouble sending DM’s to all users with a specific role. Here is my bot code: bot.on(‘message’, async message => { members = message.guild.roles.cache.find(role => === "12345678998765") =>; members.forEach(member_id => { sleep(5000).then(() => { message.users.fetch(member_id, false).then((user) => { user.send("some message"); }); }); }); }); This code gives me […]

TypeError: command.execute is not a function when catching an error. Also, cooldown doesn’t work. On Discord.js

I’ve been working on a Discord bot for a while and have implemented a cooldown command for a while too. It never works, and today i decided that i will try to fix it. At first, it kept sending me an error message saying TypeError: command.execute is not a function and an error message on […]

Discord.js music bot – stream issues

For some reason, my code suddenly doesn’t work as intended. It worked just a few weeks ago, yet now it refuses to work. I forgot how I tampered with it, but I’m pretty sure it isn’t by much. After joining a voice channel, my bot attempts to create an AudioResource via the stream provided by […]

Discord Bot JS Error: Cannot read property ‘execute’ of undefined

This is my index.js file const Discord = require(‘discord.js’); const client = new Discord.Client(); const prefix = "!"; const fs = require(‘fs’); client.commands = new Discord.Collection(); const commandFiles = fs.readdirSync(‘./commands/’).filter(file => file.endsWith(‘.js’)); for (const file of commandFiles) { const command = require(./commands/${file}); `client.commands.set(, command);` } client.on(‘ready’, () =>{ console.log(‘Garbonzo is online!’) //reactionroles(); }) client.login(token); //reaction […]

How to filter fetched JSON data?

I’m trying to make a simple command that pulls info from imgur, finds the images, and from there randomly decides which photo to show. The problem I’m having is that I can’t seem to filter the responses based on certain criteria. Here is the relevant code: async execute(interaction) { const data = await fetch( `${ […]

Discord.js: How do I convert timestamp to unix one?

So lately I’ve seen a lot of verified bots using the new "Unix Timestamps". But when I try <t:${}> it somehow outputs the 50000th year, lol. So that’s the problem. I will really appreciate any form of support because that problem seems controversial to me. Maybe there is some package or method which can solve […]

ReferenceError: channel is not defined (DISCORD.JS)

Been following a yt tutorial fort a music bot, I had to update some things for discord.js vs13 and it gave me this error, and the bot says it had an error to connect in the discord chat any help appreciated! (also I tried to define it but no luck, I’m a noob) This is […]

Discord JS – DiscordAPIError: Unknown Message

I get an error: DiscordAPIError: Unknown Message at RequestHandler.execute (D:ProgrammingDiscord Botnode_modulesdiscord.jssrcrestRequestHandler.js:298:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (D:ProgrammingDiscord Botnode_modulesdiscord.jssrcrestRequestHandler.js:50:14) at async MessageManager.delete (D:ProgrammingDiscord Botnode_modulesdiscord.jssrcmanagersMessageManager.js:205:5) at async Message.delete (D:ProgrammingDiscord Botnode_modulesdiscord.jssrcstructuresMessage.js:741:5) at async AudioPlayer.<anonymous> (D:ProgrammingDiscord Botsrccommandsnext.js:44:21) { method: ‘delete’, path: ‘/channels/888095042437259287/messages/909879363472855080’, code: 10008, httpStatus: 404, requestData: { json: undefined, files: [] } } when trying to delete […]

Discord JS – changing button’s emoji

I am trying to change button’s current emoji to a new one like this: // Initializing button const row = new MessageActionRow() .addComponents( new MessageButton() .setCustomId(‘play_pause’) .setEmoji(‘⏸’) .setStyle(‘PRIMARY’) ) // Button was sent to Discord await{ components: [row] }); // Changing content of a button row.components[0].setEmoji(‘▶’); But in the Discord nothing changes. When I […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.