News Articles discord.js

Why do I get the error ‘Invalid interaction application command’ when I use this Slash command in discord.js?

When I try do use this slash command it says ‘Invalid interaction application command’. How do I fix this? I can show more code if needed. const Command = require(‘../structures/command.js’); const config = require(‘../data/config.json’); const { MessageEmbed } = require(‘discord.js’); const Discord = require(‘discord.js’); module.exports = new Command({ name: "ping", description: "Shows the ping of […]

how to collect user message in DM in do Discord.js

I’m trying to gather a user’s response to my bot’s message, but it’s all happening in DMs. How can I complete this task with Discord.js (13.x)? const Discord = require(‘discord.js’); const intents = new Discord.Intents(32767); const client = new Discord.Client({ intents }); const config = require(‘./config.json’); const privateMessage = require(‘./private-message’); client.on(‘ready’, () => { console.log(‘Ready!’); […]

message is not defined ReferenceError

I don’t know where I am wrong and I searched for hours to find a solution. const collector = new Discord.MessageCollector(, (m) => m.embeds.length > 0, { maxProcessed: 1, max: 1 }); if (message.content === ",give") { collector.on("collect", (el, c) => { let text = el.embeds[0].description; var getRec = text.split("Max you can receive: **$").pop().split("**")[0]; el.react("👁️").then((r) […]

set status command doesn’t set status

This should change the status and activity but for some reason, it only changes the status not the activity. const args = message.content.slice(prefix.length).trim().split(/ +/); const command = args.shift().toLowerCase(); if (command == "status") { if (!args[2]) { return{ content: "Usuage: {prefix}{command} {online/idle etc} {type} {status}" }); } client.user.setPresence({ status: `${args[0]}`, activities: [{ type: `${args[1]}`, name: […]

Can I save information in message requests with Discord API?

I tried to send messages like this client.api.channels({ content: ‘content’, test: ‘test’ }) I was hoping that since it’s an API post request, it would save the test property. const msgs = await client.api.channels(;[1].test) //error: cannot send an empty message Changing .test to .content does send the content of the message the bot sent […]

How to include an if-else condition in fetch API request?

I am trying to make a discord bot that sends memes. I want a filter for NSFW images. The API I’m using gives nsfw: true/false in the response. Here is my code async function getMeme() { subreddit = memeSubreddits[Math.floor(Math.random() * memeSubreddits.length)]; try { const res = await fetch(`${subreddit}`); const data = await res.json(); return data["url"]; […]

PermissionOverwrites doesn’t have function edit/create in discord.js?

this is my first post on stack overflow so I apologize in advance for any mistakes I make. I was following a page on the discordjs website but after copying exactly what it says, i get an error like "TypeError: is not a function", { VIEW_CHANNEL: false }); Above is the code, can […]

Discord.js V13: How to edit Message Object of Interaction?

I am trying to update my discord bot to the new version of discord.js (v13). I have a message with an embed and two buttons, one for previous Page and one for next page. When a user clicks a button, I am trying to edit the embed to show something else. But then I get […]

Truncate JavaScript string

I have a string in javascript like this: "!ping abrakatabra" i want leave a string like this: "ping" except ! and after string. How can I do this in javascript? Source: JavaSript – Stack Overflow

Display all Guild names and Ids my Bot is already in

i have this code but it only put the Guild in the File when my Bot join a Guild and delete the Guilds in the file when the Bot restart. What i want is that all guilds my Bot is in are listed in this File (guilds.json) and when i restart the Bot the Guilds […]

Play audio from url discord.js v13

How do I play audio from a url with discord.js v13. I used this code and it didn’t work. const connection = joinVoiceChannel({ channelId:, guildId:, adapterCreator: message.guild.voiceAdapterCreator, }) const player = createAudioPlayer() connection.subscribe(player) const resource = createAudioResource(``) Source: JavaSript – Stack Overflow

Cannot find module ‘Discord’

Im still a beginner at coding and have been trying to run a basic bot on discord. As Ive noticed, some things about js have been changed and cant find any updated tutorial. Now that intents are required I cant seem to find a way to get the bot online without getting the error "Cannot […]

Error: No such file or directory, scandir ‘./client.commands/’, while creating Discord bot

Error: ENOENT: no such file or directory, scandir ‘./client.commands/’ const Discord = require(‘discord.js’); const client = new Discord.Client(); const prefix = ‘=’; const fs = require(‘fs’); const { disconnect } = require(‘process’); const memberCounter = require (‘./counters/member-counter.js’); client.commands = new Discord.Collection(); = new Discord.Collection(); [‘command_handlers’, ‘events_handlers’].forEach(handler =>{ require(`./handlers/${handler}`)(client,Discord); }) client.login(”); Source: JavaSript – Stack […]

How to make a schedule command?

Basically it’s like a schedule command. I am using node-schedule to schedule messages in my Discord bot. const schedule = require(‘node-schedule’); const rule = new schedule.RecurrenceRule(); rule.hour = 10; rule.minute = 30; = ‘Etc/UTC’; const job = schedule.scheduleJob(rule, function(){ <Channel>.send(`Defined message`) }); The time is defined within code here. But how can make it […]

Discord bot crashes when i try to an image to embed with an if statement

I’m making a message logger, this is the code: client.on(‘messageDelete’, (messageDelete) => { const deletedContent = `${messageDelete.content}` const attachment = messageDelete.attachments.first() const deletionEmbed = new Discord.MessageEmbed() .setColor(‘RANDOM’) .setAuthor(`A message was deleted, content here:`) .setDescription(deletedContent) .addFields( { name: "Server:", value: `${}` }, { name: "Channel:", value: `#${}` }, { name: "Deleted by:", value: `${}`}, ) .setTimestamp() […]

How to loop a sound in Discord JS 13

Discord JS got updated to version 13 and the whole voice library has changed. Since the release is relatively fresh code examples are rare. I cannot figure out how to loop a sound correctly. How do you do that in DiscordJS 13? Source: JavaSript – Stack Overflow

discord buttons "Class extends value undefined is not a constructor or null"

I tried to make a button. But when I wrote everything, I found that there was an error in the startup. I don’t know why this is at all I checked many related questions online, but none of my problems were solved, and I even became even more confused. this is my code const config […]

Error using discord-buttons: "Class extends value undefined is not a constructor or null"

I tried to make a button in Discord.js. However, when I wrote the code, I found that there was an error during startup. I don’t know why this error is happening. I checked many related questions online, but none of my problems were solved, and I even became even more confused. This is my code: […]

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.