chore: merge branch dev to main #195

Merged
Anri merged 18 commits from dev into main 2024-10-14 23:41:43 +02:00
2 changed files with 22 additions and 10 deletions
Showing only changes of commit 5aa3991633 - Show all commits

View file

@ -41,14 +41,18 @@ export default async (client: Client) => {
} as infoReminder;
if (element.expiration_date <= now) {
// Reminder expired
deleteReminder(client, element.creation_date, `${element.user_id}`).then((res) => {
if (res != true) {
throw res;
}
});
sendReminder(client, info, element.option_id as OptionReminder);
sendReminder(client, info, element.option_id as OptionReminder)
.then(() =>
// Reminder expired
deleteReminder(client, element.creation_date, `${element.user_id}`).then((res) => {
if (res != true) {
throw res;
}
}),
)
.catch((err) => {
throw err;
});
} else {
// Restart timeout
const timeoutId = setTimeoutReminder(

View file

@ -143,10 +143,18 @@ export const deleteReminder = (client: Client, createdAt: string, userId: string
});
};
export const sendReminder = (client: Client, info: infoReminder, option: OptionReminder) => {
export const sendReminder = (client: Client, info: infoReminder, option: OptionReminder) =>
new Promise((resolve, reject) => {
try {
resolve(sendReminderAux(client, info, option));
} catch (error) {
reject(error);
}
});
const sendReminderAux = (client: Client, info: infoReminder, option: OptionReminder) => {
const loc = getLocale(client, info.locale);
// Send the message in the appropriate channel
// TODO: Embed
let message: string;
if (info.message === null || info.message.length === 0) {
message = loc.get("c_reminder7");