chore: merge dev to main #177

Merged
Anri merged 6 commits from dev into main 2024-09-23 17:51:22 +02:00
8 changed files with 23 additions and 42 deletions
Showing only changes of commit 377ee13a13 - Show all commits

View file

@ -19,7 +19,7 @@ export default {
},
interaction: async (interaction: MessageComponentInteraction, client: Client) => {
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
const pageMax = Number(/(\d+)(?!.*\d)/gm.exec(embed_desc)?.[0]);

View file

@ -64,14 +64,14 @@ export default async (client: Client) => {
scopedCommands.forEach(
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,
}),
);
// Send global commands to Discord
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()),
});
};

View file

@ -145,14 +145,14 @@ export default {
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): {
// If time is already renseigned
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) {
// Use the cli because we already have enough data
return newReminder(client, time, {
locale: interaction.locale,
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(),
channelId: interaction.channelId,
@ -202,17 +202,13 @@ export default {
// List reminders
case loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase(): {
// Which user to show
let user = interaction.options.getUser(
loc_default?.get(`c_${filename}_sub2_opt1_name`) as string,
);
let user = interaction.options.getUser(loc_default!.get(`c_${filename}_sub2_opt1_name`)!);
if (user === null) {
user = interaction.user;
}
const page =
interaction.options.getInteger(
loc_default?.get(`c_${filename}_sub2_opt2_name`) as string,
) ?? 1;
interaction.options.getInteger(loc_default!.get(`c_${filename}_sub2_opt2_name`)!) ?? 1;
const list = await embedListReminders(
client,
user,
@ -253,7 +249,7 @@ export default {
// Delete a reminder
case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): {
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) {
return interaction.reply({

View file

@ -74,9 +74,7 @@ export default {
const loc = getLocale(client, interaction.locale);
let request = interaction.options.getString(
loc_default?.get(`c_${filename}_opt1_name`) as string,
);
let request = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!);
let data = null;
await interaction.deferReply();

View file

@ -93,9 +93,7 @@ export default {
});
}
const query = interaction.options.getString(
loc_default?.get(`c_${filename}_opt1_name`) as string,
);
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!);
const player = useMainPlayer();
if (!query) {
@ -191,10 +189,7 @@ export default {
const filename = getFilename(__filename);
const player = useMainPlayer();
const query = interaction.options.getString(
loc_default?.get(`c_${filename}_opt1_name`) as string,
true,
);
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!, true);
const limit_value_discord = 100;

View file

@ -103,9 +103,7 @@ export default {
// Show the queue
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase(): {
const page =
interaction.options.getNumber(
loc_default?.get(`c_${filename}_sub1_opt1_name`) as string,
) ?? 1;
interaction.options.getNumber(loc_default!.get(`c_${filename}_sub1_opt1_name`)!) ?? 1;
embedListQueue(client, embed, queue, page, interaction.locale);
@ -152,7 +150,7 @@ export default {
// Remove <ID>
case loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase(): {
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);

View file

@ -51,10 +51,10 @@ export default async (message: Message, client: Client) => {
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) {
if (!channel || !channel.isTextBased()) {
return data;
}
@ -70,9 +70,10 @@ export default async (message: Message, client: Client) => {
// If it's a reference, we only check for reference once
const message_reference = quoted_message?.reference;
if (message_reference && message_reference.messageId) {
const channel_reference = client.channels.cache.get(
message_reference.channelId,
) as TextBasedChannel;
const channel_reference = client.channels.cache.get(message_reference.channelId);
if (!channel_reference?.isTextBased()) {
return;
}
quoted_message = await channel_reference.messages
.fetch(message_reference.messageId)
@ -105,12 +106,9 @@ export default async (message: Message, client: Client) => {
// Handle attachments
if (quoted_post?.attachments.size !== 0) {
if (
quoted_post?.attachments.size === 1 &&
isImage(quoted_post.attachments.first()?.name as string)
) {
if (quoted_post?.attachments.size === 1 && isImage(quoted_post.attachments.first()!.name)) {
// Only contains one image
embed.setImage(quoted_post.attachments.first()?.url as string);
embed.setImage(quoted_post.attachments.first()!.url);
} else {
// Contains more than one image and/or other files
let files = "";
@ -133,11 +131,7 @@ export default async (message: Message, client: Client) => {
}
// Footer
let footer = `Posté le ${showDate(
client.config.default_lang,
loc,
quoted_post?.createdAt as Date,
)}`;
let footer = `Posté le ${showDate(client.config.default_lang, loc, quoted_post!.createdAt)}`;
if (quoted_post?.editedAt) {
footer += ` et modifié le ${showDate(client.config.default_lang, loc, quoted_post.editedAt)}`;
}

View file

@ -7,7 +7,7 @@ export default {
name: getFilename(__filename),
},
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,
message: interaction.fields.fields.get("reminderGUI-message")?.value ?? null,
createdAt: interaction.createdAt.getTime(),