This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.js
246 lines (206 loc) · 10.4 KB
/
Index.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
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
const FS = require('fs');
const { Client } = require('discord.js-selfbot-v13');
const Instance = new Client({
// ...
});
Instance.on('messageCreate', async (Message) => {
if (Message.author.id !== Instance.user.id) {
return;
};
const Arguments = Message.content.split(' ');
const Command = Arguments[0];
if (Message.content.startsWith('$ping')) {
Message.delete();
try {
Message.channel.send({ files: ['./Embeds/Ping.png'] });
} catch (Error) {
Message.channel.send(`# Embed Failure! \n* Discord.js v13 failed to load the content. \n* **If this error persists**, feel free to contact <@1002377371892072498> about this bug, and wait a few! \n\nSincerely, headlined :hearts:`);
return 1;
};
} else if (Message.content.startsWith('$help')) {
Message.delete();
try {
Message.channel.send({ files: ['./Embeds/Help.png'] });
} catch (Error) {
Message.channel.send(`# Embed Failure! \n* Discord.js v13 failed to load the content. \n* **If this error persists**, feel free to contact <@1002377371892072498> about this bug, and wait a few! \n\nSincerely, headlined :hearts:`);
return 1;
};
} else if (Message.content.startsWith('$duck')) {
Message.delete();
try {
try {
fetch('https://api.animality.xyz/all/duck')
.then(Response => Response.json())
.then(Grabbed => {
if (Grabbed && Grabbed.image) {
Message.channel.send({ files: [Grabbed.image], content: '## Quack :duck:' });
} else {
throw new Error('Invalid response from API');
};
})
.catch(Error => {
Message.channel.send(`# Embed Failure! \n* Discord.js v13 failed to load the response. \n* **If this error persists**, feel free to contact <@1002377371892072498> about this bug, and wait a few! \n\nSincerely, headlined :hearts:`);
return 1;
});
} catch (Error) {
Message.channel.send(`# Embed Failure! \n* Discord.js v13 failed to load the content. \n* **If this error persists**, feel free to contact <@1002377371892072498> about this bug, and wait a few! \n\nSincerely, headlined :hearts:`);
return 1;
};
} catch (Error) {
Message.channel.send(`# Embed Failure! \n* Discord.js v13 failed to load the content. \n* **If this error persists**, feel free to contact <@1002377371892072498> about this bug, and wait a few! \n\nSincerely, headlined :hearts:`);
return 1;
};
} else if (Message.content.startsWith('$gc-add')) {
Message.delete();
try {
const UserID = Arguments[1];
const GroupID = Arguments[2];
const User = await Instance.users.fetch(UserID);
const Channel = Instance.channels.cache.get(GroupID);
await Channel.addMember(User);
} catch {
Message.channel.send('Cannot add user to group-DM.')
}
} else if (Message.content.startsWith('$gc-remove')) {
Message.delete();
try {
const UserID = Arguments[1];
const GroupID = Arguments[2];
const User = await Instance.users.fetch(UserID);
const Channel = Instance.channels.cache.get(GroupID);
await Channel.removeMember(User);
} catch {
Message.channel.send('Cannot remove user from group-DM.')
};
} else if (Message.content.startsWith('$void')) {
Message.delete();
setTimeout(async () => {
await Instance.off();
}, 1000);
} else if (Message.content.startsWith('$covid')) {
Message.delete();
try {
const Country = Arguments[1];
const URL = `https://disease.sh/v3/covid-19/countries/${Country}`;
fetch(URL)
.then(Response => Response.json())
.then(Grabbed => {
if (Grabbed && Grabbed.country) {
Message.channel.send(`# COVID-19 Statistics for ${Grabbed.country} \n* Cases: ${Grabbed.cases} \n* Deaths: ${Grabbed.deaths} \n* Recovered: ${Grabbed.recovered} \n* Active: ${Grabbed.active} \n* Critical: ${Grabbed.critical} \n* Cases Today: ${Grabbed.todayCases} \n* Deaths Today: ${Grabbed.todayDeaths} \n* Tests: ${Grabbed.tests} \n* Tests Per Million: ${Grabbed.testsPerOneMillion} \n* Population: ${Grabbed.population} \n* Continent: ${Grabbed.continent} \n* One Case Per People: ${Grabbed.oneCasePerPeople} \n* One Death Per People: ${Grabbed.oneDeathPerPeople} \n* One Test Per People: ${Grabbed.oneTestPerPeople} \n* Active Per One Million: ${Grabbed.activePerOneMillion} \n* Recovered Per One Million: ${Grabbed.recoveredPerOneMillion} \n* Critical Per One Million: ${Grabbed.criticalPerOneMillion} \n* Deaths Per One Million: ${Grabbed.deathsPerOneMillion}`);
} else {
throw new Error('Invalid response from API');
};
})
.catch(Error => {
Message.channel.send(`# Embed Failure! \n* Discord.js v13 failed to load the response. \n* **If this error persists**, feel free to contact <@1002377371892072498> about this bug, and wait a few! \n\nSincerely, headlined :hearts:`);
return 1;
});
} catch {
Message.channel.send('Invalid country name.');
}
} else if (Message.content.startsWith('$define')) {
Message.delete();
try {
const Word = Arguments[1];
const URL = `https://api.dictionaryapi.dev/api/v2/entries/en/${Word}`;
fetch(URL)
.then(Response => Response.json())
.then(Grabbed => {
if (Grabbed && Grabbed[0].word) {
Message.channel.send(`# Definition for ${Grabbed[0].word} \n* Definition: ${Grabbed[0].meanings[0].definitions[0].definition} \n* Part of Speech: ${Grabbed[0].meanings[0].partOfSpeech} \n* Example: ${Grabbed[0].meanings[0].definitions[0].example}`);
} else {
throw new Error('Invalid response from API');
};
})
.catch(Error => {
Message.channel.send(`# Embed Failure! \n* Discord.js v13 failed to load the response. \n* **If this error persists**, feel free to contact <@1002377371892072498> about this bug, and wait a few! \n\nSincerely, headlined :hearts:`);
return 1;
});
} catch {
Message.channel.send('Invalid word.');
}
} else if (Message.content.startsWith('$fing')) {
Message.delete();
try {
const Amount = Arguments[1];
const UserID = Arguments[2];
let i = 0;
const interval = setInterval(() => {
if (i >= Amount) {
clearInterval(interval);
return;
}
Message.channel.send(`<@${UserID}>`);
i++;
}, 750);
} catch {
Message.channel.send('Invalid amount.');
}
} else if (Message.content.startsWith('$animal')) {
Message.delete();
try {
const Animal = Arguments[1];
const URL = `https://api.animality.xyz/all/${Animal}`;
if (Animal === 'list') {
FS.readFile('./Animals.json', 'Utf8', (Error, Data) => {
if (Error) {
console.error(Error);
Message.channel.send('Failed to fetch the list of animals.');
} else {
const Animals = JSON.parse(Data);
const CapitalizedAnimals = Animals.map(Animal => `1. ${Animal.charAt(0).toUpperCase() + Animal.slice(1)}`);
const AnimalList = CapitalizedAnimals.join('\n');
Message.channel.send(`# Some Adorable Animals You Should Send \n${AnimalList}`);
}
});
} else {
const FactURL = `https://api.animality.xyz/fact/${Animal}`;
let Fact = '';
fetch(FactURL)
.then(Response => Response.json())
.then(FactData => {
if (FactData && FactData.fact) {
Fact = FactData.fact;
} else {
throw new Error('Invalid response from API');
}
})
.catch(Error => {
Message.channel.send(`Failed to fetch the animal fact.`);
});
fetch(URL)
.then(Response => Response.json())
.then(Grabbed => {
if (Grabbed && Grabbed.image) {
Message.channel.send({ content: `Random fact about ${Grabbed.animal}s! **${Fact}**`, files: [Grabbed.image] });
} else {
throw new Error('Invalid response from API');
}
})
.catch(Error => {
Message.channel.send(`Failed to fetch the animal image.`);
});
}
} catch (Error) {
console.error(Error);
Message.channel.send('An error occurred while processing the command.');
}
};
});
Instance.on('ready', () => {
console.log('MyDucky is ready for easy use.');
});
FS.readFile('./Information.json', 'utf8', (Error, Data) => {
if (Error) {
console.error('Error reading the file: ', Error);
return;
};
const Json = JSON.parse(Data);
const Token = Json.Token;
try {
Instance.login(Token);
} catch (Error) {
console.error('Error logging in: ', Error);
return;
};
});