Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load up the discord.js library
- const Discord = require("discord.js");
- // This is your client. Some people call it `bot`, some people call it `self`,
- // some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
- // this is what we're refering to. Your client.
- const client = new Discord.Client();
- // Here we load the config.json file that contains our token and our prefix values.
- const config = require("./config.json");
- // config.token contains the bot's token
- // config.prefix contains the message prefix
- const weather = require("weather-js");
- const moment = require('moment');
- const fs = require("fs");
- const fsn = require('fs-nextra');
- const cpuStat = require("cpu-stat");
- const express = require('express');
- const keepalive = require('express-glitch-keepalive');
- const app = express();
- app.use(keepalive);
- app.get('/', (req, res) => {
- res.json('This bot should be online! uptimerobot will keep it alive');
- });
- app.get("/", (request, response) => {
- response.sendStatus(200);
- });
- app.listen(process.env.PORT);
- client.on("ready", () => {
- // This event will run if the bot starts, and logs in, successfully.
- console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
- // Example of changing the bot's playing game to something useful. `client.user` is what the
- // docs refer to as the "ClientUser".
- client.user.setPresence({
- game: {
- name: `over ${client.guilds.size} servers!`,
- type: "watching",
- url: "https://www.twitch.tv/monstercat"
- }
- });
- });
- client.on("guildCreate", guild => {
- // This event triggers when the bot joins a guild.
- console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
- client.user.setActivity(`Serving ${client.guilds.size} servers`);
- });
- client.on("guildDelete", guild => {
- // this event triggers when the bot is removed from a guild.
- console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
- client.user.setActivity(`Serving ${client.guilds.size} servers`);
- });
- client.on('guildMemberRemove', function (message) {
- const guild2 = message.guild;
- const member2 = message;
- const membercount2 = client.users.size;
- let logleftmemberembed = new Discord.RichEmbed()
- .setTitle(`A user just left the server! ${member2.user.tag}!`)
- member2.guild.channels.find(`name`, `ใ๐ใlogs`).send(logleftmemberembed)
- member2.guild.channels.find(`name`, `ใโใairport`).send(`:( ${member2.user.tag} just left the server! we will miss you! i also dm'd them!`)
- member2.send(`Awww! You left ${guild2.name}! we hope you join again!`)
- member2.send(`AWww! you left our server!`)
- });
- client.on("guildMemberAdd", function (message) {
- const guild = message.guild;
- const member = message;
- const membercount = client.users.size;
- let lognewmemberembed = new Discord.RichEmbed()
- .setTitle(`A new user has joined the guild. ${member.user.tag}!`)
- member.guild.channels.find(`name`, `ใ๐ใlogs`).send(lognewmemberembed)
- member.guild.channels.find(`name`, `ใโใairport`).send(`Welcome to our server ${member} You are our ${guild.memberCount} member! and you were created on ${member.user.createdAt}`)
- member.send(`Welcome ${member.user} to ${guild.name} we hope you enjoy your time here.`)
- });
- client.on("message", async message => {
- // This event will run on every single message received, from any channel or DM.
- // It's good practice to ignore other bots. This also makes your bot ignore itself
- // and not get into a spam loop (we call that "botception").
- if (message.author.bot) return;
- // Also good practice to ignore any message that does not start with our prefix,
- // which is set in the configuration file.
- if (message.content.indexOf(config.prefix) !== 0) return;
- // Here we separate our "command" name, and our "arguments" for the command.
- // e.g. if we have the message "+say Is this the real life?" , we'll get the following:
- // command = say
- // args = ["Is", "this", "the", "real", "life?"]
- const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- if (command === "say") {
- // makes the bot say something and delete the message. As an example, it's open to anyone to use.
- // To get the "message" itself we join the `args` back into a string with spaces:
- const sayMessage = args.join(" ");
- // Then we delete the command message (sneaky, right?). The catch just ignores the error with a cute smiley thing.
- message.delete().catch(O_o => {});
- // And we get the bot to say the thing:
- message.channel.send(sayMessage);
- }
- if (command === "kill") {
- let killed = message.mentions.members.first();
- if (!killed) return message.channel.send("Please provide a user to kill!")
- ballMessage = message.content.slice(9);
- number = 2;
- var random = Math.floor(Math.random() * (number - 1 + 1)) + 1;
- switch (random) {
- case 1:
- message.channel.send(`${message.author} killed all of ${killed} family members.`)
- break;
- case 2:
- message.reply(`${message.author} used a sharp axe to kill ${killed}`);
- break;
- }
- }
- if (command === "help") {
- const infoList = fs.readFileSync("./info.txt", "utf8");
- let bicon = client.user.displayAvatarURL;
- const pidor = message.guild.members.get(args[0]) || message.member;
- let infoEmbed = new Discord.RichEmbed()
- .setColor("00ff00")
- .setTitle("**__Info commands__**")
- .setDescription(infoList)
- pidor.send(infoEmbed);
- let supEmbed = new Discord.RichEmbed()
- .setColor("#00ff00")
- .setTitle("Support")
- .setImage("https://cdn.discordapp.com/avatars/291221132256870400/4f71fea454b62405b55f2fe0d8e7db0c.png?size=2048")
- .setDescription("If you need help with something feel free to join the [Support Server](https://discord.gg/wJ2ARmw)")
- .setFooter("<> means required, [] means optional")
- .setTimestamp()
- pidor.send(supEmbed)
- let chanEmbed = new Discord.RichEmbed()
- .setTitle("Help")
- .setColor("#0ff00")
- .setFooter(`Help command used by: ${pidor.user.username}`)
- .setDescription(`${pidor} Check your DMs`);
- message.channel.send(chanEmbed).then(msg => {
- msg.delete(5000)
- });
- message.delete();
- }
- if (command === "meme") {
- const randomPuppy = require('random-puppy');
- let reddit = [
- "meme",
- "dankmemes",
- "dankmeme"
- ]
- let subreddit = reddit[Math.floor(Math.random() * reddit.length)];
- message.channel.startTyping();
- randomPuppy(subreddit).then(async url => {
- await message.channel.send({
- files: [{
- attachment: url,
- name: 'meme.png'
- }]
- }).then(() => message.channel.stopTyping());
- }).catch(err => console.error(err));
- };
- if (command === "ticket") {
- const cooldown = new Set();
- let args = message.content.split(' ').slice(1).join(' ');
- message.delete();
- if (cooldown.has(message.author.id && message.guild.id)) {
- return message.channel.send('**[COOLDOWN]** Sending tickets has **5 Minutes** Cooldown!');
- }
- if (args.length < 1) {
- return message.channel.send(`You must give me something to report first ${message.author}`);
- }
- cooldown.add(message.author.id && message.guild.id);
- setTimeout(() => {
- cooldown.delete(message.author.id && message.guild.id);
- }, 300000);
- let guild = message.guild;
- const cnl = message.guild.channels.find(channel => channel.name === "ใ๐ปใstaff-chat");
- message.channel.send(`Hey, ${message.author}, we got your report! We will reply soon as possible! Here is the full ticket:`);
- const embed2 = new Discord.RichEmbed()
- .setAuthor(`Ticket from ${message.author.tag}`, message.author.displayAvatarURL)
- .addField('Ticket:', `**Tickets's Author:** ${message.author.tag}\n**Server:** ${guild.name}\n**Full ticket:** ${args}`)
- .setThumbnail(message.author.displayAvatarURL)
- .setFooter(`${moment().format('MMMM Do YYYY, h:mm:ss a')}`)
- .setColor(16711728);
- message.channel.send({
- embed: embed2
- });
- const embed = new Discord.RichEmbed()
- .setAuthor(`Ticket from ${message.author.tag}`, message.author.displayAvatarURL)
- .addField('Ticket:', `**Report's Author:** ${message.author.tag}\n**Server:** ${guild.name}\n**Full report:** ${args}`)
- .setThumbnail(message.author.displayAvatarURL)
- .setColor("#ffd700");
- cnl.send({
- embed
- })
- }
- if (command === "announce") {
- if (!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- let announcementchannel = message.guild.channels.find(channel => channel.name === "ใ๐ใannouncements");
- let sayMessage = args.join(" ");
- let announcembed = new Discord.RichEmbed()
- .setTitle("Important announcement:")
- .setDescription(sayMessage)
- .setFooter(`announcement made by ${message.author.tag}!`, message.author.displayAvatarURL)
- announcementchannel.send(announcembed)
- message.delete().catch(O_o => {});
- }
- if (command === "stats") {
- let {
- version
- } = require("discord.js");
- cpuStat.usagePercent(function (err, percent, seconds) {
- if (err) {
- return console.log(err);
- }
- let secs = Math.floor(client.uptime % 60);
- let days = Math.floor((client.uptime % 31536000) / 86400);
- let hours = Math.floor((client.uptime / 3600) % 24);
- let mins = Math.floor((client.uptime / 60) % 60);
- //let duration = moment.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
- let embedStats = new Discord.RichEmbed()
- .setTitle("*** Stats ***")
- .setColor("#00ff00")
- .addField("โข Mem Usage", `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} / ${(os.totalmem() / 1024 / 1024).toFixed(2)} MB`, true)
- .addField("โข Uptime ", `${hours}h ${mins}m`, true) //`${duration}`, true)
- .addField("โข Users", `${client.users.size.toLocaleString()}`, true)
- .addField("โข Servers", `${client.guilds.size.toLocaleString()}`, true)
- .addField("โข Channels ", `${client.channels.size.toLocaleString()}`, true)
- .addField("โข Discord.js", `v${version}`, true)
- // .addField("โข Node", `${process.version}`, true)
- .addField("โข CPU", `\`\`\`md\n${os.cpus().map(i => `${i.model}`)[0]}\`\`\``)
- .addField("โข CPU usage", `\`${percent.toFixed(2)}%\``, true)
- .addField("โข Arch", `\`${os.arch()}\``, true)
- .addField("โข Platform", `\`\`${os.platform()}\`\``, true)
- .setFooter("Tom The Bot stats")
- message.channel.send(embedStats)
- })
- }
- if (command === "weather") {
- weather.find({
- search: args.join(" "),
- degreeType: "F"
- }, function (err, result) { // Make sure you got that args.join part
- if (err) message.channel.send(err);
- // We also want them to know if a place they enter is invalid.
- if (result === undefined || result.length === 0) {
- message.channel.send("**Please enter a valid location.**") // This tells them that the location they entered is invalid.
- return; // This exists the code so that the rest doesn't run.
- }
- // Variables
- var current = result[0].current; // This is a varable for the current part of the JSON output.
- var location = result[0].location; // This is a variable for the location part of the JSON output.
- // Let's use an embed for this.
- const embed = new Discord.RichEmbed()
- .setDescription(`**${current.skytext}**`) // This is the text of what they sky looks like.
- .setAuthor(`Weather for ${current.observationpoint}`) // This shows the current location of the weather.
- .setThumbnail(current.imageURL) // This sets the thumbnail of the embed
- .setColor(0x00AE86) // This sets the color of the embed, you can chnage this to whatever you want, if you use a hex editor, make sure to put 0x in front of it.
- .addField('Timezone', `UTC${location.timezone}`, true) // This is the first field, it shows the timezone.
- .addField('Degree Type', location.degreetype, true) // This is the filed that shows the degree type, and its inline.
- .addField('Temperature', `${current.temperature} Degrees`, true)
- .addField('Feels Like', `${current.feelslike} Degrees`, true)
- .addField('Winds', current.winddisplay, true)
- .addField('Humidity', `${current.humidity}%`, true)
- .addField("Date:", message.createdAt.toLocaleString())
- // Now, lets display it when called
- message.channel.send({
- embed
- });
- });
- }
- if (command === "uptime") {
- let totalSeconds = (client.uptime / 1000);
- let days = Math.floor(totalSeconds / 86400);
- let hours = Math.floor(totalSeconds / 3600);
- totalSeconds %= 3600;
- let minutes = Math.floor(totalSeconds / 60);
- let seconds = totalSeconds % 60;
- let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
- message.channel.send(uptime)
- }
- if (command === "8ball") {
- let question = message.content.split(/\s+/g).slice(1).join(" ");
- if (!question) {
- return message.channel.send('You must provide a question! **Usage: !!!8ball <question>**');
- }
- var answer = ['It is certain',
- 'It is decidedly so',
- 'Without a doubt',
- 'Yes, definitely',
- 'You may rely on it',
- 'As I see it, yes',
- 'Most likely',
- 'Outlook good',
- 'Yes',
- 'Signs point to yes',
- 'Reply hazy try again',
- 'Ask again later',
- 'Better not tell you now',
- 'Cannot predict now',
- 'Concentrate and ask again',
- 'Don\'t count on it',
- 'My reply is no',
- 'My sources say no',
- 'Outlook not so good',
- 'Very doubtful'
- ];
- const ballEmbed = new Discord.RichEmbed()
- .setAuthor(question)
- .setDescription(answer[Math.round(Math.random() * (answer.length - 1))] + '.')
- .setColor(0x646770)
- .setTimestamp();
- message.channel.send(ballEmbed);
- }
- if (command === "poll") {
- if (args.length == 0) {
- return message.channel.send({
- embed: {
- "title": "Help",
- "fields": [{
- "name": "Simple Poll (Yes/No)",
- "value": "`poll` - this menu\n`poll <time> <question>` - poll with timed end. Time should be entered in seconds, default - 1 hour"
- },
- {
- "name": "Multi-choice Poll",
- "value": "`mpoll <time> <question> <a1>...<a9>` - poll with multi-choice and timed end. Time should be entered in seconds, default - 1 hour"
- }
- ],
- "color": 3264944,
- "footer": {
- "text": message + ""
- }
- }
- });
- }
- let time1 = args.shift();
- let question = args.join(" ");
- if (!isNaN(time1)) {
- time1 = time1 * 1000;
- } else {
- question = time1 + " " + question;
- time1 = 3600 * 1000;
- }
- message.channel.send({
- embed: {
- "title": `Poll by ${message.author.username}`,
- "description": question + "",
- "color": "3264944",
- "footer": {
- "text": "Poll Created By " + message.author.username,
- "icon_url": message.author.avatarURL
- }
- }
- }).then(async function (msg) {
- await msg.react('๐');
- await msg.react('๐');
- var reactions = await msg.awaitReactions(reaction => reaction.emoji.name === '๐' || reaction.emoji.name === '๐', {
- time: time1
- });
- var yes = "Most voted ๐";
- var no = "Most voted ๐";
- var tie = "Tie!";
- var end;
- if (msg.reactions.get('๐').count - 1 > msg.reactions.get('๐').count - 1) {
- end = yes
- } else if (msg.reactions.get('๐').count - 1 < msg.reactions.get('๐').count - 1) {
- end = no
- } else if (msg.reactions.get('๐').count - 1 == msg.reactions.get('๐').count - 1) {
- end = tie
- }
- msg.channel.send({
- embed: {
- "title": question,
- "description": `**Poll ended!** \n\n๐: ${msg.reactions.get('๐').count-1}\n***----------***\n๐: ${msg.reactions.get('๐').count-1}`,
- "color": 3264944,
- "footer": {
- "text": end
- }
- }
- })
- });
- }
- if (command === "coinflip") {
- let = headembed = new Discord.RichEmbed()
- .setTitle(`${message.author.username}`)
- .setDescription(`heads!`)
- .setFooter(`Tommy bot! | Replying to ${message.author.username}`)
- .setTimestamp()
- let tailsembed = new Discord.RichEmbed()
- .setTitle(`Coinflip`)
- .setDescription(`Tails!`)
- .setFooter(`Tommy bot! | Replying to ${message.author.username}`)
- .setTimestamp()
- ballMessage = message.content.slice(9);
- number = 2;
- var random = Math.floor(Math.random() * (number - 1 + 1)) + 1;
- switch (random) {
- case 1:
- message.channel.send(tailsembed)
- break;
- case 2:
- message.channel.send(headembed)
- break;
- }
- }
- if (command === "rps") {
- let rock2 = ['Paper! I win!', 'Scissors! You win!']
- let rock1 = Math.floor(Math.random() * rock2.length);
- let paper2 = ['Rock! You win!', 'Scissors! I win!']
- let paper1 = Math.floor(Math.random() * paper2.length);
- let scissors2 = ['Rock! I win', 'Paper! You win!']
- let scissors1 = Math.floor(Math.random() * scissors2.length);
- let rock = new Discord.RichEmbed()
- .setAuthor('Rock, Paper, Scissors')
- .setColor(0x6B5858)
- .addField('You choose', `${args[0]}`)
- .addField('I choose', rock2[rock1])
- .setTimestamp()
- let paper = new Discord.RichEmbed()
- .setAuthor('Rock, Paper, Scissors')
- .setColor(0x6B5858)
- .addField('You choose', `${args[0]}`)
- .addField('I choose', paper2[paper1])
- .setTimestamp()
- let scissors = new Discord.RichEmbed()
- .setAuthor('Rock, Paper, Scissors')
- .setColor(0x6B5858)
- .addField('You choose', `${args[0]}`)
- .addField('I choose', scissors2[scissors1])
- .setTimestamp()
- if (message.content === '$rps rock') message.channel.send(rock)
- if (message.content === '$rps Rock') message.channel.send(rock)
- if (message.content === '$rps paper') message.channel.send(paper)
- if (message.content === '$rps Paper') message.channel.send(paper)
- if (message.content === '$rps scissors') message.channel.send(scissors)
- if (message.content === '$rps Scissors') message.channel.send(scissors)
- if (message.content === '$rps') message.channel.send('Options: ``Rock``, ``Paper``, ``Scissors``. **Usage: $rps <option>**')
- }
- if (command === "contact") {
- if (args[0] == "help") {
- let helpembxd = new Discord.RichEmbed()
- .setColor("#00ff00")
- .addField("Contact Command", "Usage: !Contact <reason>")
- message.channel.send(helpembxd);
- return;
- }
- let Invite = await message.guild.channels.find((c) => c.type === 'text').createInvite()
- let Sender = message.author;
- const sayMessage = args.join(" ");
- if (!sayMessage) return message.channel.send("Please give us reason for contacting").then(msg => {
- msg.delete(5000)
- });
- let contact = new Discord.RichEmbed()
- .setColor("00ff00")
- .setThumbnail(Sender.displayAvatarURL)
- .setDescription(`Contact message from [${message.guild.name}](${Invite.url})`)
- .setTitle("Message from contact command!")
- .addField("User", Sender, true)
- .addField("User ID: ", Sender.id, true)
- .addField("Message: ", sayMessage)
- .setTimestamp()
- client.users.get("308589969704747009").send(contact);
- let embed = new Discord.RichEmbed()
- .setColor("#00ff00")
- .setTitle("Message Sent!")
- .setDescription("Your contact message has been sent!")
- .addField("Reqested by ", Sender)
- .addField("Message: ", sayMessage)
- .setFooter("Thanks you for contacting The Bot's Owner! so i can be better!")
- message.channel.send(embed).then(msg => {
- msg.delete(10000)
- });
- message.delete();
- }
- if (command === "spam") {
- if (args.length !== 0) {
- if (message.content.indexOf("@everyone") > -1 || message.content.indexOf("@here") > -1) {
- message.channel.send("No.");
- } else {
- message.channel.send(args.join(" ").repeat(500).substring(0, 500));
- }
- } else {
- message.reply("you need to specify what you want to spam!");
- }
- };
- if (command === "ping") {
- // Calculates ping between sending a message and editing it, giving a nice round-trip latency.
- // The second ping is an average latency between the bot and the websocket server (one-way, not round-trip)
- const m = await message.channel.send("Ping?");
- m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
- }
- if (command === "botinfo") {
- let inline = true
- let bicon = client.user.displayAvatarURL;
- let usersize = client.users.size
- let chansize = client.channels.size
- let uptimxd = client.uptime
- let servsize = client.guilds.size
- let botembed = new Discord.RichEmbed()
- .setColor("#00ff00")
- .setThumbnail(bicon)
- .addField("Bot Name", `${client.user.username}`, inline)
- .addField("Bot Owner", "<@321091504242294784>", inline)
- .addField("Servers", `๐ก ${servsize}`, inline)
- .addField("Channels", `๐ ${chansize}`, inline)
- .addField("Users", `${usersize}`, inline)
- .addField("Bot Library", "Discord.js", inline)
- .addField("Created On", client.user.createdAt)
- .setTimestamp()
- message.channel.send(botembed);
- }
- if (command === "avatar") {
- let msg = await message.channel.send("Generating avatar...");
- let mentionedUser = message.mentions.users.first() || message.author;
- let embed = new Discord.RichEmbed()
- .setImage(mentionedUser.displayAvatarURL)
- .setColor("00ff00")
- .setTitle("Avatar")
- .setFooter("Searched by " + message.author.tag)
- .setDescription("[Avatar URL link](" + mentionedUser.displayAvatarURL + ")");
- message.channel.send(embed)
- message.delete();
- }
- if (command === "userinfo") {
- let inline = true
- let resence = true
- const status = {
- online: "<:online:424890369688469504> Online",
- idle: "<:idle:424890472855502849> Idle",
- dnd: "<:dnd:424890429524410368> Do Not Disturb",
- offline: "<:offilne:424890400319340546> Offline/Invisible"
- }
- const member = message.mentions.members.first() || message.guild.members.get(args[0]) || message.member;
- let target = message.mentions.users.first() || message.author
- if (member.user.bot === true) {
- bot = "<:bottag:425631858265423883> Yes";
- } else {
- bot = "<:user:424958082691629057> No";
- }
- let embed = new Discord.RichEmbed()
- //.setAuthor(member.user.username)
- .setThumbnail((target.displayAvatarURL))
- .setColor("#00ff00")
- .addField("Full Username", `${member.user.tag}`, inline)
- .addField("ID", member.user.id, inline)
- .addField("Nickname", `${member.nickname !== null ? `<425632265993846795> Nickname: ${member.nickname}` : "<:no:425632070036094986> None"}`, true)
- .addField("Bot", `${bot}`, inline, true)
- .addField("Status", `${status[member.user.presence.status]}`, inline, true)
- .addField("Playing", `${member.user.presence.game ? `๐ฎ ${member.user.presence.game.name}` : "<425632070036094986> Not playing"}`, inline, true)
- .addField("Roles", `${member.roles.filter(r => r.id !== message.guild.id).map(roles => `\`${roles.name}\``).join(" **|** ") || "<:no:425632070036094986> No Roles"}`, true)
- .addField("Joined Discord At", member.user.createdAt)
- .setFooter(`Information about ${member.user.username}`)
- .setTimestamp()
- message.channel.send(embed);
- message.delete();
- }
- if (command === "report") {
- message.delete()
- // mentioned or grabbed user
- let target = message.mentions.members.first() || message.guild.members.get(args[0])
- if (!target) return message.channel.send("Please provide a valid user").then(m => m.delete(15000))
- // reasoning definition
- let reason = args.slice(1).join(" ")
- if (!reason) return message.channel.send(`Please provide a reason for reporting **${target.user.tag}**`).then(m => m.delete(15000))
- // grab reports channel
- let sChannel = message.guild.channels.find(x => x.name === "ใ๐ใlogs")
- // send to reports channel and add tick or cross
- message.channel.send("Your report has been filed to the staff team. Thank you!").then(m => m.delete(15000))
- sChannel.send(`**${message.author.tag}** has reported **${target.user.tag}** for **${reason}**.`).then(async msg => {
- await msg.react("โ ")
- await msg.react("โ")
- })
- }
- if (command === "addrole") {
- if (!message.member.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- let rMember = message.mentions.members.first() || message.guild.members.find(m => m.user.tag === args[0]) || message.guild.members.get(args[0])
- if (!rMember) return message.channel.send("Please provide a user to add a role too.")
- let role = message.guild.roles.find(r => r.name == args[1]) || message.guild.roles.find(r => r.id == args[1]) || message.mentions.roles.first()
- if (!role) return message.channel.send("Please provide a role to add to said user.")
- let reason = args.slice(2).join(" ")
- if (!reason) return message.channel.send("Please provide a reason")
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to perform this command.")
- if (rMember.roles.has(role.id)) {
- return message.channel.send(`${rMember.displayName}, already has the role!`)
- } else {
- await rMember.addRole(role.id).catch(e => console.log(e.message))
- message.channel.send(`The role, ${role.name}, has been added to ${rMember.displayName}.`)
- }
- let addroleembed = new RichEmbed()
- .setColor(redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "Addrole")
- .addField("Person who was moderated:", rMember.user.username)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "logs")
- sChannel.send(addroleembed)
- }
- if (command === "removerole") {
- if (!message.member.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- let rMember = message.mentions.members.first() || message.guild.members.find(m => m.user.tag === args[0]) || message.guild.members.get(args[0])
- if (!rMember) return message.channel.send("Please provide a user to remove a role too.")
- let role = message.guild.roles.find(r => r.name == args[1]) || message.guild.roles.find(r => r.id == args[1]) || message.mentions.roles.first()
- if (!role) return message.channel.send("Please provide a role to remove from said user.")
- let reason = args.slice(2).join(" ")
- if (!reason) return message.channel.send("Please provide a reason")
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to perform this command.")
- if (!rMember.roles.has(role.id)) {
- return message.channel.send(`${rMember.displayName}, doesnt have the role!`)
- } else {
- await rMember.removeRole(role.id).catch(e => console.log(e.message))
- message.channel.send(`The role, ${role.name}, has been removed from ${rMember.displayName}.`)
- }
- let removeroleembed = new RichEmbed()
- .setColor(redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "Addrole")
- .addField("Person who was moderated", rMember.user.username)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "logs")
- sChannel.send(removeroleembed)
- }
- if (command === "votekick") {
- const agree = "โ ";
- const disagree = "โ";
- if (message.mentions.users.size === 0){
- return message.reply(":x: " + "| Please Mention A User To Kick Next Time");
- }
- let kickmember = message.guild.member(message.mentions.users.first());
- if(!kickmember){
- message.reply(":x: " + "| That User Does Not Seem Valid!");
- }
- if(!message.guild.member(client.user).hasPermission("KICK_MEMBERS")){
- return message.reply(":x: " + "| i need the \"KICK_MEMBERS\" permission!").catch(console.error);
- }
- let msg = await message.channel.send("Vote now! (10 Seconds)");
- await msg.react(agree);
- await msg.react(disagree);
- const reactions = await msg.awaitReactions(reaction => reaction.emoji.name === agree || reaction.emoji.name === disagree, {time: 10000});
- msg.delete();
- var NO_Count = reactions.get(disagree).count;
- var YES_Count = reactions.get(agree);
- if(YES_Count == undefined){
- var YES_Count = 1;
- }else{
- var YES_Count = reactions.get(agree).count;
- }
- var sumsum = new Discord.RichEmbed()
- .addField("Voting Finished:", "----------------------------------------\n" +
- "Total votes (NO): " + `${NO_Count-1}\n` +
- "Total votes (Yes): " + `${YES_Count-1}\n` +
- "----------------------------------------\n" +
- "NOTE: Votes needed to kick (3+)\n" +
- "----------------------------------------", true)
- .setColor("0x#FF0000")
- await message.channel.send({embed: sumsum});
- if(YES_Count >= 4 && YES_Count > NO_Count){
- kickmember.kick().then(member => {
- message.reply(`${member.user.username} was succesfully kicked`)
- })
- }else{
- message.channel.send("\n" + "SAFE..... FOR NOW");
- }
- }
- if (command === "ban") {
- // Most of this command is identical to kick, except that here we'll only let admins do it.
- // In the real world mods could ban too, but this is just an example, right? ;)
- if (!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- let member = message.mentions.members.first();
- if (!member)
- return message.reply("Please mention a valid member of this server");
- if (!member.bannable)
- return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
- let reason = args.slice(1).join(' ');
- if (!reason) reason = "No reason provided";
- await member.ban(reason)
- .catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
- message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
- }
- if (command === "purge") {
- // This command removes all messages from all users in the channel, up to 100.
- // get the delete count, as an actual number.
- const deleteCount = parseInt(args[0], 10);
- // Ooooh nice, combined conditions. <3
- if (!deleteCount || deleteCount < 2 || deleteCount > 100)
- return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
- // So we get our messages, and delete them. Simple enough, right?
- const fetched = await message.channel.fetchMessages({
- limit: deleteCount
- });
- message.channel.bulkDelete(fetched)
- .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
- }
- if (command === "lockdown") {
- if (!message.member.permissions.has("MANAGE_CHANNELS")) return message.channel.send("Sorry, you do not have permission to perform the antiraid command.");
- if (!message.guild.member(client.user).hasPermission('MANAGE_CHANNELS')) return message.reply('Sorry, i dont have the perms to do this cmd i need MANAGE_CHANNELS. :x:')
- const ms = require('ms');
- if (!client.lockit) client.lockit = [];
- const time = args.join(' ');
- const validUnlocks = ['release', 'unlock', 'stop', 'off'];
- if (!time) return message.reply('You must set a duration for the lockdown in either hours, minutes or seconds');
- if (validUnlocks.includes(time)) {
- message.channel.overwritePermissions(message.guild.id, {
- SEND_MESSAGES: true
- }).then(() => {
- message.channel.send('Lockdown lifted.');
- clearTimeout(client.lockit[message.channel.id]);
- delete client.lockit[message.channel.id];
- }).catch(error => {
- console.log(error);
- });
- } else {
- message.channel.overwritePermissions(message.guild.id, {
- SEND_MESSAGES: false
- }).then(() => {
- message.channel.send(`Channel locked down for ${ms(ms(time), { long:true })}`).then(() => {
- client.lockit[message.channel.id] = setTimeout(() => {
- message.channel.overwritePermissions(message.guild.id, {
- SEND_MESSAGES: true
- }).then(message.channel.send('Lockdown lifted.'))
- delete client.lockit[message.channel.id];
- }, ms(time));
- }).catch(error => {
- console.log(error);
- });
- });
- }
- }
- if (command === "unban") {
- if (!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- if (isNaN(args[0])) return message.channel.send("You need to provide an ID.")
- let bannedMember = await client.fetchUser(args[0])
- if (!bannedMember) return message.channel.send("Please provide a user id to unban someone!")
- let reason = args.slice(1).join(" ")
- if (!reason) reason = "No reason given!"
- if (!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("I dont have permission to perform this command!") |
- message.delete()
- try {
- message.guild.unban(bannedMember, reason)
- message.channel.send(`${bannedMember.tag} has been unbanned from the guild!`)
- } catch (e) {
- console.log(e.message)
- }
- let unbannedembed = new RichEmbed()
- .setColor(redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "unban")
- .addField("Moderated on:", `${bannedMember.username} (${bannedMember.id})`)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "ใ๐ใlogs")
- sChannel.send(unbannedembed)
- }
- if (message.guild && message.content.startsWith('$dmeveryone')) {
- if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('This requires the permission: ADMINISTRATOR');
- let text = message.content.slice('$dmeveryone'.length); // cuts off the /private part
- message.guild.members.forEach(member => {
- if (member.id != client.user.id && !member.user.bot) member.send(text);
- });
- }
- if (command === "kick") {
- // This command must be limited to mods and admins. In this example we just hardcode the role names.
- // Please read on Array.some() to understand this bit:
- // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some?
- if (!message.member.hasPermission("KICK_MEMBERS")) return message.reply("Sorry, you don't have permissions to use this!");
- // Let's first check if we have a member and if we can kick them!
- // message.mentions.members is a collection of people that have been mentioned, as GuildMembers.
- // We can also support getting the member by ID, which would be args[0]
- let member = message.mentions.members.first() || message.guild.members.get(args[0]);
- if (!member)
- return message.reply("Please mention a valid member of this server");
- if (!member.kickable)
- return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
- // slice(1) removes the first part, which here should be the user mention or ID
- // join(' ') takes all the various parts to make it a single string.
- let reason = args.slice(1).join(' ');
- if (!reason) reason = "No reason provided";
- // Now, time for a swift kick in the nuts!
- await member.kick(reason)
- .catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
- message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`)
- }
- if (command === "unmute") {
- if (!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("You dont have permission to use this command.");
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to add roles!")
- //define the reason and unmutee
- let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
- if (!mutee) return message.channel.send("Please supply a user to be muted!");
- let reason = args.slice(1).join(" ");
- if (!reason) reason = "No reason given"
- //define mute role and if the mute role doesnt exist then send a message
- let muterole = message.guild.roles.find(r => r.name === "Muted")
- if (!muterole) return message.channel.send("That user is muted.")
- //remove role to the mentioned user and also send the user a dm explaing where and why they were unmuted
- mutee.removeRole(muterole.id).then(() => {
- message.delete()
- mutee.send(`Hello, you have been unmuted in ${message.guild.name} for: ${reason}`).catch(err => console.log(err))
- message.channel.send(`${mutee.user.username} was unmuted!`)
- })
- //send an embed to the modlogs channel
- let unmuteembed = new RichEmbed()
- .setColor(redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "unmute")
- .addField("Person who was moderated:", mutee.user.username)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "ใ๐ใlogs")
- sChannel.send(unmuteembed)
- }
- if (command === "mute") {
- if (!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("You dont have permission to use this command.");
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to add roles!")
- //define the reason and mutee
- let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
- if (!mutee) return message.channel.send("Please supply a user to be muted!");
- let reason = args.slice(1).join(" ");
- if (!reason) reason = "No reason given"
- //define mute role and if the mute role doesnt exist then create one
- let muterole = message.guild.roles.find(r => r.name === "Muted")
- if (!muterole) {
- try {
- muterole = await message.guild.createRole({
- name: "Muted",
- color: "#514f48",
- permissions: []
- })
- message.guild.channels.forEach(async (channel, id) => {
- await channel.overwritePermissions(muterole, {
- SEND_MESSAGES: false,
- ADD_REACTIONS: false,
- SEND_TTS_MESSAGES: false,
- ATTACH_FILES: false,
- SPEAK: false
- })
- })
- } catch (e) {
- console.log(e.stack);
- }
- }
- //add role to the mentioned user and also send the user a dm explaing where and why they were muted
- mutee.addRole(muterole.id).then(() => {
- message.delete()
- mutee.send(`Hello, you have been muted in ${message.guild.name} for: ${reason}`).catch(err => console.log(err))
- message.channel.send(`${mutee.user.username} was successfully muted.`)
- })
- //send an embed to the modlogs channel
- let muteembed = new RichEmbed()
- .setColor(redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "mute")
- .addField("Person who was moderated:", mutee.user.username)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "ใ๐ใlogs")
- sChannel.send(muteembed)
- }
- if (command === "serverinfo") {
- const verlvl = {
- 0: "None",
- 1: "Low",
- 2: "Medium",
- 3: "(โฏยฐโกยฐ๏ผโฏ๏ธต โปโโป",
- 4: "(ใเฒ ็เฒ )ใๅฝกโปโโป"
- }
- let inline = true
- let sicon = message.guild.iconURL;
- let serverembed = new Discord.RichEmbed()
- .setColor("#00ff00")
- .setThumbnail(sicon)
- .setAuthor(message.guild.name)
- .addField("Name", message.guild.name, inline)
- .addField("ID", message.guild.id, inline)
- .addField("Owner", message.guild.owner, inline)
- .addField("Region", message.guild.region, inline)
- .addField("Verification Level", verlvl[message.guild.verificationLevel], inline)
- .addField("Members", `<:user:424958082691629057> ${message.guild.memberCount}`, inline)
- .addField("Roles", message.guild.roles.size, inline)
- .addField("Channels", message.guild.channels.size, inline)
- .addField("You Joined", message.member.joinedAt)
- .setFooter(`Created ${message.guild.createdAt}`);
- message.channel.send(serverembed);
- message.delete();
- }
- if (command === "invite") {
- let bicon = client.user.displayAvatarURL;
- let inviteEmbed = new Discord.RichEmbed()
- .setDescription("[**Invite**](https://discordapp.com/oauth2/authorize?&client_id=596214805786918923&scope=bot&permissions=8)")
- .setColor("#00ff00")
- .setThumbnail(bicon)
- .addField("Use this invite to invite the bot in your server!", "https://discordapp.com/oauth2/authorize?&client_id=596214805786918923&scope=bot&permissions=8")
- message.channel.send(inviteEmbed);
- message.delete();
- }
- // Let's go with a few common example commands! Feel free to delete or change those.
- })
- client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement