@aluffyz/discord-botjs 1.4.0
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.
Potentially problematic release.
This version of @aluffyz/discord-botjs 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 +78 -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,78 @@
|
|
|
1
|
+
const { CommandInteraction } = require("discord.js");
|
|
2
|
+
const { useQueue, useMainPlayer } = require("discord-player");
|
|
3
|
+
const _ = require("lodash");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {*} client
|
|
7
|
+
* @param {CommandInteraction} interaction
|
|
8
|
+
*/
|
|
9
|
+
async function playing(client, interaction) {
|
|
10
|
+
const check = useQueue(interaction.guildId);
|
|
11
|
+
|
|
12
|
+
var user;
|
|
13
|
+
if (interaction.deferred) {
|
|
14
|
+
user = interaction.user;
|
|
15
|
+
} else {
|
|
16
|
+
user = interaction.author;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (check && check.node.isPlaying()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const player = useMainPlayer();
|
|
24
|
+
|
|
25
|
+
while (client.ctrack[interaction.guildId].length > 0) {
|
|
26
|
+
const urrl = client.ctrack[interaction.guildId][0] ?? "None";
|
|
27
|
+
|
|
28
|
+
if (urrl === "None") return;
|
|
29
|
+
|
|
30
|
+
await player.play(interaction.member.voice.channel, urrl, {
|
|
31
|
+
nodeOptions: {
|
|
32
|
+
leaveOnEmpty: true,
|
|
33
|
+
leaveOnEmptyCooldown: 300_000,
|
|
34
|
+
leaveOnEnd: true,
|
|
35
|
+
leaveOnEndCooldown: 300_000,
|
|
36
|
+
leaveOnStop: true,
|
|
37
|
+
leaveOnStopCooldown: 300_000,
|
|
38
|
+
maxSize: 1000,
|
|
39
|
+
maxHistorySize: 100,
|
|
40
|
+
volume: 50,
|
|
41
|
+
bufferingTimeout: 3000,
|
|
42
|
+
connectionTimeout: 30000,
|
|
43
|
+
metadata: {
|
|
44
|
+
requestedBy: user,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await sleep(3000);
|
|
50
|
+
|
|
51
|
+
const queue = useQueue(interaction.guildId);
|
|
52
|
+
const curr = queue.currentTrack;
|
|
53
|
+
|
|
54
|
+
while (queue.node.isPlaying()) {
|
|
55
|
+
await sleep(100);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (client.ctrack[interaction.guildId].length > 0)
|
|
59
|
+
if (
|
|
60
|
+
(await useMainPlayer().search(client.ctrack[interaction.guildId][0]))
|
|
61
|
+
._data.tracks[0] == curr
|
|
62
|
+
) {
|
|
63
|
+
if (client.isloop[interaction.guildId] === "2") {
|
|
64
|
+
const first = client.ctrack[interaction.guildId].shift();
|
|
65
|
+
client.ctrack[interaction.guildId].push(first);
|
|
66
|
+
} else if (client.isloop[interaction.guildId] !== "1") {
|
|
67
|
+
const first = client.ctrack[interaction.guildId].shift();
|
|
68
|
+
client.ptrack[interaction.guildId].push(first);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function sleep(ms) {
|
|
75
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = playing;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const { CommandInteraction, EmbedBuilder, ActionRowBuilder, ButtonBuilder } = require('discord.js');
|
|
2
|
+
const { ButtonStyle, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } = require('discord.js');
|
|
3
|
+
const { useMainPlayer } = require('discord-player')
|
|
4
|
+
const _ = require('lodash')
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
update_component, update_embed
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {CommandInteraction} interaction
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
async function update_embed(client, interaction) {
|
|
16
|
+
|
|
17
|
+
const tracks = client.ctrack[interaction.guildId];
|
|
18
|
+
|
|
19
|
+
const queueLength = (_.get(client.ctrack, interaction.guildId, 'None') == 'None') ? 0 : client.ctrack[interaction.guildId].length || 0;
|
|
20
|
+
|
|
21
|
+
if (queueLength == 0) {
|
|
22
|
+
return [
|
|
23
|
+
new EmbedBuilder()
|
|
24
|
+
.setFooter({
|
|
25
|
+
text: `Page 1 of 1`,
|
|
26
|
+
})
|
|
27
|
+
.setColor(client.get_color())
|
|
28
|
+
.addFields(
|
|
29
|
+
{
|
|
30
|
+
name: `Your queue don't have any track`,
|
|
31
|
+
value: ' '
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
const totalPages = Math.ceil(queueLength / 10) || 1;
|
|
37
|
+
|
|
38
|
+
const player = useMainPlayer()
|
|
39
|
+
|
|
40
|
+
var embeds = []
|
|
41
|
+
|
|
42
|
+
var j = 1;
|
|
43
|
+
while (j <= totalPages) {
|
|
44
|
+
var ava = (interaction.deferred) ? interaction.user.displayAvatarURL() : interaction.author.displayAvatarURL();
|
|
45
|
+
var emmm = new EmbedBuilder()
|
|
46
|
+
.setThumbnail(ava)
|
|
47
|
+
.setColor(client.get_color())
|
|
48
|
+
.setFooter({
|
|
49
|
+
text: `Page ${j} of ${totalPages}`
|
|
50
|
+
})
|
|
51
|
+
embeds.push(emmm);
|
|
52
|
+
j++;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var i = 0;
|
|
56
|
+
|
|
57
|
+
for (const track of tracks) {
|
|
58
|
+
const search = await player.search(track)
|
|
59
|
+
embeds[Math.floor(i / 10)].addFields({
|
|
60
|
+
name: `${i + 1}/> ${search.tracks[0].title}`,
|
|
61
|
+
value: ' ',
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
i++;
|
|
65
|
+
}
|
|
66
|
+
return embeds;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param {[]} embeds
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
async function update_component(curr, maxx, embeds) {
|
|
76
|
+
|
|
77
|
+
if (embeds[0].data.fields[0].value == ' ')
|
|
78
|
+
return [];
|
|
79
|
+
|
|
80
|
+
var butt1 = new ButtonBuilder()
|
|
81
|
+
.setLabel("⏪")
|
|
82
|
+
.setCustomId("<<")
|
|
83
|
+
.setStyle(ButtonStyle.Primary)
|
|
84
|
+
.setDisabled((curr == 0) ? true : false)
|
|
85
|
+
|
|
86
|
+
var butt2 = new ButtonBuilder()
|
|
87
|
+
.setLabel("◀️")
|
|
88
|
+
.setCustomId("<")
|
|
89
|
+
.setStyle(ButtonStyle.Primary)
|
|
90
|
+
.setDisabled((curr == 0) ? true : false)
|
|
91
|
+
|
|
92
|
+
var butt3 = new ButtonBuilder()
|
|
93
|
+
.setLabel("▶️")
|
|
94
|
+
.setCustomId(">")
|
|
95
|
+
.setStyle(ButtonStyle.Primary)
|
|
96
|
+
.setDisabled(curr == maxx ? true : false)
|
|
97
|
+
|
|
98
|
+
var butt4 = new ButtonBuilder()
|
|
99
|
+
.setLabel("⏩")
|
|
100
|
+
.setCustomId(">>")
|
|
101
|
+
.setStyle(ButtonStyle.Primary)
|
|
102
|
+
.setDisabled(curr == maxx ? true : false)
|
|
103
|
+
|
|
104
|
+
var confirm = new ButtonBuilder()
|
|
105
|
+
.setLabel("✅")
|
|
106
|
+
.setCustomId("noice")
|
|
107
|
+
.setStyle(ButtonStyle.Success)
|
|
108
|
+
|
|
109
|
+
var nope = new ButtonBuilder()
|
|
110
|
+
.setLabel("❌")
|
|
111
|
+
.setCustomId("nope")
|
|
112
|
+
.setStyle(ButtonStyle.Danger)
|
|
113
|
+
|
|
114
|
+
var reset = new ButtonBuilder()
|
|
115
|
+
.setLabel("🔃")
|
|
116
|
+
.setCustomId("reset")
|
|
117
|
+
.setStyle(ButtonStyle.Primary)
|
|
118
|
+
|
|
119
|
+
var delete_select = new StringSelectMenuBuilder()
|
|
120
|
+
.setCustomId('delete')
|
|
121
|
+
.setPlaceholder('What track do you want to delete?')
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
for (i = 1; i <= embeds[curr].data.fields.length; i++) {
|
|
125
|
+
delete_select.addOptions(
|
|
126
|
+
new StringSelectMenuOptionBuilder()
|
|
127
|
+
.setLabel(`${curr * 10 + i}`)
|
|
128
|
+
.setValue(`${curr * 10 + i}`),
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
var skip_select = new StringSelectMenuBuilder()
|
|
133
|
+
.setCustomId('skip')
|
|
134
|
+
.setPlaceholder('What track do you want to skip to?')
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
for (i = 1; i <= embeds[curr].data.fields.length; i++) {
|
|
138
|
+
skip_select.addOptions(
|
|
139
|
+
new StringSelectMenuOptionBuilder()
|
|
140
|
+
.setLabel(`${curr * 10 + i}`)
|
|
141
|
+
.setValue(`${curr * 10 + i}`),
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var view1 = new ActionRowBuilder()
|
|
146
|
+
.addComponents(butt1, butt2, butt3, butt4)
|
|
147
|
+
|
|
148
|
+
var view2 = new ActionRowBuilder()
|
|
149
|
+
.addComponents(confirm, nope, reset)
|
|
150
|
+
|
|
151
|
+
var view3 = new ActionRowBuilder()
|
|
152
|
+
.addComponents(delete_select)
|
|
153
|
+
|
|
154
|
+
var view4 = new ActionRowBuilder()
|
|
155
|
+
.addComponents(skip_select)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
return [view1, view2, view3, view4];
|
|
159
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { CommandInteraction, Message } = require('discord.js');
|
|
2
|
+
const discordClient = require('../../client');
|
|
3
|
+
const { conversation_style } = require('bingai-js');
|
|
4
|
+
|
|
5
|
+
module.exports = get_result;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {discordClient} client
|
|
9
|
+
* @param {CommandInteraction} interaction
|
|
10
|
+
* @param {Message} interaction
|
|
11
|
+
* @param {string} prompt
|
|
12
|
+
* @param {string} chatbot
|
|
13
|
+
*/
|
|
14
|
+
async function get_result(client, interaction, prompt, chatbot) {
|
|
15
|
+
chatbot = chatbot.toLowerCase();
|
|
16
|
+
return new Promise(async (resolve) => {
|
|
17
|
+
try {
|
|
18
|
+
var res = ""
|
|
19
|
+
if (chatbot == "bard") {
|
|
20
|
+
await client.BardChatBot.ask(prompt).then(data => {
|
|
21
|
+
res = data
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
await client.EdgeChatBot.init()
|
|
26
|
+
if (chatbot == "creative") {
|
|
27
|
+
res = await client.EdgeChatBot.ask(prompt, conversation_style.creative);
|
|
28
|
+
}
|
|
29
|
+
else if (chatbot == "balanced") {
|
|
30
|
+
res = await client.EdgeChatBot.ask(prompt, conversation_style.balanced);
|
|
31
|
+
}
|
|
32
|
+
else if (chatbot == "precise") {
|
|
33
|
+
res = await client.EdgeChatBot.ask(prompt, conversation_style.precise);
|
|
34
|
+
}
|
|
35
|
+
client.EdgeChatBot.close();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resolve(res)
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
resolve(e);
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { CommandInteraction, EmbedBuilder } = require('discord.js');
|
|
2
|
+
|
|
3
|
+
module.exports = get_ping
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @param {CommandInteraction} interaction
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
async function get_ping(client, interaction) {
|
|
11
|
+
return [
|
|
12
|
+
new EmbedBuilder()
|
|
13
|
+
.setTitle(`CLient's Latency`)
|
|
14
|
+
.setColor(client.get_color())
|
|
15
|
+
.addFields([
|
|
16
|
+
{
|
|
17
|
+
name: `Ping:`,
|
|
18
|
+
value: `${Date.now() - interaction.createdTimestamp}ms`
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: `API Latency:`,
|
|
22
|
+
value: `${Math.round(client.client.ws.ping)}ms`
|
|
23
|
+
}
|
|
24
|
+
])
|
|
25
|
+
]
|
|
26
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const { CommandInteraction, EmbedBuilder } = require("discord.js");
|
|
2
|
+
|
|
3
|
+
module.exports = get_status;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {CommandInteraction} interaction
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
async function get_status(client, interaction) {
|
|
11
|
+
var user = interaction.deferred ? interaction.user : interaction.author;
|
|
12
|
+
|
|
13
|
+
const color = client.get_color();
|
|
14
|
+
|
|
15
|
+
const guilds = client.client.guilds.cache;
|
|
16
|
+
|
|
17
|
+
var members = 0;
|
|
18
|
+
|
|
19
|
+
guilds.forEach((guild) => {
|
|
20
|
+
members += guild.memberCount;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
new EmbedBuilder()
|
|
25
|
+
.setTitle(`${client.name} Client`)
|
|
26
|
+
.setColor(color)
|
|
27
|
+
.addFields([
|
|
28
|
+
{
|
|
29
|
+
name: `Total servers:`,
|
|
30
|
+
value: `${client.client.guilds.cache.size}`,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: `Total members:`,
|
|
34
|
+
value: `${members}`,
|
|
35
|
+
},
|
|
36
|
+
]),
|
|
37
|
+
new EmbedBuilder()
|
|
38
|
+
.setTitle(`This Server`)
|
|
39
|
+
.setColor(color)
|
|
40
|
+
.addFields([
|
|
41
|
+
{
|
|
42
|
+
name: `Name:`,
|
|
43
|
+
value: `${interaction.guild.name}`,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: `Total members:`,
|
|
47
|
+
value: `${interaction.guild.memberCount}`,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: `Total channels:`,
|
|
51
|
+
value: `${interaction.guild.channels.cache.size}`,
|
|
52
|
+
},
|
|
53
|
+
]),
|
|
54
|
+
new EmbedBuilder()
|
|
55
|
+
.setTitle(`This User`)
|
|
56
|
+
.setColor(color)
|
|
57
|
+
.addFields([
|
|
58
|
+
{
|
|
59
|
+
name: `Name:`,
|
|
60
|
+
value: `${user.displayName}`,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: `Highest role:`,
|
|
64
|
+
value: `${interaction.member.roles.highest.name}`,
|
|
65
|
+
},
|
|
66
|
+
]),
|
|
67
|
+
new EmbedBuilder()
|
|
68
|
+
.setTitle(`Client Status`)
|
|
69
|
+
.setColor(color)
|
|
70
|
+
.addFields([
|
|
71
|
+
{
|
|
72
|
+
name: `Version:`,
|
|
73
|
+
value: `${client.version}`,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: `CLient Latency:`,
|
|
77
|
+
value: `${Date.now() - interaction.createdTimestamp}ms`,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: `API Latency:`,
|
|
81
|
+
value: `${Math.round(client.client.ws.ping)}ms`,
|
|
82
|
+
},
|
|
83
|
+
]),
|
|
84
|
+
];
|
|
85
|
+
}
|