increase lines char limit
This commit is contained in:
parent
983333238f
commit
b2325410f4
22 changed files with 124 additions and 389 deletions
|
@ -1,9 +1,5 @@
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"prettier"
|
|
||||||
],
|
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"project": ["./tsconfig.json"]
|
"project": ["./tsconfig.json"]
|
||||||
|
@ -23,15 +19,9 @@
|
||||||
"no-inline-comments": "error",
|
"no-inline-comments": "error",
|
||||||
"no-lonely-if": "error",
|
"no-lonely-if": "error",
|
||||||
"no-multi-spaces": "error",
|
"no-multi-spaces": "error",
|
||||||
"no-multiple-empty-lines": [
|
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
||||||
"error",
|
|
||||||
{ "max": 2, "maxEOF": 1, "maxBOF": 0 }
|
|
||||||
],
|
|
||||||
"no-shadow": "off",
|
"no-shadow": "off",
|
||||||
"@typescript-eslint/no-shadow": [
|
"@typescript-eslint/no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
|
||||||
"error",
|
|
||||||
{ "allow": ["err", "resolve", "reject"] }
|
|
||||||
],
|
|
||||||
"no-trailing-spaces": ["error"],
|
"no-trailing-spaces": ["error"],
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
"prefer-const": "error",
|
"prefer-const": "error",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{}
|
{ "printWidth": 100 }
|
||||||
|
|
|
@ -123,22 +123,13 @@ export default {
|
||||||
return new SlashCommandBuilder()
|
return new SlashCommandBuilder()
|
||||||
.setName(filename.toLowerCase())
|
.setName(filename.toLowerCase())
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_desc`) ?? ""
|
|
||||||
)
|
)
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
getLocalizations(client, `c_${filename}_name`, true)
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`));
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_desc`)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
interaction: async (
|
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||||
interaction: ChatInputCommandInteraction,
|
|
||||||
client: Client
|
|
||||||
) => {
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
|
|
||||||
/* Votre code ici */
|
/* Votre code ici */
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import { readdir } from "fs/promises";
|
import { readdir } from "fs/promises";
|
||||||
import { removeExtension } from "../utils/misc";
|
import { removeExtension } from "../utils/misc";
|
||||||
import {
|
import { ChatInputCommandInteraction, Client, MessageComponentInteraction } from "discord.js";
|
||||||
ChatInputCommandInteraction,
|
|
||||||
Client,
|
|
||||||
MessageComponentInteraction,
|
|
||||||
} from "discord.js";
|
|
||||||
import { getLocale } from "../utils/locales";
|
import { getLocale } from "../utils/locales";
|
||||||
|
|
||||||
export default async (client: Client) => {
|
export default async (client: Client) => {
|
||||||
|
@ -20,17 +16,12 @@ export default async (client: Client) => {
|
||||||
const button_files = await readdir(`${__dirname}/${buttons_category}`);
|
const button_files = await readdir(`${__dirname}/${buttons_category}`);
|
||||||
|
|
||||||
// Add the category to the collection for the help command
|
// Add the category to the collection for the help command
|
||||||
client.buttons.categories.set(
|
client.buttons.categories.set(buttons_category, button_files.map(removeExtension));
|
||||||
buttons_category,
|
|
||||||
button_files.map(removeExtension)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add the button
|
// Add the button
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
button_files.map(async (button_file) => {
|
button_files.map(async (button_file) => {
|
||||||
const button = (
|
const button = (await import(`../buttons/${buttons_category}/${button_file}`)).default;
|
||||||
await import(`../buttons/${buttons_category}/${button_file}`)
|
|
||||||
).default;
|
|
||||||
|
|
||||||
// Add it to the collection so the interaction will work
|
// Add it to the collection so the interaction will work
|
||||||
client.buttons.list.set(button.data.name, button);
|
client.buttons.list.set(button.data.name, button);
|
||||||
|
|
|
@ -16,10 +16,7 @@ export default {
|
||||||
data: {
|
data: {
|
||||||
name: getFilename(__filename),
|
name: getFilename(__filename),
|
||||||
},
|
},
|
||||||
interaction: async (
|
interaction: async (interaction: MessageComponentInteraction, client: Client) => {
|
||||||
interaction: MessageComponentInteraction,
|
|
||||||
client: Client
|
|
||||||
) => {
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const embed_desc = interaction.message.embeds.at(0)?.description as string;
|
const embed_desc = interaction.message.embeds.at(0)?.description as string;
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,7 @@ export default {
|
||||||
data: {
|
data: {
|
||||||
name: getFilename(__filename),
|
name: getFilename(__filename),
|
||||||
},
|
},
|
||||||
interaction: async (
|
interaction: async (interaction: MessageComponentInteraction, client: Client) => {
|
||||||
interaction: MessageComponentInteraction,
|
|
||||||
client: Client
|
|
||||||
) => {
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const embed_desc = interaction.message.embeds.at(0)?.description as string;
|
const embed_desc = interaction.message.embeds.at(0)?.description as string;
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,13 @@ export default async (client: Client) => {
|
||||||
const command_files = await readdir(`${__dirname}/${command_category}`);
|
const command_files = await readdir(`${__dirname}/${command_category}`);
|
||||||
|
|
||||||
// Add the category to the collection for the help command
|
// Add the category to the collection for the help command
|
||||||
client.commands.categories.set(
|
client.commands.categories.set(command_category, command_files.map(removeExtension));
|
||||||
command_category,
|
|
||||||
command_files.map(removeExtension)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add the command
|
// Add the command
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
command_files.map(async (command_file) => {
|
command_files.map(async (command_file) => {
|
||||||
const command = (
|
const command = (await import(`../commands/${command_category}/${command_file}`))
|
||||||
await import(`../commands/${command_category}/${command_file}`)
|
.default;
|
||||||
).default;
|
|
||||||
|
|
||||||
// Add it to the collection so the interaction will work
|
// Add it to the collection so the interaction will work
|
||||||
command.data = command.data(client);
|
command.data = command.data(client);
|
||||||
|
@ -68,12 +64,9 @@ export default async (client: Client) => {
|
||||||
|
|
||||||
scopedCommands.forEach(
|
scopedCommands.forEach(
|
||||||
async (command, guild) =>
|
async (command, guild) =>
|
||||||
await rest.put(
|
await rest.put(Routes.applicationGuildCommands(client.user?.id as string, guild), {
|
||||||
Routes.applicationGuildCommands(client.user?.id as string, guild),
|
body: command,
|
||||||
{
|
})
|
||||||
body: command,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send global commands to Discord
|
// Send global commands to Discord
|
||||||
|
|
|
@ -20,36 +20,22 @@ export default {
|
||||||
new SlashCommandBuilder()
|
new SlashCommandBuilder()
|
||||||
.setName(filename.toLowerCase())
|
.setName(filename.toLowerCase())
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_name`, true)
|
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_desc`)
|
|
||||||
)
|
)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
|
||||||
|
|
||||||
// Command option
|
// Command option
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_name`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_opt1_name`) ?? ""
|
|
||||||
)
|
)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_opt1_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_name`, true)
|
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_desc`)
|
|
||||||
)
|
)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -111,9 +97,7 @@ export default {
|
||||||
|
|
||||||
const allChannelDesired = channelGuild
|
const allChannelDesired = channelGuild
|
||||||
.filter((chan) => chan?.type == 0)
|
.filter((chan) => chan?.type == 0)
|
||||||
.filter(
|
.filter((chan) => chan?.parentId == catToArchive.map((cat) => cat?.id)[0]);
|
||||||
(chan) => chan?.parentId == catToArchive.map((cat) => cat?.id)[0]
|
|
||||||
);
|
|
||||||
|
|
||||||
// If no channels in the source category
|
// If no channels in the source category
|
||||||
if (allChannelDesired.size == 0) {
|
if (allChannelDesired.size == 0) {
|
||||||
|
@ -128,9 +112,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move channels to the archived categoryx
|
// Move channels to the archived categoryx
|
||||||
allChannelDesired.forEach((elem) =>
|
allChannelDesired.forEach((elem) => elem?.setParent(catArchived?.id as string));
|
||||||
elem?.setParent(catArchived?.id as string)
|
|
||||||
);
|
|
||||||
|
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { Locale } from "discord-api-types/v9";
|
import { Locale } from "discord-api-types/v9";
|
||||||
import {
|
import { Client, ChatInputCommandInteraction, EmbedBuilder, Colors } from "discord.js";
|
||||||
Client,
|
|
||||||
ChatInputCommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
Colors,
|
|
||||||
} from "discord.js";
|
|
||||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||||
import { getFilename } from "../../utils/misc";
|
import { getFilename } from "../../utils/misc";
|
||||||
import "../../modules/string";
|
import "../../modules/string";
|
||||||
|
@ -19,44 +14,27 @@ export default {
|
||||||
new SlashCommandBuilder()
|
new SlashCommandBuilder()
|
||||||
.setName(filename.toLowerCase())
|
.setName(filename.toLowerCase())
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_name`, true)
|
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_desc`)
|
|
||||||
)
|
)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
|
||||||
|
|
||||||
// Command option
|
// Command option
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_name`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_opt1_name`) ?? ""
|
|
||||||
)
|
)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_opt1_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_name`, true)
|
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_desc`)
|
|
||||||
)
|
)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
interaction: async (
|
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||||
interaction: ChatInputCommandInteraction,
|
|
||||||
client: Client
|
|
||||||
) => {
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
const desired_command = interaction.options.getString(
|
const desired_command = interaction.options.getString(
|
||||||
client.locales
|
client.locales
|
||||||
|
@ -116,9 +94,8 @@ export default {
|
||||||
.setDescription(
|
.setDescription(
|
||||||
// Loads the description
|
// Loads the description
|
||||||
// according to the user's locals
|
// according to the user's locals
|
||||||
command.data.description_localizations?.[
|
command.data.description_localizations?.[interaction.locale as Locale] ??
|
||||||
interaction.locale as Locale
|
command.data.description
|
||||||
] ?? command.data.description
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,22 +11,13 @@ export default {
|
||||||
return new SlashCommandBuilder()
|
return new SlashCommandBuilder()
|
||||||
.setName(filename.toLowerCase())
|
.setName(filename.toLowerCase())
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_desc`) ?? ""
|
|
||||||
)
|
)
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
getLocalizations(client, `c_${filename}_name`, true)
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`));
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_desc`)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
interaction: async (
|
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||||
interaction: ChatInputCommandInteraction,
|
|
||||||
client: Client
|
|
||||||
) => {
|
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
|
|
||||||
const sent = (await interaction.reply({
|
const sent = (await interaction.reply({
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import {
|
import { ChannelType, Client, Colors, CommandInteraction, EmbedBuilder } from "discord.js";
|
||||||
ChannelType,
|
|
||||||
Client,
|
|
||||||
Colors,
|
|
||||||
CommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
} from "discord.js";
|
|
||||||
import "../../modules/string";
|
import "../../modules/string";
|
||||||
import { getLocale, getLocalizations } from "../../utils/locales";
|
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||||
import { getFilename } from "../../utils/misc";
|
import { getFilename } from "../../utils/misc";
|
||||||
|
@ -19,36 +13,22 @@ export default {
|
||||||
new SlashCommandBuilder()
|
new SlashCommandBuilder()
|
||||||
.setName(filename.toLowerCase())
|
.setName(filename.toLowerCase())
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_name`, true)
|
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_desc`)
|
|
||||||
)
|
)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
|
||||||
|
|
||||||
// Command option
|
// Command option
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_name`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_opt1_name`) ?? ""
|
|
||||||
)
|
)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
client.locales
|
client.locales.get(client.config.default_lang)?.get(`c_${filename}_opt1_desc`) ?? ""
|
||||||
.get(client.config.default_lang)
|
|
||||||
?.get(`c_${filename}_opt1_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_name`, true)
|
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_opt1_desc`)
|
|
||||||
)
|
)
|
||||||
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
||||||
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -98,16 +78,12 @@ export default {
|
||||||
const all_channel_desired = channel_guild
|
const all_channel_desired = channel_guild
|
||||||
.filter((chan) => chan?.type == 0)
|
.filter((chan) => chan?.type == 0)
|
||||||
.filter((chan) => chan?.parentId == cat_to_prep_id[0]);
|
.filter((chan) => chan?.parentId == cat_to_prep_id[0]);
|
||||||
const all_channel_desired_name = all_channel_desired.map(
|
const all_channel_desired_name = all_channel_desired.map((c_d) => c_d?.name);
|
||||||
(c_d) => c_d?.name
|
|
||||||
);
|
|
||||||
|
|
||||||
let desc = "";
|
let desc = "";
|
||||||
|
|
||||||
const general = "général";
|
const general = "général";
|
||||||
if (
|
if (all_channel_desired_name.filter((cdn) => cdn == general).length == 0) {
|
||||||
all_channel_desired_name.filter((cdn) => cdn == general).length == 0
|
|
||||||
) {
|
|
||||||
interaction.guild?.channels.create({
|
interaction.guild?.channels.create({
|
||||||
name: general,
|
name: general,
|
||||||
type: 0,
|
type: 0,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { ModalActionRowComponentBuilder, SlashCommandBuilder } from "@discordjs/builders";
|
||||||
ModalActionRowComponentBuilder,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from "@discordjs/builders";
|
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
|
@ -39,38 +36,22 @@ export default {
|
||||||
// Command
|
// Command
|
||||||
.setName(filename.toLowerCase())
|
.setName(filename.toLowerCase())
|
||||||
.setDescription(loc_default.get(`c_${filename}_desc`) ?? "")
|
.setDescription(loc_default.get(`c_${filename}_desc`) ?? "")
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
getLocalizations(client, `c_${filename}_name`, true)
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_desc`)
|
|
||||||
)
|
|
||||||
|
|
||||||
// New reminder
|
// New reminder
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand((subcommand) =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "")
|
||||||
loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "")
|
.setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "")
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true))
|
||||||
getLocalizations(client, `c_${filename}_sub1_name`, true)
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`))
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_sub1_desc`)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Specified Time
|
// Specified Time
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub1_opt1_name`)?.toLowerCase() ?? "")
|
||||||
loc_default
|
.setDescription(loc_default.get(`c_${filename}_sub1_opt1_desc`) ?? "")
|
||||||
.get(`c_${filename}_sub1_opt1_name`)
|
|
||||||
?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(
|
|
||||||
loc_default.get(`c_${filename}_sub1_opt1_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(
|
||||||
getLocalizations(client, `c_${filename}_sub1_opt1_name`, true)
|
getLocalizations(client, `c_${filename}_sub1_opt1_name`, true)
|
||||||
)
|
)
|
||||||
|
@ -82,14 +63,8 @@ export default {
|
||||||
// Specified message (not required)
|
// Specified message (not required)
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub1_opt2_name`)?.toLowerCase() ?? "")
|
||||||
loc_default
|
.setDescription(loc_default.get(`c_${filename}_sub1_opt2_desc`) ?? "")
|
||||||
.get(`c_${filename}_sub1_opt2_name`)
|
|
||||||
?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(
|
|
||||||
loc_default.get(`c_${filename}_sub1_opt2_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(
|
||||||
getLocalizations(client, `c_${filename}_sub1_opt2_name`, true)
|
getLocalizations(client, `c_${filename}_sub1_opt2_name`, true)
|
||||||
)
|
)
|
||||||
|
@ -102,28 +77,16 @@ export default {
|
||||||
// List reminders
|
// List reminders
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand((subcommand) =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "")
|
||||||
loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "")
|
.setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "")
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true))
|
||||||
getLocalizations(client, `c_${filename}_sub2_name`, true)
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`))
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_sub2_desc`)
|
|
||||||
)
|
|
||||||
|
|
||||||
// User
|
// User
|
||||||
.addUserOption((option) =>
|
.addUserOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub2_opt1_name`)?.toLowerCase() ?? "")
|
||||||
loc_default
|
.setDescription(loc_default.get(`c_${filename}_sub2_opt1_desc`) ?? "")
|
||||||
.get(`c_${filename}_sub2_opt1_name`)
|
|
||||||
?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(
|
|
||||||
loc_default.get(`c_${filename}_sub2_opt1_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(
|
||||||
getLocalizations(client, `c_${filename}_sub2_opt1_name`, true)
|
getLocalizations(client, `c_${filename}_sub2_opt1_name`, true)
|
||||||
)
|
)
|
||||||
|
@ -135,14 +98,8 @@ export default {
|
||||||
// Page
|
// Page
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub2_opt2_name`)?.toLowerCase() ?? "")
|
||||||
loc_default
|
.setDescription(loc_default.get(`c_${filename}_sub2_opt2_desc`) ?? "")
|
||||||
.get(`c_${filename}_sub2_opt2_name`)
|
|
||||||
?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(
|
|
||||||
loc_default.get(`c_${filename}_sub2_opt2_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(
|
||||||
getLocalizations(client, `c_${filename}_sub2_opt2_name`, true)
|
getLocalizations(client, `c_${filename}_sub2_opt2_name`, true)
|
||||||
)
|
)
|
||||||
|
@ -155,28 +112,16 @@ export default {
|
||||||
// Delete a reminder
|
// Delete a reminder
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand((subcommand) =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "")
|
||||||
loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "")
|
.setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "")
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true))
|
||||||
getLocalizations(client, `c_${filename}_sub3_name`, true)
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`))
|
||||||
)
|
|
||||||
.setDescriptionLocalizations(
|
|
||||||
getLocalizations(client, `c_${filename}_sub3_desc`)
|
|
||||||
)
|
|
||||||
|
|
||||||
// ID
|
// ID
|
||||||
.addIntegerOption((option) =>
|
.addIntegerOption((option) =>
|
||||||
option
|
option
|
||||||
.setName(
|
.setName(loc_default.get(`c_${filename}_sub3_opt1_name`)?.toLowerCase() ?? "")
|
||||||
loc_default
|
.setDescription(loc_default.get(`c_${filename}_sub3_opt1_desc`) ?? "")
|
||||||
.get(`c_${filename}_sub3_opt1_name`)
|
|
||||||
?.toLowerCase() ?? ""
|
|
||||||
)
|
|
||||||
.setDescription(
|
|
||||||
loc_default.get(`c_${filename}_sub3_opt1_desc`) ?? ""
|
|
||||||
)
|
|
||||||
.setNameLocalizations(
|
.setNameLocalizations(
|
||||||
getLocalizations(client, `c_${filename}_sub3_opt1_name`, true)
|
getLocalizations(client, `c_${filename}_sub3_opt1_name`, true)
|
||||||
)
|
)
|
||||||
|
@ -189,10 +134,7 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
interaction: async (
|
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||||
interaction: ChatInputCommandInteraction,
|
|
||||||
client: Client
|
|
||||||
) => {
|
|
||||||
const loc_default = client.locales.get(client.config.default_lang);
|
const loc_default = client.locales.get(client.config.default_lang);
|
||||||
const filename = getFilename(__filename);
|
const filename = getFilename(__filename);
|
||||||
const loc = getLocale(client, interaction.locale);
|
const loc = getLocale(client, interaction.locale);
|
||||||
|
@ -243,12 +185,8 @@ export default {
|
||||||
.setRequired(false);
|
.setRequired(false);
|
||||||
|
|
||||||
modal.addComponents(
|
modal.addComponents(
|
||||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(timeGUI),
|
||||||
timeGUI
|
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(messageGUI)
|
||||||
),
|
|
||||||
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(
|
|
||||||
messageGUI
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return interaction.showModal(modal);
|
return interaction.showModal(modal);
|
||||||
|
@ -316,12 +254,7 @@ export default {
|
||||||
|
|
||||||
// Check if the ID exists and belongs to the user
|
// Check if the ID exists and belongs to the user
|
||||||
if (
|
if (
|
||||||
await checkOwnershipReminder(
|
await checkOwnershipReminder(client, id, interaction.user.id, interaction.guildId ?? "0")
|
||||||
client,
|
|
||||||
id,
|
|
||||||
interaction.user.id,
|
|
||||||
interaction.guildId ?? "0"
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: loc.get(`c_${filename}3`),
|
content: loc.get(`c_${filename}3`),
|
||||||
|
@ -334,11 +267,7 @@ export default {
|
||||||
clearTimeout(reminderInfo.timeout_id);
|
clearTimeout(reminderInfo.timeout_id);
|
||||||
|
|
||||||
// Delete from database
|
// Delete from database
|
||||||
return deleteReminder(
|
return deleteReminder(client, reminderInfo.creation_date, reminderInfo.user_id).then(() =>
|
||||||
client,
|
|
||||||
reminderInfo.creation_date,
|
|
||||||
reminderInfo.user_id
|
|
||||||
).then(() =>
|
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
content: `Reminder **#${id}** supprimé !`,
|
content: `Reminder **#${id}** supprimé !`,
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
|
|
|
@ -42,11 +42,7 @@ export default async (client: Client) => {
|
||||||
|
|
||||||
if (element.expiration_date <= now) {
|
if (element.expiration_date <= now) {
|
||||||
// Reminder expired
|
// Reminder expired
|
||||||
deleteReminder(
|
deleteReminder(client, element.creation_date, `${element.user_id}`).then((res) => {
|
||||||
client,
|
|
||||||
element.creation_date,
|
|
||||||
`${element.user_id}`
|
|
||||||
).then((res) => {
|
|
||||||
if (res != true) {
|
if (res != true) {
|
||||||
throw res;
|
throw res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { Client, GuildMember, Message, TextBasedChannel, EmbedBuilder } from "discord.js";
|
||||||
Client,
|
|
||||||
GuildMember,
|
|
||||||
Message,
|
|
||||||
TextBasedChannel,
|
|
||||||
EmbedBuilder,
|
|
||||||
} from "discord.js";
|
|
||||||
import { getLocale } from "../../utils/locales";
|
import { getLocale } from "../../utils/locales";
|
||||||
import { isImage, userWithNickname } from "../../utils/misc";
|
import { isImage, userWithNickname } from "../../utils/misc";
|
||||||
import { showDate } from "../../utils/time";
|
import { showDate } from "../../utils/time";
|
||||||
|
@ -57,9 +51,7 @@ export default async (message: Message, client: Client) => {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = message.guild.channels.cache.get(
|
const channel = message.guild.channels.cache.get(channel_id) as TextBasedChannel;
|
||||||
channel_id
|
|
||||||
) as TextBasedChannel;
|
|
||||||
|
|
||||||
// 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) {
|
||||||
|
@ -73,9 +65,7 @@ export default async (message: Message, client: Client) => {
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
.map(async ({ message_id, channel }) => {
|
.map(async ({ message_id, channel }) => {
|
||||||
const quoted_message = await channel.messages
|
const quoted_message = await channel.messages.fetch(message_id).catch(() => undefined);
|
||||||
.fetch(message_id)
|
|
||||||
.catch(() => undefined);
|
|
||||||
|
|
||||||
// If message doesn't exist or empty
|
// If message doesn't exist or empty
|
||||||
if (
|
if (
|
||||||
|
@ -112,9 +102,7 @@ export default async (message: Message, client: Client) => {
|
||||||
} else {
|
} else {
|
||||||
// Contains more than one image and/or other files
|
// Contains more than one image and/or other files
|
||||||
let files = "";
|
let files = "";
|
||||||
quoted_post?.attachments.forEach(
|
quoted_post?.attachments.forEach((file) => (files += `[${file.name}](${file.url}), `));
|
||||||
(file) => (files += `[${file.name}](${file.url}), `)
|
|
||||||
);
|
|
||||||
embed.addFields({
|
embed.addFields({
|
||||||
// TODO: Don't pluralize when there is only one file.
|
// TODO: Don't pluralize when there is only one file.
|
||||||
// TODO: Locales
|
// TODO: Locales
|
||||||
|
@ -136,20 +124,18 @@ export default async (message: Message, client: Client) => {
|
||||||
quoted_post?.createdAt as Date
|
quoted_post?.createdAt as Date
|
||||||
)}`;
|
)}`;
|
||||||
if (quoted_post?.editedAt) {
|
if (quoted_post?.editedAt) {
|
||||||
footer += ` et modifié le ${showDate(
|
footer += ` et modifié le ${showDate(client.config.default_lang, loc, quoted_post.editedAt)}`;
|
||||||
client.config.default_lang,
|
|
||||||
loc,
|
|
||||||
quoted_post.editedAt
|
|
||||||
)}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let author = "Auteur";
|
let author = "Auteur";
|
||||||
if (message.author == quoted_post?.author) {
|
if (message.author == quoted_post?.author) {
|
||||||
author += " & Citateur";
|
author += " & Citateur";
|
||||||
} else {
|
} else {
|
||||||
footer += `\nCité par ${
|
footer += `\nCité par ${userWithNickname(message.member as GuildMember) ?? "?"} le ${showDate(
|
||||||
userWithNickname(message.member as GuildMember) ?? "?"
|
client.config.default_lang,
|
||||||
} le ${showDate(client.config.default_lang, loc, message.createdAt)}`;
|
loc,
|
||||||
|
message.createdAt
|
||||||
|
)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.setFooter({
|
embed.setFooter({
|
||||||
|
|
|
@ -61,9 +61,7 @@ const run = async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(logStart(client_name, true));
|
console.log(logStart(client_name, true));
|
||||||
console.log(
|
console.log(`Botanique "${client.user?.username}" v${client.config.version} started!`);
|
||||||
`Botanique "${client.user?.username}" v${client.config.version} started!`
|
|
||||||
);
|
|
||||||
|
|
||||||
// ^C
|
// ^C
|
||||||
process.on("SIGINT", () => quit(client));
|
process.on("SIGINT", () => quit(client));
|
||||||
|
|
|
@ -15,17 +15,12 @@ export default async (client: Client) => {
|
||||||
const modal_files = await readdir(`${__dirname}/${modals_category}`);
|
const modal_files = await readdir(`${__dirname}/${modals_category}`);
|
||||||
|
|
||||||
// Add the category to the collection for the help command
|
// Add the category to the collection for the help command
|
||||||
client.modals.categories.set(
|
client.modals.categories.set(modals_category, modal_files.map(removeExtension));
|
||||||
modals_category,
|
|
||||||
modal_files.map(removeExtension)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add the modal
|
// Add the modal
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
modal_files.map(async (modal_file) => {
|
modal_files.map(async (modal_file) => {
|
||||||
const modal = (
|
const modal = (await import(`../modals/${modals_category}/${modal_file}`)).default;
|
||||||
await import(`../modals/${modals_category}/${modal_file}`)
|
|
||||||
).default;
|
|
||||||
|
|
||||||
// Add it to the collection so the interaction will work
|
// Add it to the collection so the interaction will work
|
||||||
client.modals.list.set(modal.data.name, modal);
|
client.modals.list.set(modal.data.name, modal);
|
||||||
|
|
|
@ -7,19 +7,14 @@ export default {
|
||||||
name: getFilename(__filename),
|
name: getFilename(__filename),
|
||||||
},
|
},
|
||||||
interaction: async (interaction: ModalSubmitInteraction, client: Client) =>
|
interaction: async (interaction: ModalSubmitInteraction, client: Client) =>
|
||||||
newReminder(
|
newReminder(client, interaction.fields.fields.get("reminderGUI-time")?.value as string, {
|
||||||
client,
|
locale: interaction.locale,
|
||||||
interaction.fields.fields.get("reminderGUI-time")?.value as string,
|
message: interaction.fields.fields.get("reminderGUI-message")?.value ?? null,
|
||||||
{
|
createdAt: interaction.createdAt.getTime(),
|
||||||
locale: interaction.locale,
|
channelId: interaction.channelId,
|
||||||
message:
|
userId: interaction.user.id,
|
||||||
interaction.fields.fields.get("reminderGUI-message")?.value ?? null,
|
guildId: interaction.guildId,
|
||||||
createdAt: interaction.createdAt.getTime(),
|
}).then((msg) =>
|
||||||
channelId: interaction.channelId,
|
|
||||||
userId: interaction.user.id,
|
|
||||||
guildId: interaction.guildId,
|
|
||||||
}
|
|
||||||
).then((msg) =>
|
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
content: msg as string,
|
content: msg as string,
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
|
|
|
@ -34,10 +34,7 @@ declare module "discord.js" {
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
/** How the modal interact */
|
/** How the modal interact */
|
||||||
interaction: (
|
interaction: (interaction: ModalSubmitInteraction, client: Client) => unknown;
|
||||||
interaction: ModalSubmitInteraction,
|
|
||||||
client: Client
|
|
||||||
) => unknown;
|
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
@ -82,10 +79,7 @@ declare module "discord.js" {
|
||||||
/** Data about the command */
|
/** Data about the command */
|
||||||
data: SlashCommandBuilder;
|
data: SlashCommandBuilder;
|
||||||
/** How the command interact */
|
/** How the command interact */
|
||||||
interaction: (
|
interaction: (interaction: CommandInteraction, client: Client) => unknown;
|
||||||
interaction: CommandInteraction,
|
|
||||||
client: Client
|
|
||||||
) => unknown;
|
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,9 +34,7 @@ export default async () => {
|
||||||
console.log("Translations progression :");
|
console.log("Translations progression :");
|
||||||
client.locales = await loadLocales(client.config.default_lang);
|
client.locales = await loadLocales(client.config.default_lang);
|
||||||
|
|
||||||
client.db = new Database(
|
client.db = new Database(`${process.env.DOCKERIZED === "1" ? "/config" : "./config"}/db.sqlite3`);
|
||||||
`${process.env.DOCKERIZED === "1" ? "/config" : "./config"}/db.sqlite3`
|
|
||||||
);
|
|
||||||
|
|
||||||
initDatabase(client.db);
|
initDatabase(client.db);
|
||||||
|
|
||||||
|
|
|
@ -52,20 +52,14 @@ export const loadLocales = async (default_lang: string) => {
|
||||||
* @param text Name of string to fetch
|
* @param text Name of string to fetch
|
||||||
* @returns the dictionary
|
* @returns the dictionary
|
||||||
*/
|
*/
|
||||||
export const getLocalizations = (
|
export const getLocalizations = (client: Client, text: string, lowercase = false) => {
|
||||||
client: Client,
|
|
||||||
text: string,
|
|
||||||
lowercase = false
|
|
||||||
) => {
|
|
||||||
const data: Record<string, string> = {};
|
const data: Record<string, string> = {};
|
||||||
|
|
||||||
// Load all the localizations
|
// Load all the localizations
|
||||||
client.locales.forEach((locale, lang) => {
|
client.locales.forEach((locale, lang) => {
|
||||||
// Fetch the text and fallback to default lang if needed
|
// Fetch the text and fallback to default lang if needed
|
||||||
// See getLocale for more info on why we *can* fallback
|
// See getLocale for more info on why we *can* fallback
|
||||||
let str =
|
let str = locale.get(text) ?? client.locales.get(client.config.default_lang)?.get(text);
|
||||||
locale.get(text) ??
|
|
||||||
client.locales.get(client.config.default_lang)?.get(text);
|
|
||||||
|
|
||||||
// Store it if defined
|
// Store it if defined
|
||||||
if (str !== undefined) {
|
if (str !== undefined) {
|
||||||
|
@ -114,10 +108,7 @@ export const getLocale = (client: Client, lang: string) => {
|
||||||
* @param default_lang default lang
|
* @param default_lang default lang
|
||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
const checkLocales = async (
|
const checkLocales = async (locales: Map<string, Map<string, string>>, default_lang: string) => {
|
||||||
locales: Map<string, Map<string, string>>,
|
|
||||||
default_lang: string
|
|
||||||
) => {
|
|
||||||
// Associate each lang with the number of locale it has
|
// Associate each lang with the number of locale it has
|
||||||
let locales_size = new Map<string, number>();
|
let locales_size = new Map<string, number>();
|
||||||
locales.forEach((locales_data, lang) => {
|
locales.forEach((locales_data, lang) => {
|
||||||
|
@ -125,9 +116,7 @@ const checkLocales = async (
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sort the map
|
// Sort the map
|
||||||
locales_size = new Map(
|
locales_size = new Map([...locales_size.entries()].sort((a, b) => b[1] - a[1]));
|
||||||
[...locales_size.entries()].sort((a, b) => b[1] - a[1])
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check if default lang is 100%
|
// Check if default lang is 100%
|
||||||
const [max_size_name] = locales_size.keys();
|
const [max_size_name] = locales_size.keys();
|
||||||
|
@ -177,9 +166,7 @@ const checkLocales = async (
|
||||||
const padding = " ".repeat(lang.length === 5 ? 1 : 4);
|
const padding = " ".repeat(lang.length === 5 ? 1 : 4);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`${padding}${lang} | ${color()}${blocks}\x1b[0m${blank} | ${percentage.toPrecision(
|
`${padding}${lang} | ${color()}${blocks}\x1b[0m${blank} | ${percentage.toPrecision(3)}%`
|
||||||
3
|
|
||||||
)}%`
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,11 +62,7 @@ const splitTime = (time: string) => {
|
||||||
* @param info data about the context of the reminder
|
* @param info data about the context of the reminder
|
||||||
* @returns Promise resolution of the sql request
|
* @returns Promise resolution of the sql request
|
||||||
*/
|
*/
|
||||||
export const newReminder = async (
|
export const newReminder = async (client: Client, time: string, info: infoReminder) =>
|
||||||
client: Client,
|
|
||||||
time: string,
|
|
||||||
info: infoReminder
|
|
||||||
) =>
|
|
||||||
new Promise((ok, ko) => {
|
new Promise((ok, ko) => {
|
||||||
const data = splitTime(time);
|
const data = splitTime(time);
|
||||||
const timeout = strToSeconds(data.time);
|
const timeout = strToSeconds(data.time);
|
||||||
|
@ -107,11 +103,7 @@ export const newReminder = async (
|
||||||
* @param userId User ID who created the reminder
|
* @param userId User ID who created the reminder
|
||||||
* @returns what the SQlite request sended
|
* @returns what the SQlite request sended
|
||||||
*/
|
*/
|
||||||
export const deleteReminder = (
|
export const deleteReminder = (client: Client, createdAt: string, userId: string) => {
|
||||||
client: Client,
|
|
||||||
createdAt: string,
|
|
||||||
userId: string
|
|
||||||
) => {
|
|
||||||
// Delete the reminder for the database
|
// Delete the reminder for the database
|
||||||
return new Promise((ok, ko) => {
|
return new Promise((ok, ko) => {
|
||||||
// Add the remind to the db
|
// Add the remind to the db
|
||||||
|
@ -130,11 +122,7 @@ export const deleteReminder = (
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendReminder = (
|
export const sendReminder = (client: Client, info: infoReminder, option: OptionReminder) => {
|
||||||
client: Client,
|
|
||||||
info: infoReminder,
|
|
||||||
option: OptionReminder
|
|
||||||
) => {
|
|
||||||
const loc = getLocale(client, info.locale);
|
const loc = getLocale(client, info.locale);
|
||||||
// Send the message in the appropriate channel
|
// Send the message in the appropriate channel
|
||||||
// TODO: Embed
|
// TODO: Embed
|
||||||
|
@ -184,9 +172,7 @@ export const sendReminder = (
|
||||||
if (channel?.isTextBased()) {
|
if (channel?.isTextBased()) {
|
||||||
let content = `<@${info.userId}>`;
|
let content = `<@${info.userId}>`;
|
||||||
embed.setFooter({
|
embed.setFooter({
|
||||||
text: `${loc.get("c_reminder17")} ${timeDeltaToString(
|
text: `${loc.get("c_reminder17")} ${timeDeltaToString(info.createdAt)}`,
|
||||||
info.createdAt
|
|
||||||
)}`,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mention everybody if needed
|
// Mention everybody if needed
|
||||||
|
@ -218,15 +204,13 @@ export const setTimeoutReminder = (
|
||||||
) => {
|
) => {
|
||||||
return Number(
|
return Number(
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
deleteReminder(client, String(info.createdAt), info.userId).then(
|
deleteReminder(client, String(info.createdAt), info.userId).then((val) => {
|
||||||
(val) => {
|
if (val != true) {
|
||||||
if (val != true) {
|
throw val;
|
||||||
throw val;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendReminder(client, info, option);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
sendReminder(client, info, option);
|
||||||
|
});
|
||||||
}, timeout * 1000)
|
}, timeout * 1000)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -342,11 +326,7 @@ export const updateReminder = (client: Client, data: dbReminder) => {
|
||||||
* @param guildId guild ID
|
* @param guildId guild ID
|
||||||
* @returns List of reminders of a user in a guild
|
* @returns List of reminders of a user in a guild
|
||||||
*/
|
*/
|
||||||
const listReminders = async (
|
const listReminders = async (client: Client, userId: string, guildId: string | null) => {
|
||||||
client: Client,
|
|
||||||
userId: string,
|
|
||||||
guildId: string | null
|
|
||||||
) => {
|
|
||||||
return (await new Promise((ok, ko) => {
|
return (await new Promise((ok, ko) => {
|
||||||
// Check the ownership
|
// Check the ownership
|
||||||
client.db.all(
|
client.db.all(
|
||||||
|
@ -394,9 +374,7 @@ export const embedListReminders = async (
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(Colors.DarkGrey)
|
.setColor(Colors.DarkGrey)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${loc.get("c_reminder5")} ${user} • ${loc.get(
|
`${loc.get("c_reminder5")} ${user} • ${loc.get("c_reminder6")} ${page}/${pageMax}`
|
||||||
"c_reminder6"
|
|
||||||
)} ${page}/${pageMax}`
|
|
||||||
)
|
)
|
||||||
.setThumbnail(user.displayAvatarURL());
|
.setThumbnail(user.displayAvatarURL());
|
||||||
|
|
||||||
|
@ -411,9 +389,7 @@ export const embedListReminders = async (
|
||||||
if (text.length > 1024) {
|
if (text.length > 1024) {
|
||||||
text = `${text.substring(0, 1021)}...`;
|
text = `${text.substring(0, 1021)}...`;
|
||||||
}
|
}
|
||||||
const expiration = `${loc.get("c_reminder8")} ${timeDeltaToString(
|
const expiration = `${loc.get("c_reminder8")} ${timeDeltaToString(remind.expiration_date)}`;
|
||||||
remind.expiration_date
|
|
||||||
)}`;
|
|
||||||
embed.addFields({
|
embed.addFields({
|
||||||
name: `#${remind.id} • ${loc.get("c_reminder9")} ${showDate(
|
name: `#${remind.id} • ${loc.get("c_reminder9")} ${showDate(
|
||||||
local,
|
local,
|
||||||
|
|
|
@ -5,11 +5,7 @@
|
||||||
* @param date Date
|
* @param date Date
|
||||||
* @returns String
|
* @returns String
|
||||||
*/
|
*/
|
||||||
export const showDate = (
|
export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) => {
|
||||||
tz: string,
|
|
||||||
locale: Map<string, unknown>,
|
|
||||||
date: Date
|
|
||||||
) => {
|
|
||||||
return date.toLocaleString(tz).replace(" ", ` ${locale.get("u_time_at")} `);
|
return date.toLocaleString(tz).replace(" ", ` ${locale.get("u_time_at")} `);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue