This repository has been archived by the owner on May 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
211 lines (197 loc) · 7.77 KB
/
app.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
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
/* jshint esversion: 6 */
require('dotenv').config();
const request = require('request');
const giphy = require('giphy-api')();
const Discord = require('discord.js');
const acebot = new Discord.Client();
const prefix = process.env.PREFIX;
// Format date for last online
const dateFormat = require('dateformat');
const now = new Date();
const onlineNow = dateFormat(now, 'shortDate');
const updatedDate = `${dateFormat(now, 'shortDate')} at ${dateFormat(now, 'shortTime')}`;
// Client Events
acebot.on('ready', () => {
console.log('I am ready, gimmie some commands!!');
acebot.user.setStatus('online', `Last Restart: ${onlineNow}`).catch(console.error);
});
acebot.on('channelPinsUpdate', (channel) => {
channel.send(`The pins for **${channel.name}** have been updated on ${updatedDate}`).catch(console.error);
});
acebot.on('channelCreate', (channel) => {
console.log(`A ${channel.type} channel by the name of ${channel.name} was created ${channel.createdAt} with the ID of ${channel.id}`);
channel.send(`Successfully created this channel on ${updatedDate}.`).catch(console.error);
});
acebot.on('channelDelete', (channel) => {
console.log(`A ${channel.type} channel by the name of ${channel.name} was successfully deleted on ${updatedDate}.`);
});
// Message handler
acebot.on('message', (message) => {
if (message.author.bot) {
return;
}
if (!message.content.startsWith(prefix)) {
return;
}
const args = message.content.split(' ').slice(1);
const AdminRole = message.guild.roles.find('name', 'Admin');
let result = args.join(' ');
let command = message.content.split(' ')[0];
command = command.slice(prefix.length).toLowerCase();
console.log(command);
// Add numbas - do maths
if (command === 'add') {
const numArray = args.map(n => parseInt(n, 10));
const total = numArray.reduce((p, c) => p + c);
message.channel.send(total).catch(console.error);
}
// Help
if (command === 'helpme') {
message.reply("\n\nCommands:\n\n**!ping** - Sends 'pong' back to user\n\n**!btc** - Responds with current USD market price of bitcoin\n\n**!eth** - Responds with current USD market price of ethereum\n\n**!ltc** - Responds with current USD market price of litecoin\n\n**!goat** - Responds with random goat gif\n\n**!kitten** - Responds with random kitten gif\n\n**!helpme** - Bot help\n\n**!add** - Adds numbers; Example '!add 5 5 5' Total = 15 \n\n**!foo** - Responds with 'bar!' if you're an Admin.\n\n**!triggered** - Responds with favorite triggered gif.\n\n**!brule** - Responds with random Steve Brule gif.\n\n**!bringo** - Responds with favorite Steve Brule bringo gif.\n\n**!bow** - Responds with favorite James Franco bow gif.\n\n**!hue** - Responds with random HueHueHue gif.").catch(console.error);
}
// Ping - Pong
if (command === 'ping') {
message.channel.send('Pong!').catch(console.error);
}
// Foo - Bar - locked down to Admin Role only
if (command === 'foo') {
if (message.member.roles.has(AdminRole.id)) {
message.channel.send('bar!').catch(console.error);
} else {
message.channel.send('Hah, you noob. You don`t have access to that command!').catch(console.error);
}
}
// Bitcoin
if (command === 'btc') {
request('https://api.coinbase.com/v2/prices/BTC-USD/spot', (error, response, body) => {
if (!error && response.statusCode === 200) {
const btc = JSON.parse(body);
const USD = btc.data.amount; // Set USD to the latest USD bitcoin price
message.reply(`the current Bitcoin market price is: $ ${USD} USD`).catch(console.error); // Send price to user that requested price
}
});
}
// Litecoin
if (command === 'ltc') {
request('https://api.coinbase.com/v2/prices/LTC-USD/spot', (error, response, body) => {
if (!error && response.statusCode === 200) {
const ltc = JSON.parse(body);
const USD = ltc.data.amount; // Set USD to the latest USD litecoin price
message.reply(`the current Litecoin market price is: $ ${USD} USD`).catch(console.error); // Send price to user that requested price
}
});
}
// Ethereum
if (command === 'eth') {
request(' https://api.coinbase.com/v2/prices/ETH-USD/spot', (error, response, body) => {
if (!error && response.statusCode === 200) {
const eth = JSON.parse(body);
const USD = eth.data.amount; // Set USD to the latest USD ethereum price
message.reply(`the current Ethereum market price is: $ ${USD} USD`).catch(console.error); // Send price to user that requested price
}
});
}
// Random goat gif
if (command === 'goat') {
// Search with options using callback
giphy.random({
tag: 'goat',
}, (err, res) => {
// Res contains gif data!
const goatURL = res.data.image_url;
message.channel.send(goatURL, '', ':goat: | **Here is your random goat:**').catch(console.error);
});
}
// Random cat gif
if (command === 'kitten') {
// Search with options using callback
giphy.random({
tag: 'kitten',
}, (err, res) => {
// Res contains gif data!
const kittenURL = res.data.image_url;
message.channel.send(kittenURL, '', ':cat2: | **Here is your random kitten:**').catch(console.error);
});
}
// Steve Brule - Bringo Gif
if (command === 'bringo') {
message.channel.send('https://media.giphy.com/media/xLsaBMK6Mg8DK/giphy.gif').catch(console.error);
}
// Jumping Doge Gif
if (command === 'imback') {
message.channel
.send('https://i.imgur.com/wmba9uw.gifv')
.catch(console.error);
}
// Zoop emojis
if (command === 'zoop') {
message.channel
.send(':point_right: :sunglasses: :point_right:')
.catch(console.error);
}
// Triggered Gif
if (command === 'triggered') {
message.channel.send('https://media.giphy.com/media/vk7VesvyZEwuI/giphy.gif').catch(console.error);
}
// Bow Gif
if (command === 'bow') {
message.channel.send('https://media3.giphy.com/media/uvqkm9ip7mNvq/giphy.gif').catch(console.error);
}
// tongue Gif
if (command === 'tongue') {
message.channel.send('https://media.giphy.com/media/yxPLEa1MTvj7TErGp5/giphy.gif').catch(console.error);
}
// wat Gif
if (command === 'wat') {
message.channel.send('https://media.giphy.com/media/oDK8A6xUNjD2M/giphy.gif').catch(console.error);
}
// conan Gif
if (command === 'conan') {
message.channel.send('http://giphygifs.s3.amazonaws.com/media/SoBfbf8QGWzaU/giphy.gif').catch(console.error);
}
// steve erwin Gif
if (command === 'steve') {
message.channel.send('https://media.giphy.com/media/3oEjHFbOJ4DzYeZM6k/giphy.gif').catch(console.error);
}
// Random Steve Brule gif
if (command === 'brule') {
// Search with options using callback
giphy.random({
tag: 'steve brule',
}, (err, res) => {
// Res contains gif data!
const bruleURL = res.data.image_url;
message.channel.send(bruleURL, '', '**Here is your random Steve Brule gif:**').catch(console.error);
});
}
// HueHueHue Gif
if (command === 'hue') {
// Search with options using callback
giphy.random({
tag: 'huehuehue',
}, (err, res) => {
// Res contains gif data!
const hueURL = res.data.image_url;
message.channel.send(hueURL, '', '**Here is your random HueHueHue gif:**').catch(console.error);
});
}
// Set status
if (command === 'setstatus') {
if (!result) {
result = 'online';
}
acebot.user.setStatus(result).catch(console.error);
}
// Set game
if (command === 'setgame') {
if (message.member.roles.has(AdminRole.id)) {
if (!result) {
result = null;
}
acebot.user.setGame(result).catch(console.error);
} else {
message.channel.send('Hah, you noob. You don`t have access to that command!').catch(console.error);
}
}
}); // End message handler
acebot.login(process.env.LOGIN_TOKEN);