I’m making a discord bot and I was wondering if you can create a .js file with it. I haven’t found a way to do it. My command reacts to &createfile {name} and it will always create a .js file. My code so far: Answer Simply use the built-in fs module. It is built into node, so it doesn’t need
Tag: discord.js
member cannot be mentioned in the embed discord.js v13
I was making a join and leave log system that returns a specific embed when someone joins/leaves the server. but when the bot sends the embed in the channel, the member is not mentioned. My code: Notes: No one can see the channel that I am sending this embed to, just me and the bot I am using discord.js v13
How can I list all the records to see if they are duplicated?
I have a problem that I cannot resolve. I have a table in MongoDB, and this is structure: I need to list all names from the table (shopData.name) and then check if the typed name exists in the database. I tried to do something like the one below, but it doesn’t work. Could someone take a look at this and
How to filter the member counter in discord.js v13
I made a member counting system for my server but it counts every member that is joined. I want to filter the counter to just count the humans/users My code: I am using discord.js v13 and node.js v16 Answer You can just filter through all the members in a server and remove all the members which are bots by checking
TypeError: Cannot read properties of undefined (reading ‘set’) discord.js v13 slash commands handler
I am creating a Slash commands handler when i run the bot i get this error : Mainguild.SlashCommands.set(SlashComanndsArray).then(async (SlashCommand) => { TypeError: Cannot read properties of undefined (reading ‘set’) this is the code : also SlashComanndsArray , SlashCommand are defined and for the SlashCommands is a collection that i created id index.js with client.SlashCommands = new Collection(); the full code
How do I fetch Weather’s API ‘forecastday’ using axios?
I use WeatherAPI’s service, which returns the weather forecast given the city name The URL looks like this https://api.weatherapi.com/v1/forecast.json?key=[API_KEY]&q=tokyo&aqi=no After trying to paste that URL into my browser and pasting the result into a JSON beautifier, here’s the result Here’s the weird part. I tried using axios to fetch the information from my app and printing it out, this is
sending info from api to discord in a message (discord.js)
Hey i have a question about how to send data over to a message in discord.js. The code that im using now is kinda working. Its just giving me the response [Object Object] Answer the respone.data is not a object. That’s why i’m getting [object, object] So the solution is let datachuck = response.data.value
My bot is collecting it’s own message (infinite loop) and spamming an specific line
the bot spams the (`You Found ${earnings} Coins!`); and I think it’s collecting it’s own messages (infinite loop) I asked the problem from some of my friends and they said the same: “the bot is collecting it’s own messages, remove the collector”. but I don’t know how can I replace the collector. Answer In discord.js v13 all Collector related classes
Trying to setup a new welcome.js
Whenever a user joins, it failes. It worked on the last server but not now? Any help or indication that something is wrong would be much appreciated. I am new to this so sorry if bad Answer So there are a couple things wrong here. First you have 2 “clients” defined Then your code reads as follow Try this and
How to create a slash command with spacing in the name?
I’ve seen some bots that have space in the name of their slash commands, ex: /admin ban But when I try to implement it, I get an error saying that the name of the slash command does not match a validation regex. My code: Error: Answer These are called subcommands. They are a good way to sort commands. For example,