Repository navigation
Expand file tree
/
Copy pathBot.js
More file actions
261 lines (231 loc) Β· 10.2 KB
/
Copy pathBot.js
File metadata and controls
261 lines (231 loc) Β· 10.2 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
const Discord = require('discord.js');
const client = new Discord.Client();
const getRandomFruitsName = require('random-fruits-name');
const axios = require('axios').default;
const config = require('./config.json');
const movieQuote = require('popular-movie-quotes');
var prefix = config.prefix;
client.on("ready", () =>{
console.log(`Logged in as ${client.user.tag}!`);
client.user.setPresence({ activity: { name: `${prefix}help`}, status: 'online' });
setInterval(setPresence, 900000);
});
client.on("message", (message) => {
if ((message.content.startsWith(`${prefix}s`)) && !(message.content === `${prefix}spam`)) {
let args = message.content.slice(prefix.length + 1).trim().split(' ');
let bigLink = args.shift();
//message.delete();
if (!bigLink.length) {
message.channel.send('No input detected. Format your command as such: `-s [link]`');
}
else {
message.delete();
const shorten = {
url: "https://api-ssl.bitly.com/v4/shorten",
method: "post",
headers: {
'Authorization': `Bearer ${config.bitly_token}`,
'Content-Type': 'application/json'
},
data: {
"long_url": `${bigLink}`
}
}
axios.request(shorten)
.then(function (response) {
message.channel.send('```Received. Check your dms!```')
.then(msg => {
msg.delete({ timeout: 5000 })
})
message.author.send('Link retrieved. Here you go!\n' + response.data.link)
})
.catch(function (error) {
message.channel.send("```That's not a link! Remember to paste the full link for the feature to work!```")
.then(msg => {
msg.delete({ timeout: 5000 })
});
});
}
}
message.content = message.content.toLowerCase();
if (message.content.includes('<@!760397472249282570>')) {
let father = message.author.id;
if(father === '<@243189710275608589>') {
message.reply('ping me = die <:ChibiSayuPaimon:758708247309320203>');
setTimeout(function(){
message.channel.send('Stick to my commands, peasant.');
}, 1000);
}
else {
message.reply('You can ping me because you are my creator π');
setTimeout(function(){
message.channel.send('What a benevolent human.');
}, 1000);
}
}
if(message.content.includes('bad') & (message.content.includes('cookie') || message.content.includes('cookies'))) {
let filter = m => m.author.id === message.author.id
message.channel.send("<:AK47:758575767570481152>You got a problem with that?").then(() => {
message.channel.awaitMessages(filter, {
max: 1,
time: 5000,
errors: ['time']
})
.then(message => {
message = message.first()
if (message.content.includes('yes')) {
message.channel.send("You better be ready. Something's coming... Something dangerous... <:ChibiSayuPaimon:758708247309320203>")
}
else if (message.content.includes('no')) {
message.channel.send("I thought so. Choose your words carefully.")
}
else {
message.channel.send("IT'S A YES OR NO QUESTION DUMMY. GO AWAY π€")
}
})
.catch(collected => {
message.channel.send("As I thought π");
});
})
}
if (!message.content.startsWith(prefix) || message.author.bot) return;
if (message.content === `${prefix}help`) {
message.delete({timeout: 1000});
const helpMenuEmbed = new Discord.MessageEmbed()
.setColor('#202225')
.setTitle('Commands List')
.addFields(
{ name: 'π **Ping** `[-ping]`β', value: 'Pong?!?! Test speeds or see if I am alive.'},
{ name: 'π
**Random Fruit** `[-fruit]`', value: 'Gives the name of a random fruit from God knows where.' },
{ name: 'π **Quotes** `[-quote, -q]`', value: 'Gives quotes, duh.'},
{ name: '<a:Cookies:758576143405678603> **Uhh, Cookies??** `[-cookie]`', value: 'Mmm cookies.'},
{ name: 'π **Link Shortenter** `[-s]`', value: 'Shortens your links using the [bit.ly](https://bitly.com/) API'},
{ name: 'π **Coming soon**', value: '*new features being added soon!*' },
{ name: "Disord.js Guide", value: "[mmmm yes hover text](https://discordjs.guide/ 'hover text work?')"},
{ name: "Discord.js Catalog", value: "[ew boring lists](https://discord.js.org/#/ 'click me to get access to extreme boredom!')", inline:true},
{ name: "NPS", value: "[NPS Catalog](https://www.npmjs.com/)", inline:true})
.setDescription("Bot prefix: `"+ prefix + "`")
.setFooter("Check out my progress at https://github.com/Jaedn/Oreo-Bot/");
message.channel.send(helpMenuEmbed);
}
if(message.content === `${prefix}fruit`) {
const embed = new Discord.MessageEmbed()
.setColor('#31d4cd')
.setTitle(getRandomFruitsName());
message.channel.send(embed);
}
if(message.content === `${prefix}ping`) {
message.channel.send("pong!");
}
if(message.content === `${prefix}complain`) {
message.channel.send("Why am I here...");
setTimeout(function(){
message.channel.send("Just to suffer...");
}, 3000);
};
if(message.content.startsWith(`${prefix}q`)) {
if(message.content === `${prefix}quote` || message.content === `${prefix}q` || message.content === `${prefix}quote help` || message.content === `${prefix}q help`) {
const quoteCommandsEmbed = new Discord.MessageEmbed()
.setColor('#202225')
.setTitle('Quote Commands')
.addFields(
{ name: 'Movie Quotes `[-quote movie, -q movie]`β', value: 'Gives a random movie quote.'},
{ name: 'Kanye Quotes `[-quote Kanye, -q Kanye]`', value: 'Gives a random quote from the ultimate Kanye. \n(Be careful with this!)' })
.setDescription('Need help? Here is a list of commmands for quotes!');
message.channel.send(quoteCommandsEmbed);
}
else if(message.content === `${prefix}quote kanye` || message.content === `${prefix}q kanye`) {
axios.get('https://api.kanye.rest/')
.then(function (response) {
// handle success
message.channel.send("> Kanye: " + response.data.quote)
})
.catch(function (error) {
// handle error
console.log('KANYE QUOTE API ERROR');
console.log(error);
});
}
else if(message.content === `${prefix}quote movie` || message.content === `${prefix}q movie`) {
message.channel.send('> ' + movieQuote.getRandomQuote());
}
}
if(message.content === (`${prefix}spam`)) {
setTimeout(function(){
message.channel.send("haha you thought");
}, 2000);
}
/*
if(message.content.startsWith(`${prefix}spam`)) {
function test() {
client.channels.cache.get(channelID).send("<@406898425578258442>")
};
var channelID = message.channel.id;
var interval = setInterval(test, 1000);
if(message.content === (`${prefix}stop`)) {
clearInterval(interval);
}
}
*/
if(message.content === (`${prefix}cookie`)) {
message.react('758576143405678603');
message.channel.send('here hab cookie uwu πͺ');
function cookie() {
message.channel.send('<a:Cookies:758576143405678603>');
}
(function loop() {
var rand = Math.random() * (360000 - 7200000) + 7200000;
setTimeout(function() {
cookie();
loop();
}, rand);
}());
}
if(message.content === (`${prefix}restart`)) {
let filter = m => m.author.id === message.author.id
message.channel.send("```Are you sure you want to restart the bot? \nYou have 15 seconds to reply. Y / N```").then(() => {
message.channel.awaitMessages(filter, {
max: 1,
time: 15000,
errors: ['time']
})
.then(message => {
message = message.first()
if (message.content === 'yes' || message.content === 'y') {
let channelID = message.channel.id;
client.channels.cache.get(channelID).send("Restarting...")
resetBot();
}
else if (message.content === 'no' || message.content === 'n') {
message.channel.send("```Restart Cancelled.```")
}
else {
message.channel.send("```Cancelled: Invalid Response.```")
}
})
.catch(collected => {
message.channel.send("Failed");
});
})
}
//possible react function in future
if (message.content === `${prefix}react`) {
message.react('π¦');
message.react('π§');
message.react('π¨');
}
});
function setPresence() {
client.user.setPresence({ activity: { name:`${prefix}help`}, status: 'online' });
}
function resetBot(channel) {
// send channel a message that you're resetting bot [optional]
(async msg => {
client.destroy()
setTimeout(function(){
client.login(config.token)
}, 3000);
await msg.edit('Restart worked')
});
}
client.login(config.token);