chore: merge dev to main #177
13 changed files with 82 additions and 58 deletions
|
@ -19,7 +19,7 @@ export default {
|
||||||
},
|
},
|
||||||
interaction: async (interaction: MessageComponentInteraction, client: Client) => {
|
interaction: async (interaction: MessageComponentInteraction, client: Client) => {
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const embed_desc = interaction.message.embeds.at(0)?.author?.name as string;
|
const embed_desc = interaction.message.embeds.at(0)!.author!.name;
|
||||||
|
|
||||||
// Retrieve Pages
|
// Retrieve Pages
|
||||||
const pageMax = Number(/(\d+)(?!.*\d)/gm.exec(embed_desc)?.[0]);
|
const pageMax = Number(/(\d+)(?!.*\d)/gm.exec(embed_desc)?.[0]);
|
||||||
|
|
|
@ -64,14 +64,14 @@ export default async (client: Client) => {
|
||||||
|
|
||||||
scopedCommands.forEach(
|
scopedCommands.forEach(
|
||||||
async (command, guild) =>
|
async (command, guild) =>
|
||||||
await rest.put(Routes.applicationGuildCommands(client.user?.id as string, guild), {
|
await rest.put(Routes.applicationGuildCommands(client.user!.id, guild), {
|
||||||
body: command,
|
body: command,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send global commands to Discord
|
// Send global commands to Discord
|
||||||
const globalCommands = commands.filter((c) => c.scope().length === 0);
|
const globalCommands = commands.filter((c) => c.scope().length === 0);
|
||||||
return await rest.put(Routes.applicationCommands(client.user?.id as string), {
|
return await rest.put(Routes.applicationCommands(client.user!.id), {
|
||||||
body: globalCommands.map((c) => c.data.toJSON()),
|
body: globalCommands.map((c) => c.data.toJSON()),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,14 +145,14 @@ export default {
|
||||||
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): {
|
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): {
|
||||||
// If time is already renseigned
|
// If time is already renseigned
|
||||||
const time = interaction.options.getString(
|
const time = interaction.options.getString(
|
||||||
loc_default?.get(`c_${filename}_sub1_opt1_name`) as string,
|
loc_default!.get(`c_${filename}_sub1_opt1_name`)!,
|
||||||
);
|
);
|
||||||
if (time != null) {
|
if (time != null) {
|
||||||
// Use the cli because we already have enough data
|
// Use the cli because we already have enough data
|
||||||
return newReminder(client, time, {
|
return newReminder(client, time, {
|
||||||
locale: interaction.locale,
|
locale: interaction.locale,
|
||||||
message: interaction.options.getString(
|
message: interaction.options.getString(
|
||||||
loc_default?.get(`c_${filename}_sub1_opt2_name`) as string,
|
loc_default!.get(`c_${filename}_sub1_opt2_name`)!,
|
||||||
),
|
),
|
||||||
createdAt: interaction.createdAt.getTime(),
|
createdAt: interaction.createdAt.getTime(),
|
||||||
channelId: interaction.channelId,
|
channelId: interaction.channelId,
|
||||||
|
@ -202,17 +202,13 @@ export default {
|
||||||
// List reminders
|
// List reminders
|
||||||
case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase(): {
|
case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase(): {
|
||||||
// Which user to show
|
// Which user to show
|
||||||
let user = interaction.options.getUser(
|
let user = interaction.options.getUser(loc_default!.get(`c_${filename}_sub2_opt1_name`)!);
|
||||||
loc_default?.get(`c_${filename}_sub2_opt1_name`) as string,
|
|
||||||
);
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
user = interaction.user;
|
user = interaction.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
const page =
|
const page =
|
||||||
interaction.options.getInteger(
|
interaction.options.getInteger(loc_default!.get(`c_${filename}_sub2_opt2_name`)!) ?? 1;
|
||||||
loc_default?.get(`c_${filename}_sub2_opt2_name`) as string,
|
|
||||||
) ?? 1;
|
|
||||||
const list = await embedListReminders(
|
const list = await embedListReminders(
|
||||||
client,
|
client,
|
||||||
user,
|
user,
|
||||||
|
@ -253,7 +249,7 @@ export default {
|
||||||
// Delete a reminder
|
// Delete a reminder
|
||||||
case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): {
|
case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): {
|
||||||
const id = interaction.options.getInteger(
|
const id = interaction.options.getInteger(
|
||||||
loc_default?.get(`c_${filename}_sub3_opt1_name`) as string,
|
loc_default!.get(`c_${filename}_sub3_opt1_name`)!,
|
||||||
);
|
);
|
||||||
if (id === null) {
|
if (id === null) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
|
|
|
@ -74,9 +74,7 @@ export default {
|
||||||
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
|
|
||||||
let request = interaction.options.getString(
|
let request = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!);
|
||||||
loc_default?.get(`c_${filename}_opt1_name`) as string,
|
|
||||||
);
|
|
||||||
|
|
||||||
let data = null;
|
let data = null;
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
|
@ -27,6 +27,14 @@ export default {
|
||||||
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
|
||||||
|
|
||||||
|
// Normal
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName(loc_default.get(`c_${filename}_sub1_name`)!.toLowerCase())
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_sub1_desc`)!)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`))
|
||||||
|
|
||||||
// Command option
|
// Command option
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
|
@ -35,6 +43,26 @@ export default {
|
||||||
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
||||||
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
||||||
.setAutocomplete(true),
|
.setAutocomplete(true),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Play now
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName(loc_default.get(`c_${filename}_sub2_name`)!.toLowerCase())
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_sub2_desc`)!)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`))
|
||||||
|
|
||||||
|
// Command option
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName(loc_default.get(`c_${filename}_opt1_name`)!.toLowerCase())
|
||||||
|
.setDescription(loc_default.get(`c_${filename}_opt1_desc`)!)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
||||||
|
.setAutocomplete(true),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -65,9 +93,7 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = interaction.options.getString(
|
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!);
|
||||||
loc_default?.get(`c_${filename}_opt1_name`) as string,
|
|
||||||
);
|
|
||||||
|
|
||||||
const player = useMainPlayer();
|
const player = useMainPlayer();
|
||||||
if (!query) {
|
if (!query) {
|
||||||
|
@ -96,6 +122,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue = player.nodes.create(interaction.guild!, {
|
const queue = player.nodes.create(interaction.guild!, {
|
||||||
|
volume: 50,
|
||||||
defaultFFmpegFilters: ["silenceremove"],
|
defaultFFmpegFilters: ["silenceremove"],
|
||||||
metadata: {
|
metadata: {
|
||||||
channel: interaction.channel,
|
channel: interaction.channel,
|
||||||
|
@ -132,7 +159,15 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
const track = result.tracks[0];
|
const track = result.tracks[0];
|
||||||
|
|
||||||
|
if (
|
||||||
|
interaction.options.getSubcommand() ===
|
||||||
|
loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase()
|
||||||
|
) {
|
||||||
|
queue.insertTrack(track, 0);
|
||||||
|
} else {
|
||||||
queue.addTrack(track);
|
queue.addTrack(track);
|
||||||
|
}
|
||||||
|
|
||||||
title = track.title;
|
title = track.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,10 +189,7 @@ export default {
|
||||||
const filename = getFilename(__filename);
|
const filename = getFilename(__filename);
|
||||||
|
|
||||||
const player = useMainPlayer();
|
const player = useMainPlayer();
|
||||||
const query = interaction.options.getString(
|
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!, true);
|
||||||
loc_default?.get(`c_${filename}_opt1_name`) as string,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
const limit_value_discord = 100;
|
const limit_value_discord = 100;
|
||||||
|
|
||||||
|
|
|
@ -103,9 +103,7 @@ export default {
|
||||||
// Show the queue
|
// Show the queue
|
||||||
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): {
|
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): {
|
||||||
const page =
|
const page =
|
||||||
interaction.options.getNumber(
|
interaction.options.getNumber(loc_default!.get(`c_${filename}_sub1_opt1_name`)!) ?? 1;
|
||||||
loc_default?.get(`c_${filename}_sub1_opt1_name`) as string,
|
|
||||||
) ?? 1;
|
|
||||||
|
|
||||||
embedListQueue(client, embed, queue, page, interaction.locale);
|
embedListQueue(client, embed, queue, page, interaction.locale);
|
||||||
|
|
||||||
|
@ -152,7 +150,7 @@ export default {
|
||||||
// Remove <ID>
|
// Remove <ID>
|
||||||
case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): {
|
case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): {
|
||||||
const id = interaction.options.getNumber(
|
const id = interaction.options.getNumber(
|
||||||
loc_default?.get(`c_${filename}_sub3_opt1_name`) as string,
|
loc_default!.get(`c_${filename}_sub3_opt1_name`)!,
|
||||||
)!;
|
)!;
|
||||||
|
|
||||||
const track = queue.removeTrack(id - 1);
|
const track = queue.removeTrack(id - 1);
|
||||||
|
|
|
@ -51,10 +51,10 @@ export default async (message: Message, client: Client) => {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = message.guild.channels.cache.get(channel_id) as TextBasedChannel;
|
const channel = message.guild.channels.cache.get(channel_id);
|
||||||
|
|
||||||
// If channel doesn't exist in the guild and isn't text
|
// If channel doesn't exist in the guild and isn't text
|
||||||
if (!channel) {
|
if (!channel || !channel.isTextBased()) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +70,10 @@ export default async (message: Message, client: Client) => {
|
||||||
// If it's a reference, we only check for reference once
|
// If it's a reference, we only check for reference once
|
||||||
const message_reference = quoted_message?.reference;
|
const message_reference = quoted_message?.reference;
|
||||||
if (message_reference && message_reference.messageId) {
|
if (message_reference && message_reference.messageId) {
|
||||||
const channel_reference = client.channels.cache.get(
|
const channel_reference = client.channels.cache.get(message_reference.channelId);
|
||||||
message_reference.channelId,
|
if (!channel_reference?.isTextBased()) {
|
||||||
) as TextBasedChannel;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
quoted_message = await channel_reference.messages
|
quoted_message = await channel_reference.messages
|
||||||
.fetch(message_reference.messageId)
|
.fetch(message_reference.messageId)
|
||||||
|
@ -105,12 +106,9 @@ export default async (message: Message, client: Client) => {
|
||||||
|
|
||||||
// Handle attachments
|
// Handle attachments
|
||||||
if (quoted_post?.attachments.size !== 0) {
|
if (quoted_post?.attachments.size !== 0) {
|
||||||
if (
|
if (quoted_post?.attachments.size === 1 && isImage(quoted_post.attachments.first()!.name)) {
|
||||||
quoted_post?.attachments.size === 1 &&
|
|
||||||
isImage(quoted_post.attachments.first()?.name as string)
|
|
||||||
) {
|
|
||||||
// Only contains one image
|
// Only contains one image
|
||||||
embed.setImage(quoted_post.attachments.first()?.url as string);
|
embed.setImage(quoted_post.attachments.first()!.url);
|
||||||
} else {
|
} else {
|
||||||
// Contains more than one image and/or other files
|
// Contains more than one image and/or other files
|
||||||
let files = "";
|
let files = "";
|
||||||
|
@ -133,13 +131,9 @@ export default async (message: Message, client: Client) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
let footer = `Posté le ${showDate(
|
let footer = `Posté le ${showDate(loc, quoted_post!.createdAt)}`;
|
||||||
client.config.default_lang,
|
|
||||||
loc,
|
|
||||||
quoted_post?.createdAt as Date,
|
|
||||||
)}`;
|
|
||||||
if (quoted_post?.editedAt) {
|
if (quoted_post?.editedAt) {
|
||||||
footer += ` et modifié le ${showDate(client.config.default_lang, loc, quoted_post.editedAt)}`;
|
footer += ` et modifié le ${showDate(loc, quoted_post.editedAt)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let author = "Auteur";
|
let author = "Auteur";
|
||||||
|
@ -147,7 +141,6 @@ export default async (message: Message, client: Client) => {
|
||||||
author += " & Citateur";
|
author += " & Citateur";
|
||||||
} else {
|
} else {
|
||||||
footer += `\nCité par ${userWithNickname(message.member!) ?? "?"} le ${showDate(
|
footer += `\nCité par ${userWithNickname(message.member!) ?? "?"} le ${showDate(
|
||||||
client.config.default_lang,
|
|
||||||
loc,
|
loc,
|
||||||
message.createdAt,
|
message.createdAt,
|
||||||
)}`;
|
)}`;
|
||||||
|
|
|
@ -81,6 +81,10 @@
|
||||||
|
|
||||||
"c_play_name": "play",
|
"c_play_name": "play",
|
||||||
"c_play_desc": "Plays a song/playlist, no query displays the now playing song",
|
"c_play_desc": "Plays a song/playlist, no query displays the now playing song",
|
||||||
|
"c_play_sub1_name": "add",
|
||||||
|
"c_play_sub1_desc": "Adds song/playlist to the queue",
|
||||||
|
"c_play_sub2_name": "now",
|
||||||
|
"c_play_sub2_desc": "Adds the song/playlist to the beginning of the queue",
|
||||||
"c_play_opt1_name": "query",
|
"c_play_opt1_name": "query",
|
||||||
"c_play_opt1_desc": "What you want to listen to",
|
"c_play_opt1_desc": "What you want to listen to",
|
||||||
"c_play1": "You're not on any vocal channels.",
|
"c_play1": "You're not on any vocal channels.",
|
||||||
|
|
|
@ -81,6 +81,10 @@
|
||||||
|
|
||||||
"c_play_name": "play",
|
"c_play_name": "play",
|
||||||
"c_play_desc": "Joue une chanson/playlist, pas de requête affiche la chanson en cours actuellement",
|
"c_play_desc": "Joue une chanson/playlist, pas de requête affiche la chanson en cours actuellement",
|
||||||
|
"c_play_sub1_name": "ajouter",
|
||||||
|
"c_play_sub1_desc": "Ajoute la chanson/playlist à la file d'attente",
|
||||||
|
"c_play_sub2_name": "maintenant",
|
||||||
|
"c_play_sub2_desc": "Ajoute la chanson/playlist au début de la file",
|
||||||
"c_play_opt1_name": "requête",
|
"c_play_opt1_name": "requête",
|
||||||
"c_play_opt1_desc": "Ce que vous voulez écouter",
|
"c_play_opt1_desc": "Ce que vous voulez écouter",
|
||||||
"c_play1": "Tu n'es dans aucun salon vocal.",
|
"c_play1": "Tu n'es dans aucun salon vocal.",
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default {
|
||||||
name: getFilename(__filename),
|
name: getFilename(__filename),
|
||||||
},
|
},
|
||||||
interaction: async (interaction: ModalSubmitInteraction, client: Client) =>
|
interaction: async (interaction: ModalSubmitInteraction, client: Client) =>
|
||||||
newReminder(client, interaction.fields.fields.get("reminderGUI-time")?.value as string, {
|
newReminder(client, interaction.fields.fields.get("reminderGUI-time")!.value, {
|
||||||
locale: interaction.locale,
|
locale: interaction.locale,
|
||||||
message: interaction.fields.fields.get("reminderGUI-message")?.value ?? null,
|
message: interaction.fields.fields.get("reminderGUI-message")?.value ?? null,
|
||||||
createdAt: interaction.createdAt.getTime(),
|
createdAt: interaction.createdAt.getTime(),
|
||||||
|
|
|
@ -108,8 +108,9 @@ export const cleanCodeBlock = (text: string) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Keep links
|
// Keep links
|
||||||
|
// Reference: https://stackoverflow.com/a/3809435/15436737
|
||||||
text = text.replace(
|
text = text.replace(
|
||||||
/(http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)/g,
|
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&//=]*/g,
|
||||||
function (url: string) {
|
function (url: string) {
|
||||||
return `\`${url}\``;
|
return `\`${url}\``;
|
||||||
},
|
},
|
||||||
|
|
|
@ -414,7 +414,6 @@ export const embedListReminders = async (
|
||||||
const expiration = `${loc.get("c_reminder8")} ${timeDeltaToString(remind.expiration_date)}`;
|
const expiration = `${loc.get("c_reminder8")} ${timeDeltaToString(remind.expiration_date)}`;
|
||||||
embed.addFields({
|
embed.addFields({
|
||||||
name: `#${remind.id} • ${loc.get("c_reminder9")} ${showDate(
|
name: `#${remind.id} • ${loc.get("c_reminder9")} ${showDate(
|
||||||
local,
|
|
||||||
loc,
|
loc,
|
||||||
new Date(Number(remind.creation_date)),
|
new Date(Number(remind.creation_date)),
|
||||||
)}\n${expiration}`,
|
)}\n${expiration}`,
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
* @param date Date
|
* @param date Date
|
||||||
* @returns String
|
* @returns String
|
||||||
*/
|
*/
|
||||||
export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) => {
|
export const showDate = (locale: Map<string, unknown>, date: Date) =>
|
||||||
return date.toLocaleString(tz).replace(" ", ` ${locale.get("u_time_at")} `);
|
`${date.toDateString()} ${locale.get("u_time_at")} ${date.toTimeString().split(" ")[0]}`;
|
||||||
};
|
|
||||||
|
|
||||||
enum TimeSecond {
|
enum TimeSecond {
|
||||||
Year = 31536000,
|
Year = 31536000,
|
||||||
|
|
Loading…
Reference in a new issue