-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
71 lines (61 loc) · 2.32 KB
/
index.js
File metadata and controls
71 lines (61 loc) · 2.32 KB
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
require('dotenv').config();
const DISCORD = require('discord.js');
const CLIENT = new DISCORD.Client();
const mongoose = require('mongoose');
mongoose.connect('mongodb://d1153a5b46c1ff42fd56fcf2d1a70a99:' + encodeURIComponent('CSXfU5Mq5UdnjTCr') + '@12a.mongo.evennode.com:27018,12b.mongo.evennode.com:27018/d1153a5b46c1ff42fd56fcf2d1a70a99?replicaSet=us-12', {useNewUrlParser: true, useUnifiedTopology: true});
mongoose.set('useCreateIndex', true);
const badBoiSchema = new mongoose.Schema({
author: String
});
const badBoi = new mongoose.model('badBoi', badBoiSchema);
function verifyMessage(msg){
const sanMsg = msg.content.trim().toLowerCase().split(/\s+/);
let verified = true;
console.log(sanMsg);
for (let i = 0; i < sanMsg.length; i++) {
console.log(sanMsg[i]);
if(sanMsg[i] != 'bowl'){
verified = false;
break;
}
}
console.log(verified);
return verified;
}
async function handleMessage(msg) {
if(!msg.author.bot && !verifyMessage(msg)){
console.log('message not okay');
const author = msg.author;
msg.delete();
badBoi.findOne({author: author}, (err, foundBadBoi) => {
if(err){
console.log(err);
} else {
if(foundBadBoi){
member = msg.member;
member.ban({ days: 7 }).then(() => {
msg.reply(' has been added to the bowl');
});
}else{
const newBadBoi = new badBoi({author:author});
newBadBoi.save((err, badboi) => {
if(err){
console.log(err);
} else {
msg.reply('HOW DARE YOU UTTER SOMETHING OTHER THAN MY NAME YOU USELESS MORTAL. I AM YOUR GOD DO NOT DISSOBEY ME OR I WILL END YOUR PEWNY EXISTENSE AS QUICKLY AS IT BEGAN. YOU MAY ONLY SPEAK MY NAME HERE!!! DEFY ME AGAIN AND YOU WILL BE ENDED');
}
});
}
}
});
}
}
CLIENT.on('message', async (msg) => {
handleMessage(msg);
});
CLIENT.on('messageUpdate', async (oldmsg,newmsg) => {
handleMessage(newmsg);
});
CLIENT.login(process.env.TOKEN).then(() => {
console.log('Discord bot started');
});