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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
const Discord = require('discord.js');
const config = require('./config.json');
const bot = new Discord.Client();
const isImageUrl = require('is-image-url');
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('psycho~ owo.', {
type: 'LISTENING'
});
// Outputs available commands in output console
commands = ['ping', '8ball/ ball', 'say', 'server'];
console.log(commands);
});
// Outputs errors in console window
bot.on('error', console.error);
// Start Bot Commands
bot.on('message', msg => {
console.log(msg.content.toLowerCase());
if (msg.channel.name === 'bots' || msg.channel.name === 'mods-chat' || msg.member.hasPermission('KICK_MEMBERS')) {
var msgContent = msg.content.toLowerCase();
console.log(msgContent);
console.log(config.prefixes.main);
function prefixCheck() {
if (msgContent.startsWith(config.prefixes.main)) {
return "main";
} else if (msgContent.startsWith(config.prefixes.alt)) {
return "alt1";
} else if (msgContent.startsWith(config.prefixes.alt2)) {
return "alt2";
} else if (msgContent.startsWith(config.prefixes.alt3)) {
return "alt3";
} else if (msgContent.startsWith(config.prefixes.alt4)) {
return "alt4";
} else if (msgContent.startsWith(config.prefixes.alt4b)) {
return "alt4b";
}
}
if (prefixCheck() == "main") {
var args = msg.content.slice(config.prefixes.main.length).split(/ +/);
var command = args.shift().toLowerCase();
if (msg.author.bot || !msg.content.startsWith(config.prefixes.main)) return;
} else if (prefixCheck() == "alt1") {
var args = msg.content.slice(config.prefixes.alt.length).split(/ +/);
var command = args.shift().toLowerCase();
if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt)) return;
} else if (prefixCheck() == "alt2") {
var args = msg.content.slice(config.prefixes.alt2.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt2)) return;
} else if (prefixCheck() == "alt3") {
var args = msg.content.slice(config.prefixes.alt3.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt3)) return;
} else if (prefixCheck() == "alt4") {
var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return;
} else if (prefixCheck() == "alt4b") {
var args = msg.content.slice(config.prefixes.alt4b.length).split(/ +/);
var command = args.shift().toLocaleLowerCase();
if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4b)) return;
}
// Returns ping of bot
if (command == 'ping') {
const t = Date.now();
msg.channel.send('Please Wait...').then(m => {
m.edit(`** **`);
const n = Date.now();
let emb = new Discord.RichEmbed()
.setDescription(`Pong! s5nical's is \`${n - t}ms\`. Heartbeat \`${bot.ping}ms\`.`)
.setColor(0xF97DAE);
msg.channel.send(RichEmbed = emb);
});
}
function noargs() {
msg.channel.send(`Invalid argument(s)! Type \`${config.prefixes.main}help\` for more information.`);
}
function nocmd() {
msg.channel.send(`Invalid or unspecified command! Type \`${config.prefixes.main}help\``);
}
function perms(p) {
if (msg.member.hasPermission(p)) return true;
}
// 8ball feature
if (command == '8ball' || command == 'ball') {
r = ['Yes~ owo', 'No.', 'Yes!', 'No!', 'What, no.', 'Yes.', 'Maybe.', 'Perhaps.', 'Try again.', 'I\'m not sure.'];
var s = r[Math.floor(Math.random() * r.length)];
emb = new Discord.RichEmbed()
.setAuthor('The 8-ball says', 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/8-Ball_Pool.svg/500px-8-Ball_Pool.svg.png')
.setDescription('`' + s + '`');
msg.channel.send(RichEmbed = emb);
}
// Say feature, bot repeats what you say
if (command == 'say') {
if (msg.member.hasPermission('KICK_MEMBERS')) {
m = args.join(' ');
msg.channel.send(m);
msg.delete();
}
}
// Server info feature
if (command == 'server') {
var o = msg.guild.members.filter(m => m.presence.status === 'online').size;
emb = new Discord.RichEmbed()
.setAuthor(`${msg.guild.name} - ${msg.guild.id}`, `${msg.guild.iconURL}`, `https://discordapp.com/channels/${msg.guild.id}/${msg.guild.id}`)
.setDescription(`Here\'s all the information on \`${msg.guild.name}\``)
.setThumbnail(`${msg.guild.iconURL}`)
.addField('Owner', `${msg.guild.owner}`, false)
.addField(`Members [${msg.guild.memberCount}]`, `${o} members are online.`, true)
.addField('Region', `${msg.guild.region}`, true)
.addField('Text Channels', `${msg.guild.channels.filter(c => c.type === 'text').size}`, true)
.addField('Voice Channels', `${msg.guild.channels.filter(c => c.type === 'voice').size}`, true)
.addField('Guild Created', `${msg.guild.createdAt}`, false)
.addField('s5nical Joined', `${msg.guild.members.get('695107550403756192').joinedAt}`)
.setColor(0xF97DAE);
msg.channel.send(RichEmbed = emb);
}
// Help
if (command == 'help') {
let emb = new Discord.RichEmbed()
.setDescription(`The available commands are: *ping*, *8ball/ ball*, *say*, *server* and *help*.`)
.setColor(0xF97DAE);
msg.channel.send(RichEmbed = emb);
}
} else if (msg.channel.name !== 'bots' && msg.content.startsWith(`${config.prefixes.main}`) && !msg.member.hasPermission('KICK_MEMBERS')) return;
})
bot.login(config['secret'])
|