Questions tagged [discord.js]

discord.js, a powerful Node.js module, empowers developers to engage with the dynamic Discord API. If you seek assistance on utilizing discord.js specifically, this tag is your designated hub. Please note that for questions pertaining to the broader spectrum of Discord API or general inquiries about Discord itself, kindly make use of the 'discord' tag instead. Additionally, don't forget to enrich your query by incorporating both the 'javascript' and 'node.js' tags for comprehensive support.

Embed message from a Discord Bot

Is it possible to include an image of a bot on the right side of the embedded message? if (message.includes('help')) { msg.channel.send({ embed: { title: "xxxxxx", color: 3447003, description:"Enter **agjgj** to know ...

I am interested in creating a Discord bot that can send interval messages

I am trying to set up a discord bot that sends a message at regular intervals, like every 10 minutes. However, I keep running into an error. Can someone please assist me with this issue? (Apologies for any language errors in my message) Below is the code ...

DiscordJS is throwing a TS2339 error stating that the property 'forEach' is not found on the type 'Collection<string, GuildMember>'

Upon attempting to utilize the code provided, I encountered the error messages Property 'forEach' does not exist on type 'Collection<string, GuildMember> and Property 'size' does not exist on type 'Collection<string, GuildMember> import { Messa ...

Role reactions in Discord.js are a useful feature that allows users

Whenever this code is executed, an error message is displayed. The bot has full administrative privileges over the server where I am testing it. client.on('messageReactionAdd', async (reaction, user) => { if (reaction.message.partial); awa ...

Retrieve an object using a variable

Essentially, my question is how to extract a value from a variable and input it into a sequence. Being Dutch, I struggle to articulate this query correctly. var channelname = msg.channel.name; "description": `${config.ticketlist.channelname.ticketmessage} ...

Tips for correctly mentioning a user while using message.channel.send in discord.js

Looking for guidance on tagging a user properly using message.channel.send in discord.js? Here's the code I'm currently working with: function replaceAll(str, find, replacer) { return str.replace(new RegExp(find, 'g'), replacer) ...

You cannot use voice_channel.join() to create a music bot in discord.js v13

As I was working on a new music command feature for my Discord bot, I encountered an issue. Whenever I try to use the command -play {url}, I keep getting an error message that says: voice_channel.join is not a function. I searched through various resource ...

Create a discord.js bot that can randomly select and send a picture from a collection of images stored on my computer

I'm currently working on a bot that sends random pictures from an array of images stored on my computer. However, I encountered an issue when trying to embed the image, resulting in the following error message: C:Users47920DesktopDiscord Bot ode_modul ...

Node script causing occasional corruption in JSON file

I am currently developing a Discord bot that pairs up two individuals for a game. This process involves storing their Discord ID, queue status, and opponent in a JSON file. Here is an example of how the data is structured for each user: { "discordId": ...

An elusive melody that plays only when I execute the play command

I am currently working on creating a music Discord bot using the yt-search library, however, I am encountering an issue where it returns undefined when trying to play a song and joins the voice channel without actually playing anything. My approach is to u ...

Retrieve all direct message channels in Discord using DiscordJS

I need to retrieve all communication channels and messages sent by a bot. The goal is to access all available channels, including direct message (DM) channels. However, the current method seems to only fetch guild channels. client.channels.cache.entries() ...

Implementing a Discord.js Ban Function

Hey everyone, I'm new to this forum and looking for some help. I am currently working on a ban command for my Discord bot in discord.js, and I was wondering how I can make it so that if no reason is specified, it will use "unspecified reason" and still ban ...

Is it possible to identify images within a message sent by users to the server and provide a response accordingly

Apologies for my not-so-great English I am currently learning JavaScript and I am trying to detect an image in a message sent by users from the server, and reply with that image embedded in a bot message. However, message.content is not working for this p ...

How can I request a discord bot to perform a task from a different application?

Currently, my discord.js bot is up and running on a node server. I am looking to have it perform various actions (beyond just sending messages) in response to events occurring in another application that may not necessarily be on the same server. I am won ...

Is it possible for node.js to execute promises without needing to await their fulfillment?

When I visit the Discord tag, I enjoy solving questions that come my way. While I am quite proficient in Python, my skills in Javascript are just about average. However, I do try my hand at it from time to time. The Discord.py library consists of several ...

What is the best way to incorporate messages across various channels with a Discord bot?

While browsing through the questions of other users, I stumbled upon exactly what I was looking for. My dilemma now is how to make the same bot perform similar tasks on various channels but with different titles, footers, and so on... The primary code sni ...

Can we program a system that automatically deletes messages that do not include the text "ew"?

Currently developing a basic server with a unique feature - responding with "ew" in the chat. Is there a way to automatically delete any message that does not include the word "ew"? Appreciate your help! ...

Is there a method for enabling GPT-3's "davinci" to engage in conversation with users via a bot on Discord by utilizing discord.js?

var collector = new MessageCollector(message.channel, filter, { max: 10, time: 60000, }) start_sequence = "\nAI: " retart_sequence = "\nHuman: " collector.on("collect", (msg) => { ...

Error: Access Denied - discord.js bot command cannot be executed due to lack of authorization

Every time I initiate the bot and try to execute my "ping" command, an error occurs: js:350 throw new DiscordAPIError(data, res.status, request); ^ DiscordAPIError: Missing Access at RequestHandler.execute (C: ...

What is the best way to update the value of a specific key in discord.js?

As I struggle to explain properly due to my limited English proficiency, I am reiterating my question. In my config.json file, there is a key named "status" with a corresponding value of "online". I am attempting to change this value but haven't been succe ...

What is the best way to organize the arguments that have not yet been grouped together?

Is there a way to include a custom kick message along with the reason specified in the kick command? I want to ensure that the argument after mentioning the user is grouped correctly, especially for users with spaces in their names. How can I achieve thi ...

Using discord.js to conveniently set up a guild along with channels that are equipped with custom

When Discord devs introduced this feature, I can't seem to wrap my head around how they intended Discord.GuildManager#create to function. How could they possibly have expected it to work with Discord.GuildCreateOptions#channels[0], for instance, { name ...

Is it possible to retrieve the createdAt timestamp without displaying the 'GMT+0000 (Coordinated Universal Time)'?

After conducting an extensive search, I have yet to find a satisfactory answer. My goal is to configure it without including the CUT time. {name: "Registered:", value: `${user.createdAt}`}, {name: "Joined:", value: `${message.guild.joinedAt}`} Presently, ...

Choose Status Menu DiscordJS version 14

Is there a way to get help with changing the bot's status if it's not working properly? The value of the variable "statuses" is set as status, but the status itself does not change. Using client.user.setStatus('dnd'); can sometimes work, but in this partic ...

The program is requesting an expression involving the user's username

https://i.stack.imgur.com/tf1QD.png What is causing the issue with trying to use user.username? as an expression? While user.username returns a string of the User's username, I am unable to index it into listOfPlayers[]. client.on("messageReactionAdd ...

Issues with arguments not being identified - Discord.js version 14

After discovering that my arguments are no longer being recognized when executing a command, I encountered a strange issue. When args are not included, my console logs undefined, but if args are added, nothing is logged. This is snippet of my command hand ...

Issues with Rock Paper Scissors Array in Discord.js V12 not functioning as expected

I'm currently working on implementing an RPS game in my Discord bot. I want to create a feature where if the choice made by the user doesn't match any of the options in the list, it will display an error message. Here is the code snippet that I h ...

Reaching out to a particular individual with a message

In my coding dilemma, I am trying to make a bot send a message every minute to a particular user, not all users. The struggle is real! guild.members.cache.forEach(member => { setInterval(() => { member.send('hello').catch(error =&g ...

notify a designated channel when ready for launch

I'm currently attempting to figure out how to send a message to a channel when the Discord bot is launched. I've experimented with this code: client.on('message', (message) => { client.on('ready', () => { channel = cli ...

What is the method for configuring my bot to forward all logs to a specific channel?

const logsChannel = message.guild.channels.cache.find(channel => channel.name === 'logs'); I am looking to set up my bot to send log messages for various events, like member join/leave or message deletion, specifically in a channel named 'logs'. Any as ...

Step-by-step guide on creating a Discord bot that automatically responds to all messages sent

Having some trouble with this code. The bot seems to only respond to stickers and pictures that are sent locally, but not text messages. Here is the code snippet: const Discord = require('discord.js'); const bot = new Discord.Client(); const t ...

What steps should I take to incorporate a timer into my bot similar to the timer used by other giveaway bots

I am looking to add a timer to my bot giveaway embed message that continues to update itself even when the bot is offline, without showing that the message was edited. Here's what I currently have in my embed: const embed = new MessageEmbed(); ...

Extract website addresses from a text and store them in an array

I am currently attempting to extract URLs from a string and store them in an array. I have implemented a node module to assist with this task. const getUrls = require("get-urls") url = getUrls(message.content) However, the current implementation fails to ...

Discovering the number of individuals assigned to a specific role with discord.js

I am interested in determining the number of members with a specific role in my server. My approach involves using the following code snippet: const bots = guild.roles.cache.find(role => role.name == "Bots"); console.log(bots.members.cache.siz ...

Encountering Issues with Discord JS as Member Fetch Returns Undefined

I'm facing an issue with fetching specific server members by their user id in order to assign a role to them. I keep getting an undefined response each time. Even though this bot has administrator permission and all required intents are assigned, I a ...

Encountering Permissions Issue with .send() in discord.js

I'm facing a challenge with a loop, struggling to find a way to verify if my BOT is authorized to send messages in a particular channel. The code I currently have is as follows: if (msg.guild.me.hasPermission('SEND_MESSAGES')){ msg.channel.send('hello!' ...

Utilizing Discord.js to enable a command for a particular channel

Running a Discord.js bot and struggling to figure out how to restrict the command! help to only the #commands channel. Already have the channel ID, so what steps should be taken in the command event to achieve this? Appreciate any guidance! ...

Acquire Category Permissions when making a channel in discord.js v14

I am in the process of setting up a channel that will grant specific roles access while automatically blocking out @everyone. I also want this setup to be compatible with categories, allowing for other roles to have permissions within them. let customPermi ...

Encountering problems while trying to run a discord.js v14.3.0 bot on a virtual private server

I just set up a VPS to host my discord.js bot, but I keep encountering errors when checking the logs from PM2 [pm2 log], causing the bot to go offline and encounter errors. I'm puzzled because the template was originally used in a repl.it project where ev ...

I keep running into these pesky errors every time I attempt to install discordjs/opus

Currently, I am in the process of developing a music bot for Discord using Node.js. As part of this project, I need to install @discordjs/opus. However, when attempting to run the command npm install @discordjs/opus, I encounter the following error: https ...

Respond to a recommendation with a response

I've been working on setting up a bot for my Discord server, and I recently added a "marry" command to it. Whenever a user makes an offer, a message announcing the proposal pops up with two reaction options. The first reaction signifies yes, while the sec ...

Extract a value from a json document

Hey there! I'm looking to create an unwhitelist command. When a user is mentioned or their ID is provided, I want it to be removed from the JSON file without checking if the ID exists. Do you have any suggestions on how to accomplish this? Here is my code ...

What is the process for setting up quick.db on my system?

I attempted to add quick.db into my discord.js bot by typing "npm i quick.db" in the console. However, when I tried installing it, I encountered an error message instead. Here is the link to the error: . Can anyone advise me on how to resolve this issue? ...

How can I retrieve the word that comes after a specific word in discord.js

Currently, I'm attempting to create a bot similar to Dad bot, but I'm struggling with implementing the "Hi __ I'm, Dad" feature. Here's the code snippet that I've put together so far: var imWords = ["i'm", "I'm", "i'M", " ...

What is the best way to retrieve the latest files from a Heroku application?

Having recently migrated my Discord Bot to Heroku, I faced a challenge with retrieving an updated file essential for code updates. I attempted using both the Git clone command and the Heroku slugs:download command with no success in obtaining the necessar ...

InvalidSyntaxError: Client login cannot be completed due to an unexpected end of input. Please

I encountered an issue while trying to create a bot that sends welcome messages for my friend's server. Despite numerous attempts to troubleshoot the problem within my code, I have been unable to resolve it. Any assistance in solving this error would be gr ...

How can I create a script in Discord.js that automatically sends users their information upon joining the server?

I'm currently working on developing a code that automatically sends the user's avatar, username, ID, account creation date, server join date, and status when they join The structure of the code looks something like this: module.exports = (Discord, client, ...

What is the best way to locate a member using a particular nickname?

Is there a way to search for a user by their unique nickname within a particular server? ...

Error: Unable to access 'createInvite' property from undefined variable

Having trouble generating an invite to one of my guild's channels. Here is the code snippet I am using: const { Client } = require("discord.js"); const client = new Client({ intents: [] }); client.on("ready", async () => { cons ...

The Discord.js command outright declines to function

I'm having trouble with a code that I'm working on. The goal is to create a command that is enabled by default, but once a user uses it, it should be disabled for that user. However, when I try to execute the code, it doesn't work at all and no error messa ...

Oops! RangeError [MESSAGE_CONTENT_TYPE]: The content of the message must be a string that contains at least one character

Can someone help me troubleshoot my regular send command? I keep encountering an error message even after following suggestions from previous answers. Here is the error: RangeError [MESSAGE_CONTENT_TYPE]: Message content must be a non-empty string. at ...

Retrieving all users in Sqlite database with a specific value

I am looking to identify and access each user who has a specific value in their row. Here is an example code snippet of what I want: sql.prepare("SELECT * FROM raid WHERE raid1 > 0 AND NOT id='685337576810610734'").get().forEach(async (user) => { ...

Having difficulty capturing an error related to an invalid form body in discord.js

I built a command to send an embed based on JSON data, and it's working well for the most part. When I input the data correctly, the bot sends it to the channel as expected. However, if someone tries to insert text in a link section, it crashes the bot. I ...

How can one ensure that Discord waits for a script to complete running, and how can you prevent Discord from responding until all necessary data has been obtained?

I recently started working with node.js and asynchronous programming, and I'm facing a challenge that has me puzzled. My goal is to create a Discord bot that fetches data from a third-party website. While I can successfully retrieve the data and see i ...

Improving the efficiency of checking roles in Discord.js

Currently in the process of developing a Discord verification bot which includes the functionality of verifying if a user has at least one role from each required category, and then generating a summary of their roles. The existing solution I have works ...

A Comprehensive Guide: Obtaining the Final Tab from a JSON using API

What is the method to extract the last tab from a given JSON code? { "claimed_levels": { "level_1", "level_2" } } I want to display the level when someone types "!levels". The desired output format should be: Your current level is "2" ...

Error: guild is not defined | discord.js

Having trouble with a ReferenceError that says guild is not defined? I recently encountered a similar issue with members but managed to fix it by adding a constant. As someone new to javascript and node.js, I could use some assistance. I've even tried ...

Is there a way for me to divide the data in a JSON file and display user tags in place of their IDs?

Looking to create a list admins command for a bot, I'm facing challenges in converting user ids to tags within the command. Take a look at what I have accomplished so far: const { MessageEmbed } = require('discord.js'); const { readFileSync, existsSync } = ...

What could be causing errors with my kick command?

Hey everyone, I'm currently working on implementing some admin commands. Right now, I'm focusing on creating a kick command, but I keep running into errors. Making any changes seems to cause issues in other parts of the code. This is where I&apo ...

What steps should I take to program my bot to identify a specific reaction and automatically send a message in response?

Currently, I'm working on implementing a help command that utilizes reactions. The idea is that the bot will add a reaction, prompting the user to react, and once they do, the corresponding help message will be displayed. However, I've hit a road ...

Issue with installing discord.js package using npm in Discord JS

C:UsersPCDocumentsot> npm install discord.js npm WARN tar EPERM: operation not permitted, open 'C:UsersPCDocumentsot ode_modules.stagingsetimmediate-ba27c7e7LICENSE.txt' npm WARN tar EPERM: operation not permitted, open ' ...

Having trouble with Discord.js version 12 and the messageReactionAdd event not triggering properly?

client.on('messageReactionAdd', (reaction, user) => { console.log('If you see this I actually work...'); }); I am having some trouble with my code. Despite setting up a simple console log, it seems like the code is not running properly. I even tried us ...

How to modify a variable in the Config.json using a Discord.js command

Lately, I enhanced my bot's functionality by allowing it to retrieve the color for embeds from a file specified in my config.json. All I need to do is modify something like: "embedcolor": "00A950" to "embedcolor": "0 ...

Discord JS Leaderboards for the Win!

I am currently storing XP data in a JSON file for practice purposes. How can I efficiently display the top 10 users? Initially, I considered sorting the data but I'm unsure of the most efficient approach. let xpAdd = Math.floor(Math.random() * 9) + 8; ...

Importing modules using relative paths results in failure due to module not being found, whereas employing absolute paths

I have been encountering this problem for a considerable amount of time and have made multiple attempts to resolve it. I am currently working on the development of my discord.js bot and recently switched from TS back to JS due to certain complications I fa ...

What is the best way to gather user input and incorporate it into a selected template, ensuring it is verified before sending?

I'm in the process of developing a project that involves gathering user input through a collector and displaying it on my template for verification before sending it out. The format I'm aiming for can be seen here: This is the template format I ...

Is there a way to include various reactions at once?

I've been searching everywhere for solutions but I'm stuck on this issue. Here's the scenario I'm dealing with: I need my bot to execute a command that will send an embed to a specific channel accessible only by admins. Done. Following that, the bot ...

Tips for setting a new key and value for an existing object in TypeScript

As I transition from JavaScript to TypeScript, I am currently working on creating a Discord bot using TypeScript to familiarize myself with the environment. However, I encountered an error when attempting to add new keys to an object that was previously cr ...

Remove any words that are not included in the specified list

Here is the code snippet to achieve the desired functionality: const { words } = require("../../json/words.json") const args = message.content.split(' ') const wordss = words.filter(m=> m.includes(args)) if(args > 1 || !wordss) { ...

What is the best way to sort through received JSON information?

I am attempting to create a simple command that retrieves information from imgur, locates the images, and then randomly selects which photo to display. The issue I am encountering is my inability to filter the responses based on specific criteria. Below is ...

Bot in discord.js refuses to exit voice channel

I've been struggling to get my bot to leave the voice channel despite trying multiple methods. Here's what I've attempted in the source code: Discord.VoiceConnection.disconnect(); Although this is the current code, I have also tested: message.member.voice ...

Styling Discord with NodeJS

After coding with Python for Discord, I decided to switch to JavaScript for its wider functionality. However, I encountered a formatting issue with a specific line of code while testing out a music bot in JS. The bot was sending an embed message, but I wan ...

Issues arise when attempting to delete messages that have already been retrieved

Having trouble removing messages from a specific user without any success: bot.js client.on("message", (message) => { if (message.content === '$deleteuser') { message.channel.fetchMessages({limit: 10}).then(collec ...

The robot will automatically update its own message after a designated period of time

I am facing an issue with my code where the bot is not updating its message after a specific time period defined by time.milliseconds * 1000. How can I make the bot edit its message after that duration? let timeout = 15000; if (author !== null && ...