-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
121 lines (104 loc) · 3.75 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const Discord = require("discord.js");
const bot = new Discord.Client();
const prefix = "="
bot.on('ready', () => {
bot.user.setStatus('online', 'online');
bot.user.setPresence({ game: { name: 'Hello', type: 0 } });
});
var help = new Discord.RichEmbed()
.addField("There are the commands" , "&ping checks bots connection".true)
.addField("&eval Only for owner".true)
.setColor(0x0000FF)
bot.login(process.env.BOT_TOKEN)
bot.on('ready', function() {
console.log(`Ready as: ${bot.user.tag}`)
})
bot.on("message", function(msg){
console.log(`${msg.author} ${msg.content}`)
})
bot.on("message",function(msg) {
if(msg.author.bot || !msg.content.startsWith(prefix)) {
return;
}
var command = msg.content.split(" ")[0].slice(prefix.length).toLowerCase()
var args = msg.content.split(" ").slice(1);
let suffix = args.join(" ")
if(command === "ping") {
msg.channel.send("Pinging...").then(function(m) {
m.edit(`Pong! Took ${m.createdTimestamp - msg.createdTimestamp}ms`)
})
}
if(command === "say") {
var msgg = args.join(" ");
msg.channel.send(msgg)
}
var help = new Discord.RichEmbed()
.addField("Help", "Thanks for jmmousee for beeing a good sport anyways the commands are &help, &ping, &eval and &kick")
.setColor(0x0000FF)
if(command === "help") {
msg.channel.sendEmbed(help);
}
if(command === "kick") {
const reason = args.slice(1).join(' ');
const user = msg.mentions.users.first();
const modlog = bot.channels.find('name', 'mod-log');
if (!modlog) return msg.reply('I cannot find a mod-log channel');
if (reason.length < 1) return msg.reply('You must supply a reason for the kick.');
if (msg.mentions.users.size < 1) return msg.reply('You must mention someone to kick them.').catch(console.error);
if (!msg.guild.member(user).kickable) return msg.reply('I cannot kick that member');
msg.guild.member(user).kick();
const embed = new Discord.RichEmbed()
.setColor(0x00AE86)
.setTimestamp()
.setDescription(`**Action:** Kick\n**Target:** ${user.tag}\n**Moderator:** ${msg.author.tag}\n**Reason:** ${reason}`);
return bot.channels.get(modlog.id).send({embed});
}
})
function clean(text) {
if (typeof(text) === "string")
return text.replace(/`/g, "'" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}
bot.on("message", message => {
const args = message.content.split(" ").slice(1);
if (message.content.startsWith(prefix + "eval")) {
if(message.author.id !== "493543517168074753") return;
try {
var code = args.join(" ");
var evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
var embed = new Discord.RichEmbed()
.addField("Evaled Code" , clean(evaled), {code:"xl"}.true)
.setColor(0x0000FF)
message.channel.sendEmbed(embed);
} catch (err) {
var error = new Discord.RichEmbed()
.addField("rip the bot has been killed #fatalerror" , `\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``.true)
.setColor(0x0000FF)
message.channel.sendEmbed(error);
}
}
});
bot.on("message", message => {
const args = message.content.split(" ").slice(1);
if (message.content.startsWith(prefix + "eval")) {
if(message.author.id !== "162587551721324544") return;
try {
var code = args.join(" ");
var evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
var embed = new Discord.RichEmbed()
.addField("There is the evaled code" , clean(evaled), {code:"xl"}.true)
.setColor(0x0000FF)
message.channel.sendEmbed(embed);
} catch (err) {
var error = new Discord.RichEmbed()
.addField("rip there is a error" , `\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``.true)
.setColor(0x0000FF)
message.channel.sendEmbed(error);
}
}
});