Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--------------------------------------------Constants--------------------------------------------
- const Discord =require('discord.js');
- const bot = new Discord.Client();
- const token = 'NjQ0MzExMjk5NDQ2MTQ1MDM0.Xc4E4Q.VRAaYzSlbjy3uzHlTZdR-XSH42U';
- const PREFIX = ".";
- //const being constant, basically a variable that wont change.
- //--------------------------------------------Variables--------------------------------------------
- var commands = [ ".help: This message",".purge: purges (x) amount of messages from chat [x being the number of messages]", ".info: learn a little more about me.", ".profile: shows user profile", ".battle: FIGHT TO THE DEATH"]
- //command variable. If another command is created add it and its description here.
- bot.on('ready', () =>{
- console.log('This bot is online');
- })
- //The message the console sends when the bot is turned online. Use "node ." to turn it on.
- //--------------------------------------------Message Content--------------------------------------------
- bot.on('message', msg=>{
- if (msg.author.equals(bot.user)) return;
- //So the bot wont respond to itself
- if (msg.content.startsWith(PREFIX)) return;
- //So only commands with the prefix work
- if(msg.content.includes("Back in my day")){
- msg.reply('Ok boomer');
- }
- if(msg.content.includes("EthonSon")){
- msg.reply('You speak of my creator?')
- }
- //messages sent based on what is typed, still a WIP
- //say "sendMessage" so it sends without a ping
- //includes is for a message in a sentence
- //--------------------------------------------Arguments (Bot Commands)--------------------------------------------
- let args = msg.content.substring(PREFIX.length).split(" ")
- switch(args[0]){
- case 'ping':
- msg.channel.send ("pong")
- msg.channel.send ( new Date().getTime() - msg.createdTimestamp + " ms");
- break;
- }
- //ping pong; first command use of the PREFIX. Shows how long it takea for the bot to reply.
- switch(args[0]){
- case 'help':
- msg.channel.send(commands);
- break;
- case 'purge':
- if(!args[1]) return msg.reply('Purge how much ya dingus?')
- msg.channel.bulkDelete(args[1]);
- break;
- case 'info':
- msg.channel.send('Hello, I am a bot created by user @EthonSon [JOYCONBOYZ]#0168. I\'m still in developement but if you have any questions ask my creator or say !help')
- }
- //commands for the bot. HEY YOU ETHAN! MAKE SURE YOU USE "msg" INSTEAD OF "message"!!!
- //The backslash tells JavaScript (this has nothing to do with jQuery, by the way) that the next character should be interpreted as "special". In this case, an apostrophe after a backslash means to use a literal apostrophe but not to end the string.
- switch(args[0]){
- case 'profile':
- const profile = new Discord.RichEmbed()
- .setTitle('Profile')
- .addField('Player Name', msg.author.username)
- .addField('Class', msg.member.roles.map(role => role.name).join(" , "))
- .setThumbnail(msg.author.avatarURL)
- .setColor(0xB20B0B)
- msg.channel.send(profile);
- break;
- }
- switch(args[0]){
- case 'battle':
- const battle = new Discord.RichEmbed()
- .setTitle('FIGHT')
- .addField(('Player Name', msg.author.username) +" V.S "+ ('Player Name', msg.author.mentions))
- // .setThumbnail(msg.author.avatarURL()) this is wrong but you'll figure it out
- .setColor(0xB20B0B)
- msg.channel.send(battle);
- break;
- }
- })
- //profile embed. add ", true" to display embeds in a line
- bot.login(token);
- //token === bot user/passcode/ID. Used to log into the bot and turn it on.
- //don't wrap a bot.on("message") in a bot.on("message")
- //You shouldn't have too many event listeners
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement