refactor(all): uniformisation
This commit is contained in:
89 files changed
+10215
-10215
No files matched your search
+107
-107
@@ -1,107 +1,107 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { ACCESS_LEVELS, COLORS } from '../../config/constants.js';
|
||||
import { parseChoices } from '../../services/polls/poll-service.js';
|
||||
import { baseEmbed, bullets } from '../../ui/embeds.js';
|
||||
|
||||
export const access = ACCESS_LEVELS.USER;
|
||||
|
||||
const EIGHT_BALL_ANSWERS = Object.freeze([
|
||||
'Oui, sans aucun doute.',
|
||||
'Compte là-dessus et bois de l’eau.',
|
||||
'Les signes disent que oui.',
|
||||
'Impossible de le prédire pour le moment.',
|
||||
'Concentre-toi et redemande.',
|
||||
'Ma réponse est non.',
|
||||
'Très probablement.',
|
||||
'Mes sources disent non.',
|
||||
'La réponse est floue, réessaie.',
|
||||
'Absolument !',
|
||||
'Pas dans un avenir proche.',
|
||||
'Oui, mais fais attention à toi.',
|
||||
]);
|
||||
|
||||
const pick = (list) => list[Math.floor(Math.random() * list.length)];
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName('fun')
|
||||
.setDescription('Commandes de divertissement')
|
||||
.addSubcommand((sub) => sub.setName('coinflip').setDescription('Pile ou face'))
|
||||
.addSubcommand((sub) =>
|
||||
sub
|
||||
.setName('dice')
|
||||
.setDescription('Lancer un dé')
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName('sides')
|
||||
.setDescription('Nombre de faces (6 par défaut)')
|
||||
.setMinValue(2)
|
||||
.setMaxValue(1000),
|
||||
),
|
||||
)
|
||||
.addSubcommand((sub) =>
|
||||
sub
|
||||
.setName('8ball')
|
||||
.setDescription('Poser une question à la boule magique')
|
||||
.addStringOption((option) =>
|
||||
option.setName('question').setDescription('Ta question').setRequired(true).setMaxLength(300),
|
||||
),
|
||||
)
|
||||
.addSubcommand((sub) =>
|
||||
sub
|
||||
.setName('choose')
|
||||
.setDescription('Choisir au hasard parmi plusieurs options')
|
||||
.addStringOption((option) =>
|
||||
option.setName('options').setDescription('Options séparées par ";" (2 à 10)').setRequired(true),
|
||||
),
|
||||
);
|
||||
|
||||
/** Lightweight, stateless fun commands (M10-T07). */
|
||||
export async function execute(interaction) {
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
|
||||
if (subcommand === 'coinflip') {
|
||||
const result = pick(['Pile', 'Face']);
|
||||
await interaction.reply({
|
||||
embeds: [baseEmbed(COLORS.info).setTitle('🪙 Pile ou face').setDescription(`**${result}** !`)],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (subcommand === 'dice') {
|
||||
const sides = interaction.options.getInteger('sides') ?? 6;
|
||||
const roll = 1 + Math.floor(Math.random() * sides);
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
baseEmbed(COLORS.info)
|
||||
.setTitle(`🎲 Lancer de dé (d${sides})`)
|
||||
.setDescription(`Tu obtiens **${roll}** !`),
|
||||
],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (subcommand === '8ball') {
|
||||
const question = interaction.options.getString('question', true);
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
baseEmbed(COLORS.info)
|
||||
.setTitle('🎱 Boule magique')
|
||||
.addFields(
|
||||
{ name: 'Question', value: question },
|
||||
{ name: 'Réponse', value: pick(EIGHT_BALL_ANSWERS) },
|
||||
),
|
||||
],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const options = parseChoices(interaction.options.getString('options', true));
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
baseEmbed(COLORS.info)
|
||||
.setTitle('🎯 Choix aléatoire')
|
||||
.addFields({ name: 'Options', value: bullets(options) })
|
||||
.setDescription(`Je choisis : **${pick(options)}**`),
|
||||
],
|
||||
});
|
||||
}
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import { ACCESS_LEVELS, COLORS } from '../../config/constants.js';
|
||||
import { parseChoices } from '../../services/polls/poll-service.js';
|
||||
import { baseEmbed, bullets } from '../../ui/embeds.js';
|
||||
|
||||
export const access = ACCESS_LEVELS.USER;
|
||||
|
||||
const EIGHT_BALL_ANSWERS = Object.freeze([
|
||||
'Oui, sans aucun doute.',
|
||||
'Compte là-dessus et bois de l’eau.',
|
||||
'Les signes disent que oui.',
|
||||
'Impossible de le prédire pour le moment.',
|
||||
'Concentre-toi et redemande.',
|
||||
'Ma réponse est non.',
|
||||
'Très probablement.',
|
||||
'Mes sources disent non.',
|
||||
'La réponse est floue, réessaie.',
|
||||
'Absolument !',
|
||||
'Pas dans un avenir proche.',
|
||||
'Oui, mais fais attention à toi.',
|
||||
]);
|
||||
|
||||
const pick = (list) => list[Math.floor(Math.random() * list.length)];
|
||||
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName('fun')
|
||||
.setDescription('Commandes de divertissement')
|
||||
.addSubcommand((sub) => sub.setName('coinflip').setDescription('Pile ou face'))
|
||||
.addSubcommand((sub) =>
|
||||
sub
|
||||
.setName('dice')
|
||||
.setDescription('Lancer un dé')
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName('sides')
|
||||
.setDescription('Nombre de faces (6 par défaut)')
|
||||
.setMinValue(2)
|
||||
.setMaxValue(1000),
|
||||
),
|
||||
)
|
||||
.addSubcommand((sub) =>
|
||||
sub
|
||||
.setName('8ball')
|
||||
.setDescription('Poser une question à la boule magique')
|
||||
.addStringOption((option) =>
|
||||
option.setName('question').setDescription('Ta question').setRequired(true).setMaxLength(300),
|
||||
),
|
||||
)
|
||||
.addSubcommand((sub) =>
|
||||
sub
|
||||
.setName('choose')
|
||||
.setDescription('Choisir au hasard parmi plusieurs options')
|
||||
.addStringOption((option) =>
|
||||
option.setName('options').setDescription('Options séparées par ";" (2 à 10)').setRequired(true),
|
||||
),
|
||||
);
|
||||
|
||||
/** Lightweight, stateless fun commands (M10-T07). */
|
||||
export async function execute(interaction) {
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
|
||||
if (subcommand === 'coinflip') {
|
||||
const result = pick(['Pile', 'Face']);
|
||||
await interaction.reply({
|
||||
embeds: [baseEmbed(COLORS.info).setTitle('🪙 Pile ou face').setDescription(`**${result}** !`)],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (subcommand === 'dice') {
|
||||
const sides = interaction.options.getInteger('sides') ?? 6;
|
||||
const roll = 1 + Math.floor(Math.random() * sides);
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
baseEmbed(COLORS.info)
|
||||
.setTitle(`🎲 Lancer de dé (d${sides})`)
|
||||
.setDescription(`Tu obtiens **${roll}** !`),
|
||||
],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (subcommand === '8ball') {
|
||||
const question = interaction.options.getString('question', true);
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
baseEmbed(COLORS.info)
|
||||
.setTitle('🎱 Boule magique')
|
||||
.addFields(
|
||||
{ name: 'Question', value: question },
|
||||
{ name: 'Réponse', value: pick(EIGHT_BALL_ANSWERS) },
|
||||
),
|
||||
],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const options = parseChoices(interaction.options.getString('options', true));
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
baseEmbed(COLORS.info)
|
||||
.setTitle('🎯 Choix aléatoire')
|
||||
.addFields({ name: 'Options', value: bullets(options) })
|
||||
.setDescription(`Je choisis : **${pick(options)}**`),
|
||||
],
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user