summaryrefslogtreecommitdiff
path: root/app.js
blob: 688dfda1310e8764dcb7eec5b0065344376c36ba (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
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.json');
const emoji = require('emoji-random');

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

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

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

    function prefixCheck() { if (msg.content.startsWith(config.prefix)) return true; }
    if (prefixCheck()) {
        console.log(msg.member.user.tag, 'says', msg.content.toLowerCase(), 'in #' + msg.channel.name);
        var args = msg.content.slice(config.prefix.length).split(/ +/);
        var cmd = args.shift().toLowerCase();
    }

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

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

            const n = Date.now();

            let emb = new Discord.MessageEmbed()
                .setDescription(`bork! chesters's  is \`${n - t}ms\`. heartbeat \`${client.ws.ping}ms\`. ` + emoji.random())
                .setColor(0xFFE4BA);

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

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

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

    if (cmd == 'join' || cmd == 'j') {
        if (!msg.guild.voice && msg.member.voice.channel) {
            msg.member.voice.channel.join();
            msg.reply('succesfully joined voice channel ' + emoji.random());
        } else if (msg.guild.voice) { 
            msg.reply('i\'m already in voice channel ' + emoji.random());
        } else if (!msg.member.voice.channel) {
            msg.reply('you\'re not in a voice channel ' + 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' || msg.content == 'mutt') {
        var borkNum = Math.floor((Math.random() * 3) + 1);
        var specialBork = Math.floor((Math.random() * 10) + 1);
        var specialBorkCheck = Math.floor((Math.random() * 10) + 1);

        if (specialBork == specialBorkCheck) {
            msg.reply('you got the special bork, this was a 1 in 100 chance of getting ' + emoji.random());
        } else {
            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 (cmd == 'uptime' || cmd == 'ut') {
        msg.reply(duration + ' ' + emoji.random());
    }
});

client.login(config['secret']);