discord-fetchers 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of discord-fetchers might be problematic. Click here for more details.
- package/README.md +136 -0
- package/index.js +66 -0
- package/package.json +29 -0
- package/src/client.js +74 -0
- package/src/index.js +69 -0
- package/src/processor/Moderator/ban.js +54 -0
- package/src/processor/Moderator/bans.js +313 -0
- package/src/processor/Moderator/chnick.js +56 -0
- package/src/processor/Moderator/chrole.js +62 -0
- package/src/processor/Moderator/deafen.js +51 -0
- package/src/processor/Moderator/index.js +27 -0
- package/src/processor/Moderator/kick.js +56 -0
- package/src/processor/Moderator/move.js +53 -0
- package/src/processor/Moderator/mute.js +51 -0
- package/src/processor/Moderator/timeout.js +77 -0
- package/src/processor/Moderator/undeafen.js +51 -0
- package/src/processor/Moderator/unmute.js +60 -0
- package/src/processor/Moderator/untimeout.js +49 -0
- package/src/processor/Music/index.js +18 -0
- package/src/processor/Music/join.js +52 -0
- package/src/processor/Music/leave.js +46 -0
- package/src/processor/Music/nplay.js +51 -0
- package/src/processor/Music/pause.js +53 -0
- package/src/processor/Music/play.js +116 -0
- package/src/processor/Music/queue.js +220 -0
- package/src/processor/Music/resume.js +53 -0
- package/src/processor/Music/setloop.js +35 -0
- package/src/processor/Music/shuffle.js +26 -0
- package/src/processor/Music/skip.js +64 -0
- package/src/processor/Music/stop.js +38 -0
- package/src/processor/Music/support/__add_to_queue__.js +236 -0
- package/src/processor/Music/support/playing.js +1 -0
- package/src/processor/Music/support/update.js +159 -0
- package/src/processor/Ultility/chat.js +45 -0
- package/src/processor/Ultility/index.js +7 -0
- package/src/processor/Ultility/ping.js +26 -0
- package/src/processor/Ultility/status.js +85 -0
- package/test/Commands/Moderator.js +464 -0
- package/test/Commands/Music.js +166 -0
- package/test/Commands/Ultility.js +327 -0
- package/test/Commands/test/test.js +50 -0
- package/test/index.js +126 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
const { CommandInteraction } = require('discord.js');
|
2
|
+
const { useQueue, useMainPlayer } = require('discord-player')
|
3
|
+
const _ = require('lodash')
|
4
|
+
const playing = require('./support/playing')
|
5
|
+
const { update_component, update_embed } = require('./support/update')
|
6
|
+
|
7
|
+
module.exports = see_queue
|
8
|
+
|
9
|
+
/**
|
10
|
+
*
|
11
|
+
* all activities:
|
12
|
+
*
|
13
|
+
* - See queue | Supported ✅
|
14
|
+
* - Delete track(s) | Supported ✅
|
15
|
+
* - Skip to track | Supported ✅
|
16
|
+
* @param {CommandInteraction} interaction
|
17
|
+
*/
|
18
|
+
|
19
|
+
async function see_queue(client, interaction) {
|
20
|
+
|
21
|
+
var user;
|
22
|
+
if (interaction.deferred) {
|
23
|
+
user = interaction.user;
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
user = interaction.author
|
27
|
+
}
|
28
|
+
|
29
|
+
var embeds = await update_embed(client, interaction);
|
30
|
+
|
31
|
+
var curr_page = 0;
|
32
|
+
var max_page = embeds.length - 1;
|
33
|
+
|
34
|
+
var view = await update_component(curr_page, max_page, embeds);
|
35
|
+
|
36
|
+
var response = (interaction.deferred)
|
37
|
+
|
38
|
+
? await interaction.followUp({
|
39
|
+
embeds: [embeds[curr_page]],
|
40
|
+
components: view,
|
41
|
+
})
|
42
|
+
: await interaction.reply({
|
43
|
+
embeds: [embeds[curr_page]],
|
44
|
+
components: view,
|
45
|
+
});
|
46
|
+
|
47
|
+
while (true) {
|
48
|
+
const collectorFilter = i => i.user.id === user.id;
|
49
|
+
try {
|
50
|
+
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter });
|
51
|
+
// const collector = response.createMessageComponentCollector({ componentType: ComponentType.StringSelect, time: 3_600_000 });
|
52
|
+
|
53
|
+
if (confirmation.customId === '<<') {
|
54
|
+
curr_page = 0;
|
55
|
+
view = await update_component(curr_page, max_page, embeds);
|
56
|
+
await confirmation.update({ embeds: [embeds[curr_page]], components: view });
|
57
|
+
}
|
58
|
+
else if (confirmation.customId === '<') {
|
59
|
+
curr_page--;
|
60
|
+
view = await update_component(curr_page, max_page, embeds);
|
61
|
+
await confirmation.update({ embeds: [embeds[curr_page]], components: view });
|
62
|
+
}
|
63
|
+
else if (confirmation.customId === '>') {
|
64
|
+
curr_page++;
|
65
|
+
view = await update_component(curr_page, max_page, embeds);
|
66
|
+
await confirmation.update({ embeds: [embeds[curr_page]], components: view });
|
67
|
+
}
|
68
|
+
else if (confirmation.customId === '>>') {
|
69
|
+
curr_page = max_page;
|
70
|
+
view = await update_component(curr_page, max_page, embeds);
|
71
|
+
await confirmation.update({ embeds: [embeds[curr_page]], components: view });
|
72
|
+
}
|
73
|
+
else if (confirmation.customId === 'noice') {
|
74
|
+
await confirmation.update({ content: "You have chosen this track:", embeds: [embeds[curr_page]], components: [] })
|
75
|
+
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
else if (confirmation.customId === 'nope') {
|
79
|
+
await confirmation.update({ embeds: [embeds[curr_page]], components: [] })
|
80
|
+
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
else if (confirmation.customId === 'delete') {
|
84
|
+
|
85
|
+
|
86
|
+
const selection = Number(confirmation.values[0]) - 1;
|
87
|
+
var infront;
|
88
|
+
if (selection < 1) {
|
89
|
+
infront = [];
|
90
|
+
}
|
91
|
+
else {
|
92
|
+
infront = client.ctrack[interaction.guildId].slice(0, selection);
|
93
|
+
}
|
94
|
+
|
95
|
+
const inafter = client.ctrack[interaction.guildId].slice(selection + 1);
|
96
|
+
const selected = client.ctrack[interaction.guildId][selection];
|
97
|
+
|
98
|
+
client.ctrack[interaction.guildId] = infront;
|
99
|
+
|
100
|
+
if (_.get(client.isloop, interaction.guildId, undefined) === '2') {
|
101
|
+
inafter.forEach(url => {
|
102
|
+
client.ctrack[interaction.guildId].push(url)
|
103
|
+
});
|
104
|
+
}
|
105
|
+
|
106
|
+
if (selection == 0) {
|
107
|
+
useQueue(confirmation.guildId).node.stop();
|
108
|
+
|
109
|
+
await playing(client, interaction);
|
110
|
+
}
|
111
|
+
|
112
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
113
|
+
const deleted_track = (await useMainPlayer().search(selected))._data.tracks[0].title
|
114
|
+
|
115
|
+
embeds = await update_embed(client, interaction);
|
116
|
+
|
117
|
+
var curr_page = 0;
|
118
|
+
var max_page = embeds.length - 1;
|
119
|
+
|
120
|
+
var view = await update_component(curr_page, max_page, embeds);
|
121
|
+
|
122
|
+
await confirmation.update({
|
123
|
+
content: `You have deleted track ${deleted_track}`,
|
124
|
+
embeds: [embeds[curr_page]],
|
125
|
+
components: view,
|
126
|
+
});
|
127
|
+
}
|
128
|
+
else if (confirmation.customId === 'skip') {
|
129
|
+
|
130
|
+
const selection = Number(confirmation.values[0]) - 1;
|
131
|
+
|
132
|
+
const bruh = ((await useMainPlayer().search(client.ctrack[interaction.guildId][selection]))._data.tracks[0].title == useQueue(interaction.guildId).currentTrack.title);
|
133
|
+
|
134
|
+
|
135
|
+
if (bruh === false) {
|
136
|
+
const infront = (selection !== 0) ?
|
137
|
+
client.ctrack[interaction.guildId].slice(0, selection) : [];
|
138
|
+
|
139
|
+
const inafter = client.ctrack[interaction.guildId].slice(selection);
|
140
|
+
|
141
|
+
client.ctrack[interaction.guildId] = inafter;
|
142
|
+
|
143
|
+
if (_.get(client.isloop, interaction.guildId, undefined) === '2') {
|
144
|
+
infront.forEach(url => {
|
145
|
+
client.ctrack[interaction.guildId].push(url)
|
146
|
+
});
|
147
|
+
}
|
148
|
+
else if (client.isloop[interaction.guildId] !== '1') {
|
149
|
+
infront.forEach(url => {
|
150
|
+
client.ptrack[interaction.guildId].push(url)
|
151
|
+
});
|
152
|
+
}
|
153
|
+
|
154
|
+
const queue = useQueue(confirmation.guildId);
|
155
|
+
|
156
|
+
const curr_track = queue.currentTrack.title;
|
157
|
+
|
158
|
+
useQueue(confirmation.guildId).node.stop();
|
159
|
+
|
160
|
+
await playing(client, interaction);
|
161
|
+
|
162
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
163
|
+
|
164
|
+
const skiped_track = (await useMainPlayer().search(client.ctrack[interaction.guildId][0]))._data.tracks[0].title
|
165
|
+
|
166
|
+
embeds = await update_embed(client, interaction);
|
167
|
+
|
168
|
+
var curr_page = 0;
|
169
|
+
var max_page = embeds.length - 1;
|
170
|
+
|
171
|
+
var view = await update_component(curr_page, max_page, embeds);
|
172
|
+
|
173
|
+
await confirmation.update({
|
174
|
+
content: `You have skiped track ${curr_track} to ${skiped_track}`,
|
175
|
+
embeds: [embeds[curr_page]],
|
176
|
+
components: view,
|
177
|
+
});
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
|
181
|
+
embeds = await update_embed(client, interaction);
|
182
|
+
|
183
|
+
var curr_page = 0;
|
184
|
+
var max_page = embeds.length - 1;
|
185
|
+
|
186
|
+
var view = await update_component(curr_page, max_page, embeds);
|
187
|
+
|
188
|
+
const queue = useQueue(confirmation.guildId);
|
189
|
+
|
190
|
+
const curr_track = queue.currentTrack.title;
|
191
|
+
|
192
|
+
await confirmation.update({
|
193
|
+
content: `You can't skop track ${curr_track}`,
|
194
|
+
embeds: [embeds[curr_page]],
|
195
|
+
components: view,
|
196
|
+
});
|
197
|
+
}
|
198
|
+
}
|
199
|
+
else if (confirmation.customId === 'reset') {
|
200
|
+
|
201
|
+
|
202
|
+
embeds = await update_embed(client, interaction);
|
203
|
+
|
204
|
+
var curr_page = 0;
|
205
|
+
var max_page = embeds.length - 1;
|
206
|
+
|
207
|
+
var view = await update_component(curr_page, max_page, embeds);
|
208
|
+
|
209
|
+
await confirmation.update({
|
210
|
+
embeds: [embeds[curr_page]],
|
211
|
+
components: view,
|
212
|
+
});
|
213
|
+
}
|
214
|
+
|
215
|
+
} catch (e) {
|
216
|
+
await interaction.editReply({ content: `Confirmation not received with error, cancelling...\nError: ${e}`, components: [] });
|
217
|
+
return [];
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
const { CommandInteraction, EmbedBuilder } = require('discord.js');
|
2
|
+
const { useQueue } = require('discord-player')
|
3
|
+
|
4
|
+
module.exports = resuming
|
5
|
+
|
6
|
+
/**
|
7
|
+
*
|
8
|
+
* @param {CommandInteraction} interaction
|
9
|
+
*/
|
10
|
+
|
11
|
+
async function resuming(client, interaction) {
|
12
|
+
|
13
|
+
const queue = useQueue(interaction.guildId);
|
14
|
+
|
15
|
+
if (queue.node.isPaused()) {
|
16
|
+
queue.node.setPaused(false)
|
17
|
+
|
18
|
+
return [
|
19
|
+
new EmbedBuilder()
|
20
|
+
.setTitle(`I have resumed the queue`)
|
21
|
+
.setThumbnail(queue.currentTrack.thumbnail)
|
22
|
+
.setColor(client.get_color())
|
23
|
+
.addFields([
|
24
|
+
{
|
25
|
+
name: `Current track:`,
|
26
|
+
value: `${queue.currentTrack.title}`
|
27
|
+
},
|
28
|
+
{
|
29
|
+
name: `Author:`,
|
30
|
+
value: `${queue.currentTrack.author}`,
|
31
|
+
},
|
32
|
+
{
|
33
|
+
name: `Now timestamp:`,
|
34
|
+
value: `${queue.node.getTimestamp().current.label} / ${queue.node.getTimestamp().total.label}`
|
35
|
+
}
|
36
|
+
])
|
37
|
+
]
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
return [
|
41
|
+
new EmbedBuilder()
|
42
|
+
.setColor(client.get_color())
|
43
|
+
.addFields([
|
44
|
+
{
|
45
|
+
name: `I can't resume the queue`,
|
46
|
+
value: `Reason : I'm not pausing now`
|
47
|
+
}
|
48
|
+
])
|
49
|
+
]
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
const { CommandInteraction, EmbedBuilder } = require('discord.js');
|
2
|
+
const { useQueue } = require('discord-player')
|
3
|
+
|
4
|
+
|
5
|
+
module.exports = set_loop
|
6
|
+
|
7
|
+
/**
|
8
|
+
*
|
9
|
+
*
|
10
|
+
* @param {CommandInteraction} interaction
|
11
|
+
*/
|
12
|
+
|
13
|
+
async function set_loop(client, interaction, mode) {
|
14
|
+
|
15
|
+
const queue = useQueue(interaction.guildId);
|
16
|
+
|
17
|
+
queue.setRepeatMode(Number(mode))
|
18
|
+
client.isloop[interaction.guildId] = mode;
|
19
|
+
|
20
|
+
var bruh = {
|
21
|
+
0: 'Disabled Repeated mode',
|
22
|
+
1: 'Track Repeated mode',
|
23
|
+
2: 'Queue Repeated mode',
|
24
|
+
3: 'Autoplay Mode'
|
25
|
+
}
|
26
|
+
|
27
|
+
return [
|
28
|
+
new EmbedBuilder()
|
29
|
+
.setColor(client.get_color())
|
30
|
+
.addFields({
|
31
|
+
name: `Current queue repeated mode has been changed`,
|
32
|
+
value: `Current: ${bruh[Number(mode)]}`
|
33
|
+
})
|
34
|
+
]
|
35
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
const { CommandInteraction, EmbedBuilder } = require('discord.js');
|
2
|
+
|
3
|
+
module.exports = shuffling
|
4
|
+
|
5
|
+
/**
|
6
|
+
*
|
7
|
+
*
|
8
|
+
* @param {CommandInteraction} interaction
|
9
|
+
*/
|
10
|
+
|
11
|
+
async function shuffling(client, interaction) {
|
12
|
+
|
13
|
+
var array = client.ctrack[interaction.guildId];
|
14
|
+
for (let i = array.length - 1; i > 0; i--) {
|
15
|
+
const j = Math.floor(Math.random() * (i + 1));
|
16
|
+
[array[i], array[j]] = [array[j], array[i]];
|
17
|
+
}
|
18
|
+
|
19
|
+
client.ctrack[interaction.guildId] = array;
|
20
|
+
|
21
|
+
return [
|
22
|
+
new EmbedBuilder()
|
23
|
+
.setColor(client.get_color())
|
24
|
+
.setTitle(`Your queue has been shuffled`)
|
25
|
+
]
|
26
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
const { CommandInteraction, EmbedBuilder } = require('discord.js');
|
2
|
+
const { useQueue, useMainPlayer } = require('discord-player')
|
3
|
+
const _ = require('lodash')
|
4
|
+
const playing = require('./support/playing')
|
5
|
+
|
6
|
+
module.exports = skipping
|
7
|
+
|
8
|
+
/**
|
9
|
+
*
|
10
|
+
* @param {CommandInteraction} interaction
|
11
|
+
*/
|
12
|
+
|
13
|
+
async function skipping(client, interaction) {
|
14
|
+
const infront = client.ctrack[interaction.guildId].shift();
|
15
|
+
const inafter = client.ctrack[interaction.guildId].slice(1);
|
16
|
+
|
17
|
+
client.ctrack[interaction.guildId] = inafter;
|
18
|
+
|
19
|
+
if (_.get(client.isloop, interaction.guildId, undefined) === '2') {
|
20
|
+
client.ctrack[interaction.guildId].push(infront)
|
21
|
+
}
|
22
|
+
else if (_.get(client.isloop, interaction.guildId, undefined) === '0') {
|
23
|
+
client.ptrack[interaction.guildId].push(infront)
|
24
|
+
}
|
25
|
+
|
26
|
+
const queue = useQueue(interaction.guildId);
|
27
|
+
|
28
|
+
const curr_track = queue.currentTrack.title;
|
29
|
+
|
30
|
+
useQueue(interaction.guildId).node.stop();
|
31
|
+
|
32
|
+
await playing(client, interaction);
|
33
|
+
|
34
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
35
|
+
var skiped_track;
|
36
|
+
|
37
|
+
if (client.ctrack[interaction.guildId].length > 0) {
|
38
|
+
skiped_track = (await useMainPlayer().search(client.ctrack[interaction.guildId][0]))._data.tracks[0].title
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
return [
|
42
|
+
new EmbedBuilder()
|
43
|
+
.setFooter({
|
44
|
+
text: `Page 1 of 1`,
|
45
|
+
})
|
46
|
+
.setColor(client.get_color())
|
47
|
+
.addFields(
|
48
|
+
{
|
49
|
+
name: `Your queue don't have any track`,
|
50
|
+
value: ' '
|
51
|
+
}
|
52
|
+
)]
|
53
|
+
}
|
54
|
+
|
55
|
+
return [
|
56
|
+
new EmbedBuilder()
|
57
|
+
.setTitle(`You have skipped track ${curr_track}`)
|
58
|
+
.setColor(client.get_color())
|
59
|
+
.setFields({
|
60
|
+
name: `Current track:`,
|
61
|
+
value: `${skiped_track}`
|
62
|
+
})
|
63
|
+
]
|
64
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
const { CommandInteraction, EmbedBuilder } = require('discord.js');
|
2
|
+
const { useQueue } = require('discord-player')
|
3
|
+
|
4
|
+
module.exports = stopping
|
5
|
+
/**
|
6
|
+
*
|
7
|
+
*
|
8
|
+
* @param {CommandInteraction} interaction
|
9
|
+
*/
|
10
|
+
|
11
|
+
async function stopping(client, interaction) {
|
12
|
+
const queue = useQueue(interaction.guildId);
|
13
|
+
|
14
|
+
if (!queue.deleted) {
|
15
|
+
const channell = queue.channel;
|
16
|
+
client.ctrack[interaction.guildId] = []
|
17
|
+
|
18
|
+
queue.setRepeatMode(0);
|
19
|
+
|
20
|
+
queue.clear();
|
21
|
+
|
22
|
+
queue.node.stop();
|
23
|
+
|
24
|
+
queue.delete();
|
25
|
+
|
26
|
+
return [
|
27
|
+
new EmbedBuilder()
|
28
|
+
.setColor(client.get_color())
|
29
|
+
.setTitle(`I have stopped and leaved ${channell}`)
|
30
|
+
]
|
31
|
+
}
|
32
|
+
|
33
|
+
return [
|
34
|
+
new EmbedBuilder()
|
35
|
+
.setColor(client.get_color())
|
36
|
+
.setTitle(`I have stopped and leaved Voice channel`)
|
37
|
+
]
|
38
|
+
}
|
@@ -0,0 +1,236 @@
|
|
1
|
+
const {
|
2
|
+
CommandInteraction,
|
3
|
+
EmbedBuilder,
|
4
|
+
ActionRowBuilder,
|
5
|
+
ButtonBuilder,
|
6
|
+
ButtonStyle,
|
7
|
+
} = require("discord.js");
|
8
|
+
var _ = require("lodash");
|
9
|
+
const { discordClient } = require("../../../client");
|
10
|
+
const { QueryType, useMainPlayer } = require("discord-player");
|
11
|
+
|
12
|
+
/**
|
13
|
+
*
|
14
|
+
* @param {CommandInteraction} interaction
|
15
|
+
* @param {string} prompt
|
16
|
+
*/
|
17
|
+
async function add_to_queue(client, interaction, prompt, mode) {
|
18
|
+
var videos = await check_prompt(client, interaction, prompt, mode);
|
19
|
+
|
20
|
+
return videos;
|
21
|
+
}
|
22
|
+
|
23
|
+
module.exports = add_to_queue;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @param {discordClient} client
|
27
|
+
* @param {CommandInteraction} interaction
|
28
|
+
* @param {string} prompt
|
29
|
+
* @returns
|
30
|
+
*/
|
31
|
+
async function check_prompt(client, interaction, prompt, mode) {
|
32
|
+
const user = interaction.deferred ? interaction.user : interaction.author;
|
33
|
+
const player = useMainPlayer();
|
34
|
+
var searchResult;
|
35
|
+
|
36
|
+
if (mode == "youtube") {
|
37
|
+
searchResult = await player.search(prompt, {
|
38
|
+
requestedBy: interaction.user,
|
39
|
+
|
40
|
+
searchEngine: QueryType.YOUTUBE_SEARCH,
|
41
|
+
});
|
42
|
+
} else if (mode == "spotify") {
|
43
|
+
searchResult = await player.search(prompt, {
|
44
|
+
requestedBy: interaction.user,
|
45
|
+
searchEngine: QueryType.SPOTIFY_SEARCH,
|
46
|
+
});
|
47
|
+
} else if (mode == "soundcloud") {
|
48
|
+
searchResult = await player.search(prompt, {
|
49
|
+
requestedBy: interaction.user,
|
50
|
+
searchEngine: QueryType.SOUNDCLOUD_SEARCH,
|
51
|
+
});
|
52
|
+
}
|
53
|
+
|
54
|
+
const vidsresult = searchResult.tracks;
|
55
|
+
var embeds = [];
|
56
|
+
var color = client.get_color();
|
57
|
+
|
58
|
+
vidsresult.forEach((item) => {
|
59
|
+
var time = item.duration;
|
60
|
+
var timee = time.split(":");
|
61
|
+
|
62
|
+
timee = timee.reverse();
|
63
|
+
|
64
|
+
var hours, minutes, seconds, days, weeks, months, years;
|
65
|
+
|
66
|
+
seconds = Number(timee[0]);
|
67
|
+
minutes = Number(timee[1]);
|
68
|
+
hours = timee.length > 2 ? Number(timee[2]) : 0;
|
69
|
+
|
70
|
+
days = Math.floor(hours / 24);
|
71
|
+
weeks = Math.floor(days / 7);
|
72
|
+
months = Math.floor(weeks / 4);
|
73
|
+
years = Math.floor(months / 12);
|
74
|
+
|
75
|
+
months = months % 12;
|
76
|
+
hours = hours % 24;
|
77
|
+
days = days % 7;
|
78
|
+
weeks = weeks % 4;
|
79
|
+
|
80
|
+
var dur = "";
|
81
|
+
|
82
|
+
dur += years !== 0 ? `${years} years ` : ` `;
|
83
|
+
dur += months !== 0 ? `${months} months ` : ` `;
|
84
|
+
dur += weeks !== 0 ? `${weeks} weeks ` : ` `;
|
85
|
+
dur += days !== 0 ? `${days} days ` : ` `;
|
86
|
+
dur += hours !== 0 ? `${hours} hours ` : ` `;
|
87
|
+
dur += minutes !== 0 ? `${minutes} minutes ` : ` `;
|
88
|
+
dur += seconds !== 0 ? `${seconds} seconds ` : ` `;
|
89
|
+
|
90
|
+
const embeb = new EmbedBuilder()
|
91
|
+
.setColor(color)
|
92
|
+
.setDescription("Chose your track:)")
|
93
|
+
.setThumbnail(item.thumbnail)
|
94
|
+
.addFields(
|
95
|
+
{
|
96
|
+
name: "Track's name:",
|
97
|
+
value: item.title,
|
98
|
+
inline: false,
|
99
|
+
},
|
100
|
+
{
|
101
|
+
name: "Author:",
|
102
|
+
value: item.author,
|
103
|
+
inline: false,
|
104
|
+
},
|
105
|
+
{
|
106
|
+
name: "Duration:",
|
107
|
+
value: dur,
|
108
|
+
inline: false,
|
109
|
+
}
|
110
|
+
);
|
111
|
+
|
112
|
+
embeds.push({
|
113
|
+
embeb: embeb,
|
114
|
+
link: item.url,
|
115
|
+
});
|
116
|
+
});
|
117
|
+
|
118
|
+
var curr_page = 0;
|
119
|
+
var max_page = vidsresult.length - 1;
|
120
|
+
|
121
|
+
var view = await update_component(curr_page, max_page);
|
122
|
+
|
123
|
+
var response = interaction.deferred
|
124
|
+
? await interaction.followUp({
|
125
|
+
embeds: [embeds[curr_page].embeb],
|
126
|
+
components: view,
|
127
|
+
})
|
128
|
+
: await interaction.reply({
|
129
|
+
embeds: [embeds[curr_page].embeb],
|
130
|
+
components: view,
|
131
|
+
});
|
132
|
+
|
133
|
+
var done = false;
|
134
|
+
while (done == false) {
|
135
|
+
const collectorFilter = (i) => i.user.id === user.id;
|
136
|
+
try {
|
137
|
+
const confirmation = await response.awaitMessageComponent({
|
138
|
+
filter: collectorFilter,
|
139
|
+
});
|
140
|
+
|
141
|
+
if (confirmation.customId === "<<") {
|
142
|
+
curr_page = 0;
|
143
|
+
view = await update_component(curr_page, max_page);
|
144
|
+
await confirmation.update({
|
145
|
+
embeds: [embeds[curr_page].embeb],
|
146
|
+
components: view,
|
147
|
+
});
|
148
|
+
} else if (confirmation.customId === "<") {
|
149
|
+
curr_page--;
|
150
|
+
view = await update_component(curr_page, max_page);
|
151
|
+
await confirmation.update({
|
152
|
+
embeds: [embeds[curr_page].embeb],
|
153
|
+
components: view,
|
154
|
+
});
|
155
|
+
} else if (confirmation.customId === ">") {
|
156
|
+
curr_page++;
|
157
|
+
view = await update_component(curr_page, max_page);
|
158
|
+
await confirmation.update({
|
159
|
+
embeds: [embeds[curr_page].embeb],
|
160
|
+
components: view,
|
161
|
+
});
|
162
|
+
} else if (confirmation.customId === ">>") {
|
163
|
+
curr_page = max_page;
|
164
|
+
view = await update_component(curr_page, max_page);
|
165
|
+
await confirmation.update({
|
166
|
+
embeds: [embeds[curr_page].embeb],
|
167
|
+
components: view,
|
168
|
+
});
|
169
|
+
} else if (confirmation.customId === "noice") {
|
170
|
+
await confirmation.update({
|
171
|
+
content: "You have chosen this track:",
|
172
|
+
embeds: [embeds[curr_page].embeb],
|
173
|
+
components: [],
|
174
|
+
});
|
175
|
+
|
176
|
+
return [embeds[curr_page].link];
|
177
|
+
} else if (confirmation.customId === "nope") {
|
178
|
+
await confirmation.update({
|
179
|
+
content: "You haven't chosen any track",
|
180
|
+
embeds: [],
|
181
|
+
components: [],
|
182
|
+
});
|
183
|
+
|
184
|
+
return [];
|
185
|
+
}
|
186
|
+
} catch (e) {
|
187
|
+
await response.edit({
|
188
|
+
content: `Confirmation not received with error, cancelling...\nError: ${e}`,
|
189
|
+
components: [],
|
190
|
+
});
|
191
|
+
return [];
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
async function update_component(curr, maxx) {
|
197
|
+
var butt1 = new ButtonBuilder()
|
198
|
+
.setLabel("<<")
|
199
|
+
.setCustomId("<<")
|
200
|
+
.setStyle(ButtonStyle.Primary)
|
201
|
+
.setDisabled(curr == 0 ? true : false);
|
202
|
+
|
203
|
+
var butt2 = new ButtonBuilder()
|
204
|
+
.setLabel("<")
|
205
|
+
.setCustomId("<")
|
206
|
+
.setStyle(ButtonStyle.Primary)
|
207
|
+
.setDisabled(curr == 0 ? true : false);
|
208
|
+
|
209
|
+
var butt3 = new ButtonBuilder()
|
210
|
+
.setLabel(">")
|
211
|
+
.setCustomId(">")
|
212
|
+
.setStyle(ButtonStyle.Primary)
|
213
|
+
.setDisabled(curr == maxx ? true : false);
|
214
|
+
|
215
|
+
var butt4 = new ButtonBuilder()
|
216
|
+
.setLabel(">>")
|
217
|
+
.setCustomId(">>")
|
218
|
+
.setStyle(ButtonStyle.Primary)
|
219
|
+
.setDisabled(curr == maxx ? true : false);
|
220
|
+
|
221
|
+
var confirm = new ButtonBuilder()
|
222
|
+
.setLabel("✅")
|
223
|
+
.setCustomId("noice")
|
224
|
+
.setStyle(ButtonStyle.Success);
|
225
|
+
|
226
|
+
var nope = new ButtonBuilder()
|
227
|
+
.setLabel("❌")
|
228
|
+
.setCustomId("nope")
|
229
|
+
.setStyle(ButtonStyle.Danger);
|
230
|
+
|
231
|
+
var view1 = new ActionRowBuilder().addComponents(butt2, butt4, confirm);
|
232
|
+
|
233
|
+
var view2 = new ActionRowBuilder().addComponents(butt1, butt3, nope);
|
234
|
+
|
235
|
+
return [view1, view2];
|
236
|
+
}
|