Questions tagged [discord]

If you are interested in leveraging the power of the Discord API, this interface is designed to aid in programming bots and other applications for seamless communication on Discord messaging services. Remember to tag the library if you have any inquiries about a specific API wrapper.

Uncontrolled discord bot flooding with messages despite being set to send messages only once every 60 seconds

const Discord = require('discord.js'); const { Client, MessageAttachment } = require('discord.js'); const client = new Discord.Client(); client.once('ready', () => { console.log("Ready!") }) client.on(&apos ...

Utilize Python (specifically with the Pillow library) to remove transparent backgrounds

When using the python module html2image to convert html to an image, I encountered an issue with fixed image size causing the html to break or get cut off, leaving a blank space. Is there a Python-based solution to fix this problem? (I am using chat export ...

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 ...

Access txt files using node.js;

Currently working on developing a Discord bot focused on moderation tasks. I've compiled a list of inappropriate words in a text file and now need assistance with coding in node.js to parse and remove these words from messages within the Discord platform ...

"Unleashing the power of Discord.js: Crafting a dynamic command handler enhanced with collectors for smoother

I'm currently developing a Discord Bot that responds to specific commands. To simplify the process, I was considering implementing a system where the bot asks users for questions, collects their responses, and then provides the appropriate answers bas ...

Error: Attempting to create a Discord bot results in a TypeError because the property 'id' is undefined

While working on a basic Discord bot, I encountered an issue when running the -setcaps command. The error message I received was: TypeError: Cannot read property 'id' of undefined. I'm unsure about what might be causing this error. Any a ...

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 && ...

The Discord Oauth2 API query parameter is returning as empty

While integrating Discord OAuth2 into my Next.js application, I encountered an issue when deploying to Amplify. The functionality works smoothly on localhost but fails in production. On the profile page, there is a setup for users to link their Discord acc ...

Error encountered while attempting to load token from file in the Discord.py event loop closing phase

As a precautionary measure, I've decided to keep my token in a separate file named token.txt. To load the token from the file and run the bot, I'm using the following code: f = open("token.txt", "r") token = f.readline() f.close() bot.r ...

Error: When trying to initialize, an unexpected { token was encountered

Issue: While updating my Node.js version, I inadvertently broke my Node.js program. The problem is that I can't recall the previous Node.js version that was working fine before this happened. Error: When I try to run my program using node app.js, ...

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! ...

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 ...

I'm having trouble using Discord.js to set up a custom role with specialized permissions for muting users

module.exports = { name: "mute", description: "This command is used to mute members in a server", execute: async function (msg, arg) { const muteRole = await msg.guild.roles.cache.find((r) => r.name == "Mute ...

Is that file or directory non-existent?

While working on developing a Discord bot, I keep encountering an error message stating: "Line 23: no such file or directory, open 'C:\Users\Owner\Desktop\Limited Bot\Items\Valkyrie_Helm.json']" even though the filep ...

Tips for setting up a scheduled event on your Discord server using Node.js

Hello fellow programmers! Recently, I've been working on a Discord bot using discordjs sdk. I'm trying to implement a feature where the bot creates an event every week. I went through the discordjs guide and checked the discord api documentati ...

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 ...

I have programmed my Python discord bot to interact and respond to commands through direct messages

After dedicating two weeks to developing a discord bot, I recently discovered that commands can be activated in direct messages. I'm concerned that this could potentially enable users with lower roles to interfere with other servers. Does anyone have ...

Automated algorithm inspecting a variety of hyperlinks

Recently, I've developed an innovative anti-invite feature for my bot. However, there seems to be a minor glitch where the bot fails to remove any links sent within the enabled guild when the command is triggered. This issue specifically occurs in versio ...

Error in code - message gets sent immediately instead of waiting for timeout to occur

There seems to be an issue with the code where the message is sent instantly instead of waiting for the specified timeout duration. Based on the code, it should wait for the time mentioned in the message. I'm puzzled as to why it's not functioni ...

I encountered an error in my discord.py main.py code, where a 'NoneType' object does not have the attribute 'send'

Every time I attempt to utilize the channel.send() function in discord.py to send a message, I encounter an error stating "'NoneType' object has no attribute 'send'. Can someone please offer assistance? The issue stems from this section of code: channel ...

Receiving and transmitting messages repeatedly in Discord.JS

Currently, I am developing a simple bot. Interestingly, the bot seems to be responding multiple times to a single command. Here is the code snippet: const Discord = require('discord.js'); var bot = new Discord.Client(); const PREFIX = "+"; var fortunes ...

Discord.js version 14 is throwing a TypeError that says it cannot read properties of undefined, specifically 'commands'

Lately, I've been working on a discord.js bot to refresh my JavaScript skills after a long break. I've been following a tutorial on reloading slash commands and events, but I encountered this error: TypeError: Cannot read properties of undefined (reading ' ...

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} ...

Selenium Struggles to Locate an Element

In the process of developing a simple script that selects a random code from your Discord 2FA backup code text file, inserts it into the 2fa box, and submits it during login. The bot can already enter your email and password to log in initially and choose ...

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 ...

Encountering a DiscordAPIError[10062] when attempting to retrieve user points from the database due to an unknown interaction

content: "Congratulations, you have been successfully verified!", ephemeral: true, }); } } else if (interaction.customId === "giverole") { const userPoints = await findUser(interaction.member ...

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 ...

In the discord.js library, the reactionCollector feature does not cease even when the stop() method is invoked

I'm currently developing a bot using discord.js and facing an issue. My objective is to create a reaction collector that collects the reactions of users who want to participate in a tournament when triggered by the command "tournament prepare". Later, when ...

Error: The function "execute" has not been declared

Hey there! I've created a Discord bot that is meant to check the status of a Minecraft server, but I'm encountering an issue with the embed. It's showing this error: UnhandledPromiseRejectionWarning: ReferenceError: execute is not defined. ...

Potential memory leak detected in EventEmitter by Discord.js

One night while my bot was running on auto-pilot as I drifted off to sleep, a warning popped up out of the blue: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 guildMembersChunk listeners added to [Client]. Use emitter.setMaxLi ...

Encountering a 'DiscordAPIError: Unknown interaction' error while attempting to share details about a command

As I work on a slash command to deliver information about a specific command when users type /help, I encountered an error when trying to add multiple commands: E:\v13\node_modules\discord.js\src\rest\RequestHandler.js:298 ...

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 ...

I'm having trouble getting the play command to work on my Discord bot using Wavelink. Does anyone know how to troubleshoot and fix this

This is the play command for my bot: @client.tree.command(name="play", description="Play some music") @app_commands.describe(musicname="The name of the music you want to play") async def play(interaction:Interaction, musicname ...

The operation to set a nickname in Discord.js was unsuccessful due to insufficient permissions

Recently, I started using discord.js to create a simple bot. Whenever I try to change the nickname by calling message.member.setNickname("Another Nickname").then(console.log, console.log); I receive the following error message: { name: 'Disco ...

"An issue has been noticed with Discord.js and Discordx VoiceStateUpdate where the return

Whenever I attempt to retrieve the user ID, channel, and other information, I receive a response of undefined instead of the actual data import { VoiceState } from "discord.js"; import { Discord, On } from "discordx"; @Discord() export ...

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 ...

My Discord Python Bot Keeps Disrupting My Commands While Running Background Tasks

I've been developing a Python Discord bot that sends scheduled messages in a server at specific times every day, along with other functionalities. However, after implementing the scheduled messaging feature, the bot commands have stopped working - lea ...

Issue: Unable to locate element with the specified selector: #email

const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://discord.com/register'); await page.screenshot({path: 'b.png'}); await page.click(' ...

Every time I attempt to launch my Discord bot, I encounter an error message stating "ReferenceError: client is not defined." This issue is preventing my bot from starting up successfully

My setup includes the following code: const fs = require('fs'); client.commands = a new Discord Collection(); const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js')); for(const file of commandFiles){ const command = re ...

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() ...

JavaScript does not allow executing methods on imported arrays and maps

In my coding project, I created a map named queue in FILE 1. This map was fully built up with values and keys within FILE 1, and then exported to FILE 2 using module.exports.queue = (queue). Here is the code from FILE 1: let queue = new.Map() let key = &q ...

Retrieving inquiries associated with a specific tag on Stack Overflow

I'm part of a team of developers in my Discord community who are dedicated to helping others with their problems on Stack Overflow. Is there a way to create a bot that can automatically gather the latest question tagged with a specific keyword and s ...

Unable to update Discord due to opus installation issue

I recently encountered an issue with my Discord bot that was working perfectly fine yesterday. After attempting to host it on Heroku, I ran into some errors. To find a solution, I followed advice from an online post and executed the command npm cache cle ...

Establish the top-ranking role of a user or the most elevated role within a server

Can anyone help me with setting the highest role of a user? I'm trying to silentban someone by creating a silent role, but it always ends up at the lowest position. Is there a way to make this role the highest one for the user, so that the permissions of t ...

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 ...

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 ...

Bot on Discord using Discord.Js that generates unique invites for users

I'm trying to find a way to generate an invite link for users to keep track of invites. The code I have currently is creating the invite for the Bot instead. const channel = client.channels.cache.find(channel => channel.id === config.server.channel ...

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 ...

Why is it that Next Auth states that the client_id is a required field when using their authentication system, even though in the Discord providers section there is

Each time I attempt to utilize next auth for creating a discord oauth client and subsequently click sign in, an error occurs: https://next-auth.js.org/errors#get_authorization_url_error client_id is required { message: 'client_id is required', ...

Response from a Discord.NET bot for web searches

So I've developed this amazing Discord Bot that provides basic responses. For instance: User Input: !Query status Bot Output: Online! These responses are pretty straightforward, but now I want to take it up a notch and enable the bot to search the web an ...

Having issues with creating a poll command for my Discord bot as it keeps throwing the error message: "Oops! TypeError: Cannot read property 'push' of undefined."

Can anyone assist me with my question? I am using discord v11.5.1 Below is the code: exports.run = async (bot, message) => { const options = [" ...

My issue with express routing not functioning properly across various discord servers

While working on a Discord bot that accesses routes from Express, I encountered an issue. It seems to function properly when kept on a specific server, but if I try accessing Express on a different server while it's running, I encounter the error "assignme ...

Is implementing cogs in Discord.py an ineffective strategy?

When looking to separate my code into different files, I typically create a bash script to concatenate them together like so: cat first.py second.py third.py > run.py python ./run.py However, using cogs requires adding additional code. Is there a speci ...

Error: Your Discord bot is unable to send a message as it is empty. Please check Discord

I have been developing a Discord Bot to verify Roblox accounts. Although my script is prepared and the command "-verify" can be executed, an error arises: (node:22872) DeprecationWarning: The message event is deprecated. Use messageCreate instead (Use `n ...

A simple guide on logging into Discord with token using the Selenium library in Python

I created a Python code using the selenium module to log in to Discord using a token number. The token number needs to be added to localStorage, so I used JavaScript code to add it successfully. However, upon checking Application -> localStorage -> https:/ ...

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 } = ...

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 ...

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! ...

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 ...

Exploring the use of national flag emojis in VS code

I've been attempting to use flag emojis as reactions on a Discord bot, but they just won't cooperate. Every time I try something like this > ':flag_jp:', I encounter the following error: Error: DiscordAPIError: Unknown Emoji EDIT ...

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: ...

Joining Guilds with Discord Oauth2 Integration

const joinUserToServer = fetch(`http://discordapp.com/api/guilds/440494010595803136/members/278628366213709824`, { method: 'PUT', headers: { Authorization: `Bearer TOKEN`, }, ...

Querying a .json document for a specific item and showcasing its price with the help of Discord.js

My current goal is: User inputs !price (item) The bot will look up the item in a JSON file, for example: [ { "hi": 700000, "low": 650000, "name": "football" } ] The bot will then respond with Name: Football High: 6500 ...

Extracting all usernames of members present in a specific voice channel and converting them into a string using Node.js on Discord

Hey everyone, I'm looking for a code snippet that will help me retrieve all the members from a specific voice channel by using its ID. I also need to extract and store the usernames of these members who are currently in that particular voice channel with ...

Is there a way to obtain the specific guild ID from the ready event?

I am currently working on making this bot function across multiple servers, and I need to retrieve a specific guild ID similar to using message.guild.id. However, since there is no message defined or declared, I am unsure of how to achieve this. Any sugges ...

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 ...

Troubleshooting: Potential Reasons Why Registering Slash Commands with Options is Not Functioning Properly in Discord.js

While working on a Discord bot, I encountered an issue while trying to register a slash command with options for the ban command. The error message I received was: throw new DiscordAPIError(data, res.status, request); ^ DiscordAPIError: ...

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 ...

Is there a way to ensure that the echo command doesn't allow tagging @everyone?

Looking for a solution to prevent pinging roles with the echo command? One approach could be to check if the 'content' parameter starts with "@". If it does, you can simply respond with a message indicating that it's not allowed. How would you implement ...

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 ...

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 ...

How can you check the status of a user in a Guild using Discord JS?

Is there a way to retrieve the online status of any user in a guild where the bot is present? Although I can currently access the online status of the message author, I would like to be able to retrieve the online status of any user by using the following ...

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 ...

I'm experiencing some issues with AwaitingReactions in Discord.js, it's not working properly on

I'm having trouble with implementing reaction awaiting as per the guide in discord.js. For some reason, it just doesn't seem to work on my end. No matter what I try, when I click the emoji, it doesn't register. I've scoured numerous Sta ...

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? ...