Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const discord = require('discord.js');
- const prefix = '$';
- const commands = ["help", "hello", "joke", "GAMER GOD AWARD", "spam"];
- const client = new discord.Client();
- client.on('ready', () => {
- client.user.setGame('Do $help');
- client.user.setStatus('online');
- console.log("BOT STARTED!");
- });
- for (i = 0; i < commands.length; i++) {
- commands[i] = prefix + commands[i];
- }
- let gamergodchosen = 0;
- let gamergod = "";
- client.on('message', (message) => {
- if (message.author.bot) return;
- if (message.content === commands[0]) {
- let e = "Here is a list of commands: \n";
- for (i = 0; i < commands.length; i++) {
- e += (i != (commands.length - 1)) ? commands[i] + "\n" : commands[i];
- }
- message.reply(e);
- }
- if (message.content === commands[1]) {
- message.reply('hello! :smile:');
- }
- if (message.content === commands[2]) {
- let jsonjokes = require('./jokes.json');
- let rn = Math.floor(Math.random() * jsonjokes.jokes.length);
- message.reply(jsonjokes.jokes[rn]);
- }
- if (message.content === commands[3]) {
- //You have been deemed a Gamer God
- if (gamergodchosen === 0) {
- message.reply("YOU HAVE BEEN DEEMED __*THE GAMER GOD*__! **YOU WILL ONLY SEE THIS ONCE!** :trophy:");
- gamergodchosen = 1;
- gamergod = message.author;
- }else{
- message.reply('Gamer God has already been claimed by ' + gamergod + '.');
- }
- }
- let spam = message.content.split(' ');
- if (spam[0] === commands[4]) {
- if (spam[1] && spam[2]) {
- let times = Number(spam[1]).toFixed(0);
- if (isNaN(parseFloat(times))) {
- message.reply('Incorrect format. Command should be run like this: ' + commands[4] + ' [#] [message]');
- return;
- }
- if (times > 100) {
- message.reply('Number is larger than 100.');
- return;
- }
- if (times < 1) {
- message.reply('Number is less than 1.');
- return;
- }
- let msg = message.content.slice(spam[0].length + spam[1].length + 2, message.content.length);
- function doSetTimeout(){
- setTimeout(function(){
- message.channel.send(msg);
- }, 750);
- }
- for (i = 0; i < times; i++) {
- message.channel.startTyping();
- doSetTimeout();
- message.channel.stopTyping();
- }
- } else {
- message.reply('Incorrect format. Command should be run like this: ' + commands[4] + ' [#] [message]');
- }
- }
- });
- client.login('my_token');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement