summaryrefslogtreecommitdiff
path: root/app.js
blob: 1cc2b0c3e931015940e98877a06790ac9cfe1d04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const Discord = require('discord.js');
const config = require('./config.json');
const bot = new Discord.Client();
const emoji = require('emoji-random');

bot.on('ready', () => { 
    console.log(`Started bot: ${bot.user.tag} (ID: ${bot.user.id})\nCurrently running on ${bot.guilds.size} server(s).`);
    bot.user.setActivity('with squeaky toy :D', {
        type: 'PLAYING'
    });
});

bot.on('error', console.error);

bot.on('message', async msg => {
    const upTime = require('moment');
    require('moment-duration-format');
    const duration = upTime.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");

    function prefixCheck() {
    if (msgContent.startsWith('c!')) {
        return true;
    }
    var msgContent = msg.content.toLowerCase();
    if (prefixCheck()) {
        console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name);
    }

    if (command == 'ping' || command == 'ms') { 
        const t = Date.now();

        msg.channel.send('plz wait..').then(m => {
                m.edit(`** **`);

            const n = Date.now();
            let emb = new Discord.RichEmbed()

            .setDescription(`bork! chesters's  is \`${n - t}ms\`. heartbeat \`${bot.ping}ms\`.`)
            .setColor(0xFFE4BA);

            msg.channel.send(RichEmbed = emb);
        });
    }

    if (command == 'say') {
        if (msg.member.hasPermission('KICK_MEMBERS')) {
            m = args.join(' ');
            msg.channel.send(m);
            msg.delete();
        }
    }

    if (command == 'leave') {
        if (msg.guild.voiceConnection) {
            msg.guild.voiceConnection.disconnect();
            msg.reply('succesfully left voice channel');
        } else {
            msg.reply('i\'m not in a voice channel' + emoji.random());
        }
    }

    if (command == 'join') {
        if (!msg.guild.voiceConnection && msg.member.voiceChannel) {
            msg.member.voiceChannel.join();
            msg.reply('succesfully joined voice channel' + emoji.random());
        } else if (msg.guild.voiceConnection) {
            msg.reply('i\'m already in voice channel' + emoji.random());
        } else if (!msg.member.voiceChannel) {
            msg.reply('you\'re not in a voice channel' + emoji.random());
        }
    }

    if (command == 'reboot' | command == 'r') {
        msg.member.voiceChannel.join();
        msg.member.voiceChannel.leave();
        msg.reply('reboot finished lol' + emoji.random());
    }

    if (msg.mentions.everyone) {
        msg.react(':ArisaPing:695887537390223402');
    }

    if (msg.content == 'dog' | msg.content == 'dogs' | msg.content == 'bark' | msg.content == 'bork' | msg.content == 'woof') {
        var borkNum = Math.floor((Math.random() * 3) + 1);

        if (borkNum == 1) {
            msg.reply('bork' + emoji.random());
        } else if (borkNum == 2) {
            msg.reply('bark' + emoji.random());
        } else if (borkNum == 3) {
            msg.reply('woof' + emoji.random());
        }
    }

    if (command == 'uptime' || command == 'ut') {
        msg.reply(duration + emoji.random());
    }
})

// Get bot token
bot.login(config['secret'])