[Solved] Giving multiple prompts over DM’s

[ad_1] 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 … Read more

[Solved] Custom status with guild number [closed]

[ad_1] 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 … Read more

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

[ad_1] 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 … Read more

[Solved] Coin flip command

[ad_1] 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 … Read more

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

[ad_1] 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]}`); } } [ad_2] solved SyntaxError: Unexpected token ‘const’ … Read more

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

[ad_1] 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. [ad_2] solved … Read more

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

[ad_1] 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 … Read more

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

[ad_1] 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(“<@” + … Read more