Discord bot

Status
This thread has been locked.

casket

Deactivated
Feedback score
32
Posts
565
Reactions
574
Resources
0
How much would a discord bot go for that can unban everyone in your server I need one so lmk
 
Type
Requesting
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

CerealKillahh

Feedback score
2
Posts
43
Reactions
7
Resources
0
It’s really simple, I can make it for free but I don’t have access to my computer until tonight.
 

Ty

Supreme
Feedback score
28
Posts
790
Reactions
497
Resources
2
Code:
const Discord = require ("discord.js");
const bot = new Discord.Client({disableEveryone: true});

let prefix = "-"

bot.on("ready", async () => {
  console.log(`${bot.user.username} is now online!`)
});

bot.on("message", async message => {
    if(message.author.bot || message.channel.type === "dm") return;

    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);

    if(cmd === `${prefix}unbanall`) {

    let bannedList = await message.guild.fetchBans();
    let bannedUsers = bannedList.map(user => message.guild.unban(user))
    message.channel.send("UNBANNED ALL") // Set this to anything, just placeholder text
    }
})

bot.login("TOKEN");

I didn't get a chance to test it fully but tested it with one user banned and it worked, not sure if there's an easier way or more efficient way to do it but if it works then all good lol

if you don't know how to use just download node.js, make a file called index.js or app.js, put your bots token at the bottom and then open command prompt at the same location as your file, do npm install discord.js then node index.js or node app.js
 
Last edited:

Dorian349

Discord Bot Developer
Supreme
Feedback score
27
Posts
137
Reactions
134
Resources
3
Code:
const Discord = require ("discord.js");
const bot = new Discord.Client({disableEveryone: true});

let prefix = "-"

bot.on("ready", async () => {
  console.log(`${bot.user.username} is now online!`)
});

bot.on("message", async message => {
    if(message.author.bot || message.channel.type === "dm") return;

    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);

    if(cmd === `${prefix}unbanall`) {

    let bannedList = await message.guild.fetchBans();
    let bannedUsers = bannedList.map(user => message.guild.unban(user))
    message.channel.send("UNBANNED ALL") // Set this to anything, just placeholder text
    }
})

bot.login("TOKEN");

I didn't get a chance to test it fully but tested it with one user banned and it worked, not sure if there's an easier way or more efficient way to do it but if it works then all good lol

if you don't know how to use just download node.js, make a file called index.js or app.js, put your bots token at the bottom and then open command prompt at the same location as your file, do npm install discord.js then node index.js or node app.js
Maybe add an async function to handle ratelimit?
 

Ty

Supreme
Feedback score
28
Posts
790
Reactions
497
Resources
2
Maybe add an async function to handle ratelimit?
If I wasn't on holiday & on my phone I'd add some more, feel free to copy and add to it if you see a better fit, I'm still pretty newbie at this stuff to be truthful, lol. :)
 

Dorian349

Discord Bot Developer
Supreme
Feedback score
27
Posts
137
Reactions
134
Resources
3
Code:
const Discord = require ("discord.js");
const bot = new Discord.Client({disableEveryone: true});

let prefix = "-";

bot.on("ready", async () => {
  console.log(`${bot.user.username} is now online!`)
});

bot.on("message", async message => {
    if(message.author.bot || message.channel.type === "dm") return;

    let messageArray = message.content.split(" ");
    let cmd = messageArray[0];
    let args = messageArray.slice(1);

    if(cmd === `${prefix}unbanall`) {

    let bannedList = await message.guild.fetchBans();
    let bannedUsers = bannedList.map(async user => await message.guild.unban(user))
    message.channel.send("All users have been unbanned.") // Set this to anything, just placeholder text
    }
})

bot.login("Your bot token");
Just that, you code is correct ^^ (I tried it)
 
Status
This thread has been locked.
Top