const Discord = require("discord.js"); const client = new Discord.Client() const config = require('./config.json'); //const winston = require("winston"); We dont need this currently console.log(` [ WAYTBot - Simple Logging bot for Discord ]`); console.log(` - Based upon Logcord by Anidox`); console.log(` - v0.16\n`); client.on('ready', () => { console.log(` - Logged in as ${client.user.username}!`); client.user.setPresence({ status: 'online', game: { name: 'Discuss.' } }); console.log(` - Setting status and activity`); // Define channels // var DelChannel = client.channels.get("424651615962660875"); Test server var DelChannel = client.channels.get("424601455484207124"); var EdiChannel = client.channels.get(""); console.log(` - Finding channels`); console.log(` - Delete logging channel: "${DelChannel}"`); console.log(` - Edit logging channel: "${EdiChannel}" \n`); console.log(` - Bot now logging changes`); // Delete logging client.on("messageDelete", (messageDelete) => { if(messageDelete.author.tag == "WAYTBot#8192") { console.log(` - Bot message deleted D:`); } else { DelChannel.send(`"${messageDelete.content}" by ${messageDelete.author.tag} was deleted.`) console.log(` - A message was deleted by ${messageDelete.author.tag}`); } }); }); client.on("message", 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 SPAM LOL if(command === "commands") { message.channel.send(`~pet ~lgc ~plgc ~nlgc ~tlgc ~hlgc`); } if(command === "pet") { message.channel.send(`(≚ᄌ≚)ℒℴѵℯ❤`); } if(command === "lgc") { message.channel.send(`https://www.youtube.com/watch?v=_AxV8xwru_I`); } if(command === "plgc") { message.channel.send(`https://www.youtube.com/watch?v=Z7UcDjhe9HA`); } if(command === "nlgc") { message.channel.send(`https://www.youtube.com/watch?v=8T5Kqa2R3vY`); } if(command === "tlgc") { message.channel.send(`https://www.youtube.com/watch?v=u1sqhn31MK4`); } if(command === "hlgc") { message.channel.send(`https://www.youtube.com/watch?v=lg-nz4jFVFo`); } /* We dont need these, yet. 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 === "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.roles.some(r=>["Administrator", "Moderator"].includes(r.name)) ) 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. let member = message.mentions.members.first(); 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! let reason = args.slice(1).join(' '); if(!reason) return message.reply("Please indicate a reason for the kick!"); // 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 === "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.roles.some(r=>["Administrator"].includes(r.name)) ) return message.reply("Sorry, you don't have permissions to use this!"); 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) return message.reply("Please indicate a reason for the ban!"); 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({count: deleteCount}); message.channel.bulkDelete(fetched) .catch(error => message.reply(`Couldn't delete messages because of: ${error}`)); }*/ }); client.login(config.token) /*client.on('message', msg => { winston.log('info', `${msg.guild} - ${msg.channel.name} - @${msg.author.username}#${msg.author.discriminator} ( ${msg.author} ) - ${msg.createdAt} - ${msg.content}`); });*/ /*client.on("ready", () => { client.user.setActivity({game: {name: "just looking at your stuff uwu", type: 0}}); console.log(`Logcord - A Discord.js chat logging bot by Anidox`); console.log(`github.com/theanidox/logcord`); console.log(`Logged in as ${client.user.username}!`); });*/