Anri Kennel
b585b15959
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
- Resolve #65 - Update domain name - Add autocompletion support - Use debian instead of alpine based image Co-authored-by: Mylloon <kennel.anri@tutanota.com> Reviewed-on: #76
73 lines
2 KiB
TypeScript
73 lines
2 KiB
TypeScript
import { useQueue } from "discord-player";
|
|
import {
|
|
ActionRowBuilder,
|
|
ButtonBuilder,
|
|
ButtonStyle,
|
|
Client,
|
|
EmbedBuilder,
|
|
MessageComponentInteraction,
|
|
} from "discord.js";
|
|
import { v4 as uuidv4 } from "uuid";
|
|
import { getLocale } from "../../utils/locales";
|
|
import { getFilename } from "../../utils/misc";
|
|
import { embedListQueue } from "../../utils/music";
|
|
import { collect } from "../loader";
|
|
|
|
export default {
|
|
data: {
|
|
name: getFilename(__filename),
|
|
},
|
|
interaction: async (interaction: MessageComponentInteraction, client: Client) => {
|
|
const loc = getLocale(client, interaction.locale);
|
|
const embed_desc = interaction.message.embeds.at(0)?.author?.name as string;
|
|
|
|
// Retrieve Pages
|
|
const pageMax = Number(/(\d+)(?!.*\d)/gm.exec(embed_desc)?.[0]);
|
|
let page = Number(/(?!• \s+)\d(?=\/)/gm.exec(embed_desc)?.[0]);
|
|
if (page + 1 > pageMax) {
|
|
page = 1;
|
|
} else {
|
|
page++;
|
|
}
|
|
|
|
// Get queue
|
|
const queue = useQueue(interaction.guildId ?? "");
|
|
|
|
const embed = new EmbedBuilder();
|
|
const rows = [];
|
|
if (queue) {
|
|
// Create the embed
|
|
embedListQueue(client, embed, queue, page, interaction.locale);
|
|
|
|
// Create buttons
|
|
const idPrec = "queueList-prec_" + uuidv4();
|
|
const idNext = "queueList-next_" + uuidv4();
|
|
rows.push(
|
|
new ActionRowBuilder<ButtonBuilder>()
|
|
.addComponents(
|
|
new ButtonBuilder()
|
|
.setCustomId(idPrec)
|
|
.setLabel(loc.get("c_queue8"))
|
|
.setStyle(ButtonStyle.Primary)
|
|
)
|
|
.addComponents(
|
|
new ButtonBuilder()
|
|
.setCustomId(idNext)
|
|
.setLabel(loc.get("c_queue9"))
|
|
.setStyle(ButtonStyle.Primary)
|
|
)
|
|
);
|
|
|
|
// Buttons interactions
|
|
collect(client, interaction, idPrec);
|
|
collect(client, interaction, idNext);
|
|
} else {
|
|
// In case queue doesn't exists
|
|
embed.setDescription(loc.get("c_queue2"));
|
|
}
|
|
return {
|
|
embeds: [embed],
|
|
components: rows,
|
|
};
|
|
},
|
|
};
|