-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
107 lines (94 loc) · 3.1 KB
/
bot.js
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
102
103
104
105
106
107
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '!'
var anyPauses = 0;
var pausedGuilds = [];
var pausers = [];
var dotenv = require('dotenv');
dotenv.load();
client.on('ready', ()=> {
console.log('logged in as SHFT!');
});
client.on('message', msg => {
if (msg.author.bot) return;
if (msg.deleted) return;
if (msg.content[0] !== prefix) return;
const args = msg.content.slice(1).trim().split(/ +/g);
const command = args[0].toLowerCase();
if (anyPauses > 0){
var pauseCheck = pausedGuilds.indexOf(msg.guild);
if (pauseCheck > -1){
if (pausers[pauseCheck] !== msg.author) return;
if (args[0] !== 'resume') return;
anyPauses--;
pausers.splice(pauseCheck);
pausedGuilds.splice(pauseCheck);
//There is probably an easy way to filter this
//using discord.js..
}
}
if (args[0] === 'pause' && msg.guild !== undefined) {
if (!msg.guild.member(msg.author).permissions.has('MANAGE_GUILD', true)) return;
pausers.push(msg.author);
pausedGuilds.push(msg.guild);
anyPauses++;
}
if (args[0] === 'tag') {
if(args.length == 1){
msg.channel.send(`You forgot the who. 😕`);
return;
}
//if(args[1])
var tag = msg.mentions.members;
var tagged = tag.first(1);
var target = '';
if ((tagged === null) || (tagged === undefined)){
return;
}
if (tagged != 0){
target = tagged[0].user;
//console.log(target);
}
if (target != ''){
if (target == msg.author){
msg.reply("Why would you even do this?🤔");
return;
}
if (target.bot){
msg.reply("We don't go after bots.");
return;
}
msg.delete();
var postID = null;
const postedPromise = msg.channel.send({
files:
[{attachment: './CallOut.png'}],
reply: target
}).then(result => {
postID = result;
});
var promise = new Promise(function(resolve, reject) {
const gottem = new Discord.MessageCollector(msg.channel, m => m.author === target, {time: 10000});
//console.log(gottem);
gottem.on('collect', clct => {
//console.log('collected');
gottem.stop('reply');
});
gottem.on('end', (col, reason) => {
//console.log('ending');
resolve(reason);
});
});
promise.then(function(value) {
if (value == 'reply'){
postID.react('⭕');
}else{
postID.react('❌');
}
});
} else {
msg.channel.send("Doesn't seem like you mentioned anyone.")
}
}
});
client.login(process.env.BOT_TOKEN);