[Solved] Giving multiple prompts over DM’s

You CAN use message collectors. However, you need to have it in a variable. Here is an example: msg.author.send(‘some prompt’).then(m => { let i = 0; var collector = m.channel.createMessageCollector(me => me.author.id === msg.author.id && me.channel === m.channel, {max: /*some number*/}) collector.on(‘collect’, collected => { if(collected.content === ‘end’) return collector.stop(); //basically if you want to … Read more

[Solved] Custom status with guild number [closed]

Alright, I am using this in my bot too: here is the code //… client.on(‘ready’, () => { //… client.user.setActivity(‘othertext’ + client.guilds.cache.size, {type : ‘PLAYING’}) } client.on(‘guildCreate’, guild => { //same code as ‘ready’ }) client.on(‘guildDelete’, guild => { //also the same code as ‘ready’ }) Now this was from my human memory but this … Read more

[Solved] How do you give a user a role by role ID in Discord.JS V13 (latest)

You can do this something like same thing with getting member.id. const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) You can create the code similar to this. const role = message.mentions.roles.first() || message.guild.roles.cache.get(args[0]) Now you can adjust your code file: const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) const role = message.mentions.roles.first() || message.guild.roles.cache.get(args[1]) member.roles.add(role) //To add the mentioned … Read more

[Solved] Coin flip command

if(command == “ht”) { function doRandHT() { var rand = [‘HEADS!’,’TAILS!’]; return rand[Math.floor(Math.random()*rand.length)]; } const embed = { “title”: `Here is the winner!`, “description”: doRandHT(), “color”: 7584788, }; message.channel.send({ embed }); }; You can use this plain command for every random command in Discord.js I also integrated this with embed design so it will come … Read more

[Solved] SyntaxError: Unexpected token ‘const’ [closed]

You are saying if(!Events.includes(event.name)) const L = file.split(“/”); Which doesn’t make sense because const is block scoped. You forgot {} if (event.name) { if(!Events.includes(event.name)) { const L = file.split(“/”); return Table.addRow(`${event.name || “MISSING”}`, `⛔ Event name is either invalid or missing ${L[6] + `/` + L[7]}`); } } solved SyntaxError: Unexpected token ‘const’ [closed]

[Solved] How to make a Discord bot delete its own message from a DM? (Discord.js)

Here, ‘recipient’ is the person you are sending a message to: recipient.send(“This is sent to your dm!”).then(m => { m.delete(10000) //Deletes the message after 10000 milliseconds (10 seconds) } Next time, try and do a little research first. You can also read the docs for discord.js which likely do have this issue. solved How to … Read more

[Solved] How to add “reason” thing to ban command

Simply use member.ban(‘reason here’). Use an object if you need to delete previous messages and supply a reason, like so: member.ban({days: 2, reason: ‘bad’}); Now, just use this setup with the user’s reason. Use a variable for the reason as a sliced version of the arguments array, joined with spaces. Edit: Showing context… if (message.content.toLowerCase().startsWith(‘+ban’)) … Read more

[Solved] Display all Guild Names of a Bot in discord.js

guilds.json { Placeholder: null } The above is the file with the guild IDs const fs = require(‘fs’); const Discord = require(‘discord.js’); const client = new Discord.Client(); client.on(‘ready’, () => { let guilds = client.guilds.cache const json = {} guilds.forEach(g => { json[g.name] = g.id }); fs.writeFileSync(‘./guilds.json’, JSON.stringify(json)) }); client.on(‘guildCreate’, guild => { const file … Read more

[Solved] How to tag users using Discord.JS?

You have two options. You can either use the toString method on the User object, or form the mention yourself using the user’s ID. Here’s an example using toString: client.on(“message”, => { const channel = message.channel; channel.send(message.author.toString()); }); And here’s an example using the ID client.on(“message”, => { const channel = message.channel; channel.send(“<@” + message.author.id … Read more