@halpz/fetch 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +136 -0
  2. package/desktop.ini +6 -0
  3. package/index.js +66 -0
  4. package/package.json +25 -0
  5. package/src/client.js +74 -0
  6. package/src/index.js +69 -0
  7. package/src/processor/Moderator/ban.js +54 -0
  8. package/src/processor/Moderator/bans.js +313 -0
  9. package/src/processor/Moderator/chnick.js +56 -0
  10. package/src/processor/Moderator/chrole.js +62 -0
  11. package/src/processor/Moderator/deafen.js +51 -0
  12. package/src/processor/Moderator/index.js +27 -0
  13. package/src/processor/Moderator/kick.js +56 -0
  14. package/src/processor/Moderator/move.js +53 -0
  15. package/src/processor/Moderator/mute.js +51 -0
  16. package/src/processor/Moderator/timeout.js +77 -0
  17. package/src/processor/Moderator/undeafen.js +51 -0
  18. package/src/processor/Moderator/unmute.js +60 -0
  19. package/src/processor/Moderator/untimeout.js +49 -0
  20. package/src/processor/Music/index.js +18 -0
  21. package/src/processor/Music/join.js +52 -0
  22. package/src/processor/Music/leave.js +46 -0
  23. package/src/processor/Music/nplay.js +51 -0
  24. package/src/processor/Music/pause.js +53 -0
  25. package/src/processor/Music/play.js +116 -0
  26. package/src/processor/Music/queue.js +220 -0
  27. package/src/processor/Music/resume.js +53 -0
  28. package/src/processor/Music/setloop.js +35 -0
  29. package/src/processor/Music/shuffle.js +26 -0
  30. package/src/processor/Music/skip.js +64 -0
  31. package/src/processor/Music/stop.js +38 -0
  32. package/src/processor/Music/support/__add_to_queue__.js +236 -0
  33. package/src/processor/Music/support/playing.js +1 -0
  34. package/src/processor/Music/support/update.js +159 -0
  35. package/src/processor/Ultility/chat.js +45 -0
  36. package/src/processor/Ultility/index.js +7 -0
  37. package/src/processor/Ultility/ping.js +26 -0
  38. package/src/processor/Ultility/status.js +85 -0
  39. package/test/Commands/Moderator.js +464 -0
  40. package/test/Commands/Music.js +166 -0
  41. package/test/Commands/Ultility.js +327 -0
  42. package/test/Commands/test/test.js +50 -0
  43. package/test/index.js +126 -0
@@ -0,0 +1,327 @@
1
+ const {
2
+ SlashCommandBuilder,
3
+ CommandInteraction,
4
+ EmbedBuilder,
5
+ PermissionsBitField,
6
+ } = require("discord.js");
7
+ const { get_status, get_result, get_ping } = require("../../src/index");
8
+
9
+ module.exports = {
10
+ data: new SlashCommandBuilder()
11
+ .setName("ultility")
12
+ .setDescription("Other application from Kurumu")
13
+ .addSubcommand((scm) =>
14
+ scm
15
+ .setName("chat")
16
+ .setDescription("hat with chat bot!")
17
+
18
+ .addStringOption((option1) =>
19
+ option1
20
+ .setName("prompt")
21
+ .setDescription("What do you want to ask")
22
+ .setRequired(true)
23
+ )
24
+ .addStringOption((option3) =>
25
+ option3
26
+ .setName("chatbot")
27
+ .setDescription("What chatbot you want to ask?")
28
+ .setRequired(true)
29
+ .addChoices(
30
+ { name: "Bing AI Creative", value: "Creative" },
31
+ { name: "Bing AI Balanced", value: "Balanced" },
32
+ { name: "Bing AI Precise", value: "Precise" },
33
+ { name: "Google Bard", value: "Bard" }
34
+ )
35
+ )
36
+ )
37
+ .addSubcommand((scm) =>
38
+ scm
39
+ .setName("help")
40
+ .setDescription("Help for user from kurumu!")
41
+ .addStringOption((command_help) =>
42
+ command_help
43
+ .setName("command_helped")
44
+ .setDescription("What command do you want to help?")
45
+ )
46
+ )
47
+ .addSubcommand((scm) =>
48
+ scm.setName("ping").setDescription("Replies with Pong!")
49
+ )
50
+ .addSubcommand((scm) =>
51
+ scm.setName("status").setDescription("Get status of Kurumu client")
52
+ ),
53
+ /**
54
+ *
55
+ * @param {CommandInteraction} interaction
56
+ */
57
+
58
+ async execute(client, interaction) {
59
+ await interaction.deferReply({
60
+ ephemeral: true,
61
+ });
62
+
63
+ const scm = interaction.options.getSubcommand();
64
+
65
+ var result = "";
66
+
67
+ if (scm === "chat") {
68
+ const prompt = interaction.options.getString("prompt");
69
+ const chatbot = interaction.options.getString("chatbot");
70
+ const response = await get_result(client, interaction, prompt, chatbot);
71
+ try {
72
+ var char_limit = 1900,
73
+ res_mess = [],
74
+ i = 0,
75
+ res = "";
76
+ // var b = "";
77
+ // if (b.indexOf('}}') != -1) {
78
+ // response = response.split('}}')[1];
79
+ // }
80
+ // var a = response.split('}}');
81
+
82
+ if (response.length > char_limit) {
83
+ var temp = response.split("\n");
84
+ var length_temp = temp.length;
85
+
86
+ while (i < length_temp - 1) {
87
+ if (temp[i].indexOf("[Image ") == -1) {
88
+ if ((res + temp[i]).length < char_limit) {
89
+ res += temp[i] + "\n";
90
+ } else {
91
+ res_mess.push(res);
92
+ res = temp[i] + "\n";
93
+ }
94
+ }
95
+ i++;
96
+ }
97
+
98
+ res_mess.push(res);
99
+ res_mess.forEach((string) => {
100
+ interaction.followUp({
101
+ content: `${string}`,
102
+ ephemeral: true,
103
+ });
104
+ });
105
+ } else {
106
+ interaction.followUp({
107
+ content: `${response}`,
108
+ ephemeral: true,
109
+ });
110
+ }
111
+ } catch (error) {
112
+ console.error(error);
113
+ await interaction.followUp({
114
+ content: `Something was wrong, please call my owner for help :<<`,
115
+ ephemeral: true,
116
+ });
117
+ }
118
+ } else if (scm === "help") {
119
+ const command_help =
120
+ interaction.options.getString("command_helped") ?? "None";
121
+
122
+ var user;
123
+
124
+ if (interaction.deferred) {
125
+ user = interaction.user;
126
+ } else {
127
+ user = interaction.author;
128
+ }
129
+
130
+ const color = client.get_color();
131
+
132
+ if (command_help == "None") {
133
+ const commands = client.client.commands;
134
+
135
+ var group_command = [];
136
+
137
+ var embeb = new EmbedBuilder();
138
+ embeb.setTitle(`Auto help from ${client.name}`);
139
+ embeb.setDescription("Hello, may I help you?");
140
+ embeb.setColor(color);
141
+ embeb.setThumbnail(user.displayAvatarURL());
142
+
143
+ commands.forEach((command) => {
144
+ var value = "";
145
+ if (command.data.options.length > 0) {
146
+ const opts = command.data.options;
147
+ opts.forEach((scm) => {
148
+ value += "`" + `${scm.name}` + "` ";
149
+ });
150
+ const moi = command.data.name.slice(1);
151
+ embeb.addFields({
152
+ name: `${command.data.name[0].toUpperCase()}${command.data.name.slice(
153
+ 1
154
+ )}:`,
155
+ value: value,
156
+ });
157
+ }
158
+ });
159
+
160
+ // for (const folder in commandFolders) {
161
+
162
+ // const group_command = commands[commandFolders[Number(folder)]]
163
+
164
+ // if (commandFolders[folder].toLowerCase() == 'test')
165
+ // continue;
166
+
167
+ // var value = ''
168
+ // group_command.forEach(command => {
169
+ // value += "`" + `${command.name}` + "` ";
170
+ // })
171
+
172
+ // embeb.addFields({
173
+ // name: `${commandFolders[folder]}:`,
174
+ // value: value,
175
+ // });
176
+ // }
177
+
178
+ result = [embeb];
179
+ } else {
180
+ var command = "";
181
+ await search(client, interaction, command_help).then((data) => {
182
+ command = data;
183
+ });
184
+
185
+ if (command === "Not found") {
186
+ result = [
187
+ new EmbedBuilder().setColor(client.get_color()).addFields({
188
+ name: `Error:`,
189
+ value: `404 Not Found`,
190
+ }),
191
+ ];
192
+ } else {
193
+ const command_data = command;
194
+
195
+ const commandss = command_data.command;
196
+ const def_perm = commandss.data.default_member_permissions ?? 0;
197
+ var def_mem_perm_arr;
198
+
199
+ if (def_perm !== 0) {
200
+ const def_mem_perm = new PermissionsBitField(
201
+ BigInt(Number(def_perm))
202
+ );
203
+ def_mem_perm_arr = def_mem_perm.toArray();
204
+ } else {
205
+ def_mem_perm_arr = [
206
+ `You don't need any permission for this command`,
207
+ ];
208
+ }
209
+ var permss = "";
210
+
211
+ def_mem_perm_arr.forEach((perm) => {
212
+ permss += "`" + `${perm}` + "` ";
213
+ });
214
+
215
+ const commandd = command_data.scm;
216
+ const command_name = commandd.name;
217
+ const desc = commandd.description;
218
+ const opts = commandd.options;
219
+
220
+ var embebs = [];
221
+
222
+ embebs.push(
223
+ new EmbedBuilder()
224
+ .setTitle("Auto help from Kurumu for `" + `${command_name}` + "`")
225
+ .setDescription(`Hello, May I help you?`)
226
+ .setColor(color)
227
+ .setThumbnail(user.displayAvatarURL())
228
+ .addFields([
229
+ {
230
+ name: `Name:`,
231
+ value: `> ${command_name}`,
232
+ },
233
+ {
234
+ name: `Description:`,
235
+ value: `> ${desc}`,
236
+ },
237
+ {
238
+ name: `Permission:`,
239
+ value: `> ${permss}`,
240
+ },
241
+ {
242
+ name: `Options:`,
243
+ value: `> ${opts.length}`,
244
+ },
245
+ ])
246
+ );
247
+
248
+ opts.forEach(
249
+ /**
250
+ * @param {} opt
251
+ */
252
+ function (opt) {
253
+ var temp = Object.getPrototypeOf(opt).constructor.name;
254
+ temp = temp.replace("SlashCommand", "");
255
+ temp = temp.replace("Option", "");
256
+
257
+ var embeb = new EmbedBuilder()
258
+ .setTitle("Option: `" + `${opt.name}` + "`")
259
+ .setColor(color)
260
+ .addFields([
261
+ {
262
+ name: `Description:`,
263
+ value: `${opt.description}`,
264
+ },
265
+ {
266
+ name: `Type:`,
267
+ value: `${temp}`,
268
+ },
269
+ {
270
+ name: `Required:`,
271
+ value: opt.required ? "true" : "false",
272
+ },
273
+ ]);
274
+
275
+ if (opt.choices != undefined) {
276
+ var temp = "";
277
+ opt.choices.forEach((choice) => {
278
+ temp += choice.name + "\n";
279
+ });
280
+
281
+ embeb.addFields({
282
+ name: `Choices:`,
283
+ value: temp,
284
+ });
285
+ }
286
+
287
+ embebs.push(embeb);
288
+ }
289
+ );
290
+ result = embebs;
291
+ }
292
+ }
293
+ } else if (scm === "ping") {
294
+ result = await get_ping(client, interaction);
295
+ } else if (scm === "status") {
296
+ result = await get_status(client, interaction);
297
+ }
298
+
299
+ if (result !== "") {
300
+ await interaction.followUp({
301
+ embeds: result,
302
+ ephemeral: true,
303
+ });
304
+ }
305
+ },
306
+ };
307
+
308
+ async function search(client, interaction, command_help) {
309
+ return new Promise((resolve) => {
310
+ const commands = client.client.commands;
311
+
312
+ var chill = "Not found";
313
+ commands.forEach((command) => {
314
+ command.data.options.forEach((scm) => {
315
+ const moi = scm.name === command_help;
316
+ if (scm.name === command_help) {
317
+ chill = {
318
+ command: command,
319
+ scm: scm,
320
+ };
321
+ }
322
+ });
323
+ });
324
+
325
+ resolve(chill);
326
+ });
327
+ }
@@ -0,0 +1,50 @@
1
+ const { SlashCommandBuilder, CommandInteraction } = require('discord.js');
2
+ const { discordClient } = require('../../../index');
3
+ const { helping } = require('../../../index');
4
+
5
+ module.exports = {
6
+ data: new SlashCommandBuilder()
7
+ .setName('test')
8
+ .setDescription('test for user from kurumu!')
9
+ .addSubcommand(sc =>
10
+ sc
11
+ .setName('ping')
12
+ .setDescription('pong')
13
+ .addBooleanOption(opt =>
14
+ opt
15
+ .setName('nani')
16
+ .setDescription('moi'))
17
+ )
18
+ .addSubcommand(sc =>
19
+ sc
20
+ .setName('hello')
21
+ .setDescription('say hello')
22
+ ),
23
+
24
+ /**
25
+ *
26
+ * @param {discordClient} client
27
+ * @param {CommandInteraction} interaction
28
+ */
29
+
30
+ async execute(client, interaction) {
31
+ await interaction.deferReply({
32
+ ephemeral: true
33
+ });
34
+
35
+ if (interaction.options._subcommand == 'ping') {
36
+ console.log('ping')
37
+ console.log(interaction.options.getBoolean('nani'))
38
+ }
39
+
40
+ // const command_help = interaction.options.getString('command_helped') ?? 'None';
41
+
42
+ // const result = await helping(client, interaction, command_help);
43
+
44
+ // await interaction.followUp({
45
+ // embeds: result,
46
+ // ephemeral: true
47
+ // })
48
+
49
+ },
50
+ };
package/test/index.js ADDED
@@ -0,0 +1,126 @@
1
+ const { discordClient } = require("../index");
2
+ const config = require("../config.json");
3
+
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const { Collection, Events } = require("discord.js");
7
+ const { REST, Routes } = require("discord.js");
8
+
9
+ const client = new discordClient({
10
+ name: config.name,
11
+ prefix: config.prefix,
12
+ youtube_api_key: config.YOUTUBE_API_KEY,
13
+ cookie_U: config.cookie_U,
14
+ __Secure_1PSID: config.__Secure_1PSID,
15
+ __Secure_1PSIDTS: config.__Secure_1PSIDTS,
16
+ version: "v0.9.0",
17
+ });
18
+
19
+ async function setup() {
20
+ await client.setup();
21
+ }
22
+
23
+ setup();
24
+
25
+ const commands = [];
26
+
27
+ const commands_path = path.join(__dirname, "Commands");
28
+ const commands_files = fs
29
+ .readdirSync(commands_path)
30
+ .filter((file) => file.endsWith(".js"));
31
+
32
+ for (const file of commands_files) {
33
+ const filePath = path.join(commands_path, file);
34
+ const command = require(filePath);
35
+ if ("data" in command && "execute" in command) {
36
+ // console.log(command.data.name);
37
+ commands.push(command.data.toJSON());
38
+ } else {
39
+ console.log(
40
+ `[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
41
+ );
42
+ }
43
+ }
44
+
45
+ const rest = new REST().setToken(config.token);
46
+
47
+ (async () => {
48
+ try {
49
+ console.log(
50
+ `Started refreshing ${commands.length} application (/) commands.`
51
+ );
52
+
53
+ const data = await rest.put(Routes.applicationCommands(config.clientId), {
54
+ body: commands,
55
+ });
56
+
57
+ console.log(
58
+ `Successfully reloaded ${data.length} application (/) commands.`
59
+ );
60
+ } catch (error) {
61
+ console.error(error);
62
+ }
63
+ })();
64
+
65
+ client.client.commands = new Collection();
66
+
67
+ const commandsPath = path.join(__dirname, "Commands");
68
+ const commandFiles = fs
69
+ .readdirSync(commandsPath)
70
+ .filter((file) => file.endsWith(".js"));
71
+
72
+ for (const file of commandFiles) {
73
+ const filePath = path.join(commandsPath, file);
74
+ const command = require(filePath);
75
+ if ("data" in command && "execute" in command) {
76
+ client.client.commands.set(command.data.name, command);
77
+ // console.log(command.data.name);
78
+ } else {
79
+ console.log(
80
+ `[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
81
+ );
82
+ }
83
+ }
84
+
85
+ client.client.on(Events.InteractionCreate, async (interaction) => {
86
+ if (!interaction.isChatInputCommand()) return;
87
+
88
+ const command = interaction.client.commands.get(interaction.commandName);
89
+
90
+ if (!command) {
91
+ console.error(`No command matching ${interaction.commandName} was found.`);
92
+ return;
93
+ }
94
+
95
+ try {
96
+ await command.execute(client, interaction);
97
+ } catch (error) {
98
+ console.error(error);
99
+ console.log(interaction.commandName);
100
+ if (interaction.replied || interaction.deferred) {
101
+ await interaction.followUp({
102
+ content: "There was an error while executing this command!",
103
+ ephemeral: true,
104
+ });
105
+ } else {
106
+ await interaction.reply({
107
+ content: "There was an error while executing this command!",
108
+ ephemeral: true,
109
+ });
110
+ }
111
+ }
112
+ });
113
+ client.client.on("ready", () => {
114
+ console.log(
115
+ `[Warning] Make sure that you have updated BingAI and Bard cookies`
116
+ );
117
+ console.log(
118
+ `if you don't update cookies, you can have some error when running`
119
+ );
120
+ console.log(`Recommend updating cookies cookies before running bot:>`);
121
+ console.log(`Logged in as ${client.client.user.tag}!`);
122
+ });
123
+
124
+ // Log in to Discord with your client.client's token
125
+
126
+ client.client.login(config.token);