style(norme/eslint): now edited the husky rules before commiting

This commit is contained in:
Raphael 2025-08-18 14:57:23 +02:00
parent 439ddab587
commit 1c4c0f5872
16 changed files with 1883 additions and 1845 deletions

View file

@ -1,55 +1,55 @@
import js from "@eslint/js";
import ts from "typescript-eslint";
import js from '@eslint/js';
import ts from 'typescript-eslint';
export default [
js.configs.recommended,
...ts.configs.recommended,
{
languageOptions: {
ecmaVersion: "latest",
ecmaVersion: 'latest',
},
rules: {
"arrow-spacing": ["warn", { before: true, after: true }],
"brace-style": ["error", "stroustrup", { allowSingleLine: true }],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"comma-style": "error",
curly: ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"handle-callback-err": "off",
indent: ["error", "tab"],
"keyword-spacing": "error",
"max-nested-callbacks": ["error", { max: 4 }],
"max-statements-per-line": ["error", { max: 2 }],
"no-console": "off",
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { max: 2, maxEOF: 1, maxBOF: 0 }],
"no-shadow": ["error", { allow: ["err", "resolve", "reject"] }],
"no-trailing-spaces": ["error"],
"no-var": "error",
"no-undef": "off",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
quotes: ["error", "single"],
semi: ["error", "always"],
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
'arrow-spacing': ['warn', { before: true, after: true }],
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': 'error',
'comma-style': 'error',
curly: ['error', 'multi-line', 'consistent'],
'dot-location': ['error', 'property'],
'handle-callback-err': 'off',
indent: ['error', 'tab'],
'keyword-spacing': 'error',
'max-nested-callbacks': ['error', { max: 4 }],
'max-statements-per-line': ['error', { max: 2 }],
'no-console': 'off',
'no-empty-function': 'error',
'no-floating-decimal': 'error',
'no-inline-comments': 'error',
'no-lonely-if': 'error',
'no-multi-spaces': 'error',
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }],
'no-shadow': ['error', { allow: ['err', 'resolve', 'reject'] }],
'no-trailing-spaces': ['error'],
'no-var': 'error',
'no-undef': 'off',
'object-curly-spacing': ['error', 'always'],
'prefer-const': 'error',
quotes: ['error', 'single'],
semi: ['error', 'always'],
'space-before-blocks': 'error',
'space-before-function-paren': [
'error',
{
anonymous: "never",
named: "never",
asyncArrow: "always",
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
},
],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
yoda: "error",
'space-in-parens': 'error',
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'spaced-comment': 'error',
yoda: 'error',
},
},
];

View file

@ -9,12 +9,8 @@
},
"private": true,
"lint-staged": {
"*.{ts,js,cts,mts}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md,yml,yaml}": [
"prettier --write"
"*": [
"eslint --fix"
]
},
"devDependencies": {

View file

@ -1,4 +1,4 @@
import { prisma } from "../../lib/prisma.ts";
import { prisma } from '../../lib/prisma.ts';
import {
ActionRowBuilder,
ChannelType,
@ -11,30 +11,30 @@ import {
MessageFlags,
SlashCommandBuilder,
EmbedBuilder,
} from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
} from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default {
data: new SlashCommandBuilder()
.setName("logs")
.setDescription("edit the logs configuration")
.setName('logs')
.setDescription('edit the logs configuration')
.addStringOption((option) =>
option
.setName("action")
.setDescription("What is the action you to perform")
.setName('action')
.setDescription('What is the action you to perform')
.setRequired(true)
.addChoices(
{
name: "Show",
value: "logs_show",
name: 'Show',
value: 'logs_show',
},
{
name: "Auto-configuration",
value: "logs_auto",
name: 'Auto-configuration',
value: 'logs_auto',
},
{
name: "Configuration",
value: "logs_config",
name: 'Configuration',
value: 'logs_config',
},
),
),
@ -46,7 +46,8 @@ export default {
id: interaction.guild.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -63,7 +64,8 @@ export default {
id: interaction.user.id,
},
});
} catch (err) {
}
catch (err) {
throw `\t⚠ | Cannot get the database connection!\n\t\t(${err}).`;
await interaction.reply({
content: `${emoji.answer.error} | Cannot connect to the database`,
@ -71,9 +73,9 @@ export default {
});
return;
}
const choice: string = interaction.options.getString("action");
const choice: string = interaction.options.getString('action');
switch (choice) {
case "logs_show": {
case 'logs_show': {
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
@ -100,7 +102,8 @@ export default {
await interaction.reply({
embeds: [logsData],
});
} else {
}
else {
await interaction.reply({
content: `${emoji.answer.no} | The log is disable on the server`,
flags: MessageFlags.Ephemeral,
@ -108,7 +111,7 @@ export default {
}
return;
}
case "logs_auto": {
case 'logs_auto': {
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
@ -129,8 +132,8 @@ export default {
.sort((a, b) => b.position - a.position);
const menu = new StringSelectMenuBuilder()
.setCustomId("role_select")
.setPlaceholder("Choose the role that will have logs access")
.setCustomId('role_select')
.setPlaceholder('Choose the role that will have logs access')
.setMinValues(1)
.setMaxValues(Math.min(roles.size, 25))
.addOptions(
@ -145,7 +148,7 @@ export default {
new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(menu);
const permSelector: EmbedBuilder = new EmbedBuilder()
.setTitle("Which role will have access")
.setTitle('Which role will have access')
.setColor(`${guildData.color}`)
.setFooter({
text: guildData.footer,
@ -162,7 +165,7 @@ export default {
max: 25,
});
collector.on(
"collect",
'collect',
async (selectInteraction: StringSelectMenuInteraction) => {
if (selectInteraction.user.id !== interaction.user.id) {
selectInteraction.reply({
@ -187,48 +190,48 @@ export default {
];
const category = (await interaction.guild.channels.create({
name: "Logs",
name: 'Logs',
type: ChannelType.GuildCategory,
permissionOverwrites,
})) as CategoryChannel;
const logBot = (await interaction.guild.channels.create({
name: "bot-logs",
name: 'bot-logs',
type: ChannelType.GuildText,
parent: category,
permissionOverwrites,
})) as TextChannel;
const logChannels = (await interaction.guild.channels.create({
name: "channel-logs",
name: 'channel-logs',
type: ChannelType.GuildText,
parent: category,
permissionOverwrites,
})) as TextChannel;
const logMember = (await interaction.guild.channels.create({
name: "member-logs",
name: 'member-logs',
type: ChannelType.GuildText,
parent: category,
permissionOverwrites,
})) as TextChannel;
const logMod = (await interaction.guild.channels.create({
name: "mod-logs",
name: 'mod-logs',
type: ChannelType.GuildText,
parent: category,
permissionOverwrites,
})) as TextChannel;
const logMsg = (await interaction.guild.channels.create({
name: "message-logs",
name: 'message-logs',
type: ChannelType.GuildText,
parent: category,
permissionOverwrites,
})) as TextChannel;
const logServer = (await interaction.guild.channels.create({
name: "server-logs",
name: 'server-logs',
type: ChannelType.GuildText,
parent: category,
permissionOverwrites,
@ -251,9 +254,9 @@ export default {
});
const mentionList = selectedRoles
.map((id) => `- <@&${id}>`)
.join("\n");
.join('\n');
const autoConfig = new EmbedBuilder()
.setTitle("The logs category is created")
.setTitle('The logs category is created')
.setDescription(
`
This following roles will have access to the logs.

View file

@ -1,108 +1,108 @@
import { prisma } from "../../lib/prisma.ts";
import { prisma } from '../../lib/prisma.ts';
import {
ActivityType,
PresenceUpdateStatus,
MessageFlags,
SlashCommandBuilder,
} from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
} from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default {
data: new SlashCommandBuilder()
.setName("set")
.setDescription("edit the default behavour of the bot")
.setName('set')
.setDescription('edit the default behavour of the bot')
.addSubcommand((subcommand) =>
subcommand
.setName("color")
.setDescription("Change the default color for the embed")
.setName('color')
.setDescription('Change the default color for the embed')
.addStringOption((option) =>
option
.setName("color")
.setDescription("The new color by default")
.setName('color')
.setDescription('The new color by default')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("footer")
.setDescription("Change the default footer for the embed")
.setName('footer')
.setDescription('Change the default footer for the embed')
.addStringOption((option) =>
option
.setName("text")
.setDescription("The new text by default of the bot")
.setName('text')
.setDescription('The new text by default of the bot')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("pp")
.setDescription("Change the bot profile picture")
.setName('pp')
.setDescription('Change the bot profile picture')
.addStringOption((option) =>
option
.setName("link")
.setDescription("The new link to the new profile picture")
.setName('link')
.setDescription('The new link to the new profile picture')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("status")
.setDescription("Change the status of the bot")
.setName('status')
.setDescription('Change the status of the bot')
.addStringOption((option) =>
option
.setName("status")
.setDescription("The new status used by the bot")
.setName('status')
.setDescription('The new status used by the bot')
.setRequired(true),
)
.addStringOption((option) =>
option
.setName("presence")
.setDescription("The new presence of the bot")
.setName('presence')
.setDescription('The new presence of the bot')
.setRequired(true)
.addChoices(
{
name: "Online",
value: "online",
name: 'Online',
value: 'online',
},
{
name: "Do not disturb",
value: "dnd",
name: 'Do not disturb',
value: 'dnd',
},
{
name: "Idle",
value: "idle",
name: 'Idle',
value: 'idle',
},
{
name: "Invisible",
value: "invisible",
name: 'Invisible',
value: 'invisible',
},
),
)
.addStringOption((option) =>
option
.setName("type")
.setDescription("The type of the new activity")
.setName('type')
.setDescription('The type of the new activity')
.setRequired(true)
.addChoices(
{
name: "Playing",
value: "play",
name: 'Playing',
value: 'play',
},
{
name: "Watching",
value: "watch",
name: 'Watching',
value: 'watch',
},
{
name: "Listening",
value: "listen",
name: 'Listening',
value: 'listen',
},
{
name: "Competing",
value: "competing",
name: 'Competing',
value: 'competing',
},
{
name: "Streaming",
value: "stream",
name: 'Streaming',
value: 'stream',
},
),
),
@ -115,7 +115,8 @@ export default {
id: interaction.user.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -127,7 +128,7 @@ export default {
}
const subcommand: string = interaction.options.getSubcommand();
switch (subcommand) {
case "color": {
case 'color': {
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
@ -135,7 +136,7 @@ export default {
});
return;
}
const newColor: string = interaction.options.getString("color");
const newColor: string = interaction.options.getString('color');
if (!/^#[0-9A-Fa-f]{6}$/.test(newColor)) {
await interaction.reply({
content: `${emoji.answer.no} | You have to give a color with the syntax: \`#000000\`.`,
@ -161,7 +162,7 @@ export default {
});
return;
}
case "footer": {
case 'footer': {
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
@ -169,7 +170,7 @@ export default {
});
return;
}
const newFooter: string = interaction.options.getString("text");
const newFooter: string = interaction.options.getString('text');
if (newFooter.length > 2048) {
await interaction.reply({
content: `${emoji.answer.no} | The maximum lenght for the footer is 2048`,
@ -195,7 +196,7 @@ export default {
});
return;
}
case "pp": {
case 'pp': {
if (!userData.isBuyer) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`,
@ -203,10 +204,11 @@ export default {
});
return;
}
const newPicture: string = interaction.options.getString("link");
const newPicture: string = interaction.options.getString('link');
try {
interaction.client.user.setAvatar(newPicture);
} catch (err) {
}
catch (err) {
await interaction.reply({
content: `${emoji.answer.no} | Error during changing the bot profile picture`,
flags: MessageFlags.Ephemeral,
@ -221,7 +223,7 @@ export default {
});
return;
}
case "status": {
case 'status': {
if (!userData.isBuyer) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`,
@ -229,39 +231,39 @@ export default {
});
return;
}
const newStatus: string = interaction.options.getString("status");
const tmpType: string = interaction.options.getString("type");
const newStatus: string = interaction.options.getString('status');
const tmpType: string = interaction.options.getString('type');
let newType: ActivityType;
switch (tmpType) {
case "play":
case 'play':
newType = ActivityType.Playing;
break;
case "listen":
case 'listen':
newType = ActivityType.Listening;
break;
case "watch":
case 'watch':
newType = ActivityType.Watching;
break;
case "stream":
case 'stream':
newType = ActivityType.Streaming;
break;
case "competing":
case 'competing':
newType = ActivityType.Competing;
break;
}
const tmpPresence: string = interaction.options.getString("presence");
const tmpPresence: string = interaction.options.getString('presence');
let newPresence: PresenceUpdateStatus;
switch (tmpPresence) {
case "online":
case 'online':
newPresence = PresenceUpdateStatus.Online;
break;
case "idle":
case 'idle':
newPresence = PresenceUpdateStatus.Idle;
break;
case "dnd":
case 'dnd':
newPresence = PresenceUpdateStatus.DoNotDisturb;
break;
case "invisible":
case 'invisible':
newPresence = PresenceUpdateStatus.Invisible;
break;
}
@ -282,18 +284,19 @@ export default {
presence: newPresence,
},
});
if (tmpType === "steam") {
if (tmpType === 'steam') {
interaction.client.user.setPresence({
status: newPresence,
activities: [
{
name: newStatus,
type: newType,
url: "https://twitch.tv/EniumRaphael",
url: 'https://twitch.tv/EniumRaphael',
},
],
});
} else {
}
else {
interaction.client.user.setPresence({
status: newPresence,
activities: [
@ -304,7 +307,8 @@ export default {
],
});
}
} catch (err) {
}
catch (err) {
await interaction.reply({
content: `${emoji.answer.no} | Cannot change the status\n\n\t${err}`,
flags: MessageFlags.Ephemeral,

View file

@ -1,35 +1,35 @@
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
import { prisma } from "../../lib/prisma.ts";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from 'discord.js';
import { prisma } from '../../lib/prisma.ts';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default {
data: new SlashCommandBuilder()
.setName("buyer")
.setDescription("Interact with the buyers")
.setName('buyer')
.setDescription('Interact with the buyers')
.addSubcommand((subcommand) =>
subcommand
.setName("add")
.setDescription("Add a user on the buyer list")
.setName('add')
.setDescription('Add a user on the buyer list')
.addUserOption((option) =>
option
.setName("target")
.setDescription("The user who will be added to the list")
.setName('target')
.setDescription('The user who will be added to the list')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("delete")
.setDescription("Delete a user on the buyer list")
.setName('delete')
.setDescription('Delete a user on the buyer list')
.addUserOption((option) =>
option
.setName("target")
.setDescription("The user who will be deleted to the list")
.setName('target')
.setDescription('The user who will be deleted to the list')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand.setName("list").setDescription("The list of the buyer"),
subcommand.setName('list').setDescription('The list of the buyer'),
),
async execute(interaction: CommandInteraction) {
const subcommand = interaction.options.getSubcommand();
@ -40,7 +40,8 @@ export default {
id: interaction.user.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -57,7 +58,8 @@ export default {
id: interaction.guild.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -67,9 +69,9 @@ export default {
});
return;
}
const target: GuildMember = interaction.options.getUser("target");
const target: GuildMember = interaction.options.getUser('target');
switch (subcommand) {
case "add":
case 'add':
if (!userData.isDev) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for the developper of the bot`,
@ -109,7 +111,8 @@ export default {
isOwner: true,
},
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | Error when adding ${target.username} to the buyer list\n\t${err}`,
);
@ -124,14 +127,15 @@ export default {
flags: MessageFlags.Ephemeral,
});
return;
case "delete":
case 'delete':
if (!userData.isDev) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`,
flags: MessageFlags.Ephemeral,
});
return;
} else if (interaction.user.id === target.id) {
}
else if (interaction.user.id === target.id) {
await interaction.reply({
content: `${emoji.answer.no} | You cannot removing yourself from the buyer list`,
flags: MessageFlags.Ephemeral,
@ -170,7 +174,8 @@ export default {
isOwner: false,
},
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | Error when removing ${target.username} to the buyer list\n\t${err}`,
);
@ -181,7 +186,7 @@ export default {
flags: MessageFlags.Ephemeral,
});
return;
case "list":
case 'list':
if (!userData.isBuyer) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`,
@ -212,7 +217,8 @@ export default {
try {
const user = await interaction.client.users.fetch(buyer.id);
return `- ${user.username} (\`${user.id}\`)\n`;
} catch (err) {
}
catch (err) {
console.warn(`⚠️ | ${buyer.id} : ${err}`);
return null;
}
@ -225,12 +231,13 @@ export default {
.setFooter({
text: guildData.footer,
})
.setDescription(buyerList.filter(Boolean).join(""));
.setDescription(buyerList.filter(Boolean).join(''));
await interaction.reply({
embeds: [toSend],
flags: MessageFlags.Ephemeral,
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | error when fetching infromation from the database: ${err}`,
);

View file

@ -1,35 +1,35 @@
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
import { prisma } from "../../lib/prisma.ts";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from 'discord.js';
import { prisma } from '../../lib/prisma.ts';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default {
data: new SlashCommandBuilder()
.setName("owner")
.setDescription("Interact with the owners")
.setName('owner')
.setDescription('Interact with the owners')
.addSubcommand((subcommand) =>
subcommand
.setName("add")
.setDescription("Add a user on the owner list")
.setName('add')
.setDescription('Add a user on the owner list')
.addUserOption((option) =>
option
.setName("target")
.setDescription("The user who will be added to the list")
.setName('target')
.setDescription('The user who will be added to the list')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("delete")
.setDescription("Delete a user on the owner list")
.setName('delete')
.setDescription('Delete a user on the owner list')
.addUserOption((option) =>
option
.setName("target")
.setDescription("The user who will be deleted to the list")
.setName('target')
.setDescription('The user who will be deleted to the list')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand.setName("list").setDescription("The list of the owner"),
subcommand.setName('list').setDescription('The list of the owner'),
),
async execute(interaction: CommandInteraction) {
const subcommand = interaction.options.getSubcommand();
@ -40,7 +40,8 @@ export default {
id: interaction.user.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -57,7 +58,8 @@ export default {
id: interaction.guild.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -67,9 +69,9 @@ export default {
});
return;
}
const target: GuildMember = interaction.options.getUser("target");
const target: GuildMember = interaction.options.getUser('target');
switch (subcommand) {
case "add":
case 'add':
if (!userData.isBuyer) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`,
@ -102,7 +104,8 @@ export default {
isOwner: true,
},
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | Error when adding ${target.username} to the owner list\n\t${err}`,
);
@ -117,14 +120,15 @@ export default {
flags: MessageFlags.Ephemeral,
});
return;
case "delete":
case 'delete':
if (!userData.isBuyer) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for buyer`,
flags: MessageFlags.Ephemeral,
});
return;
} else if (interaction.user.id === target.id) {
}
else if (interaction.user.id === target.id) {
await interaction.reply({
content: `${emoji.answer.no} | You cannot removing yourself from the owner list`,
flags: MessageFlags.Ephemeral,
@ -156,7 +160,8 @@ export default {
isOwner: false,
},
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | Error when removing ${target.username} to the owner list\n\t${err}`,
);
@ -171,7 +176,7 @@ export default {
flags: MessageFlags.Ephemeral,
});
return;
case "list":
case 'list':
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
@ -202,7 +207,8 @@ export default {
try {
const user = await interaction.client.users.fetch(owner.id);
return `- ${user.username} (\`${user.id}\`)\n`;
} catch (err) {
}
catch (err) {
console.warn(`⚠️ | ${owner.id} : ${err}`);
return null;
}
@ -215,12 +221,13 @@ export default {
.setFooter({
text: guildData.footer,
})
.setDescription(ownerList.filter(Boolean).join(""));
.setDescription(ownerList.filter(Boolean).join(''));
await interaction.reply({
embeds: [toSend],
flags: MessageFlags.Ephemeral,
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | error when fetching infromation from the database: ${err}`,
);

View file

@ -1,35 +1,35 @@
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from "discord.js";
import { prisma } from "../../lib/prisma.ts";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from 'discord.js';
import { prisma } from '../../lib/prisma.ts';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default {
data: new SlashCommandBuilder()
.setName("whitelist")
.setDescription("Interact with the whitelist")
.setName('whitelist')
.setDescription('Interact with the whitelist')
.addSubcommand((subcommand) =>
subcommand
.setName("add")
.setDescription("Add a user on the whitelist")
.setName('add')
.setDescription('Add a user on the whitelist')
.addUserOption((option) =>
option
.setName("target")
.setDescription("The user who will be added to the whitelist")
.setName('target')
.setDescription('The user who will be added to the whitelist')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("delete")
.setDescription("Delete a user on the whitelist")
.setName('delete')
.setDescription('Delete a user on the whitelist')
.addUserOption((option) =>
option
.setName("target")
.setDescription("The user who will be deleted to the whitelist")
.setName('target')
.setDescription('The user who will be deleted to the whitelist')
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
subcommand.setName("list").setDescription("Show the whitelist"),
subcommand.setName('list').setDescription('Show the whitelist'),
),
async execute(interaction: CommandInteraction) {
const subcommand = interaction.options.getSubcommand();
@ -40,7 +40,8 @@ export default {
id: interaction.user.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Whitelist => Cannot get the database connection!\n\t\t(${err}).`,
);
@ -57,7 +58,8 @@ export default {
id: interaction.guild.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -67,9 +69,9 @@ export default {
});
return;
}
const target: GuildMember = interaction.options.getUser("target");
const target: GuildMember = interaction.options.getUser('target');
switch (subcommand) {
case "add":
case 'add':
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
@ -106,7 +108,8 @@ export default {
},
},
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | Error when adding ${target.username} to the whitelist\n\t${err}`,
);
@ -121,14 +124,15 @@ export default {
flags: MessageFlags.Ephemeral,
});
return;
case "delete":
case 'delete':
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
flags: MessageFlags.Ephemeral,
});
return;
} else if (interaction.user.id === target.id) {
}
else if (interaction.user.id === target.id) {
await interaction.reply({
content: `${emoji.answer.no} | You cannot removing yourself from the whitelist`,
flags: MessageFlags.Ephemeral,
@ -164,7 +168,8 @@ export default {
},
},
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | Error when removing ${target.username} to the username\n\t${err}`,
);
@ -179,7 +184,7 @@ export default {
flags: MessageFlags.Ephemeral,
});
return;
case "list":
case 'list':
if (!userData.isOwner) {
await interaction.reply({
content: `${emoji.answer.no} | This command is only for owner`,
@ -210,7 +215,8 @@ export default {
try {
const user = await interaction.client.users.fetch(whitelist.id);
return `- ${user.username} (\`${user.id}\`)\n`;
} catch (err) {
}
catch (err) {
console.warn(`⚠️ | ${whitelist.id} : ${err}`);
return null;
}
@ -218,17 +224,18 @@ export default {
);
const toSend: EmbedBuilder = new EmbedBuilder()
.setTitle("🗞️ | Whitelist")
.setTitle('🗞️ | Whitelist')
.setColor(guildData.color)
.setFooter({
text: guildData.footer,
})
.setDescription(WlUsers.filter(Boolean).join(""));
.setDescription(WlUsers.filter(Boolean).join(''));
await interaction.reply({
embeds: [toSend],
flags: MessageFlags.Ephemeral,
});
} catch (err) {
}
catch (err) {
console.error(
`⚠️ | Whitelist => error when fetching infromation from the database: ${err}`,
);

View file

@ -1,15 +1,15 @@
import { MessageFlags, ChannelType, SlashCommandBuilder } from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
import { prisma } from "../../lib/prisma.ts";
import { MessageFlags, ChannelType, SlashCommandBuilder } from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
import { prisma } from '../../lib/prisma.ts';
export default {
data: new SlashCommandBuilder()
.setName("deletecat")
.setDescription("Delete the categorie given in parameter")
.setName('deletecat')
.setDescription('Delete the categorie given in parameter')
.addChannelOption((opt) =>
opt
.setName("category")
.setDescription("Choose the categorie you want to delete")
.setName('category')
.setDescription('Choose the categorie you want to delete')
.setRequired(true)
.addChannelTypes(ChannelType.GuildCategory),
),
@ -21,7 +21,8 @@ export default {
id: interaction.user.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Whitelist => Cannot get the database connection!\n\t\t(${err}).`,
);
@ -40,7 +41,7 @@ export default {
return;
}
const category: GuildCategory = interaction.options.getChannel(
"category",
'category',
true,
);
try {
@ -56,7 +57,8 @@ export default {
content: `${emoji.answer.yes} | Suppressed the ${category.name}`,
flags: MessageFlags.Ephemeral,
});
} catch (err) {
}
catch (err) {
await interaction.reply({
content: `${emoji.answer.error} | Cannot suppress the category's channels`,
flags: MessageFlags.Ephemeral,

View file

@ -1,12 +1,12 @@
import { prisma } from "../../lib/prisma.ts";
import { prisma } from '../../lib/prisma.ts';
import {
userMention,
roleMention,
MessageFlags,
SlashCommandBuilder,
EmbedBuilder,
} from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
} from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
function getGuildRoles(guild: Guild): string {
const roles = guild.roles.cache
@ -14,7 +14,7 @@ function getGuildRoles(guild: Guild): string {
.sort((a, b) => b.position - a.position)
.map((role) => roleMention(role.id));
return roles.length > 0 ? roles.join(", ") : "No role";
return roles.length > 0 ? roles.join(', ') : 'No role';
}
function getUserRoles(target: GuildMember): string {
@ -23,7 +23,7 @@ function getUserRoles(target: GuildMember): string {
.sort((a, b) => b.position - a.position)
.map((role) => `${roleMention(role.id)}`);
return roles.length > 0 ? roles.join(", ") : "No role";
return roles.length > 0 ? roles.join(', ') : 'No role';
}
function getUserBadges(userData: {
@ -40,29 +40,29 @@ function getUserBadges(userData: {
if (userData.isBuyer) badges.push(`${emoji.badge.buyer}`);
if (userData.isOwner) badges.push(`${emoji.badge.owner}`);
return badges.length > 0 ? badges.join(" ") : "Aucun badge";
return badges.length > 0 ? badges.join(' ') : 'Aucun badge';
}
export default {
data: new SlashCommandBuilder()
.setName("info")
.setName('info')
.setDescription(
"Show the infromation of one of these categories (user, server, bot)",
'Show the infromation of one of these categories (user, server, bot)',
)
.addSubcommand((subcommand) =>
subcommand
.setName("user")
.setDescription("Show the infromation of one user")
.setName('user')
.setDescription('Show the infromation of one user')
.addUserOption((option) =>
option
.setName("target")
.setDescription("The user to show the infromation"),
.setName('target')
.setDescription('The user to show the infromation'),
),
)
.addSubcommand((subcommand) =>
subcommand
.setName("server")
.setDescription("Show the infromation of the server"),
.setName('server')
.setDescription('Show the infromation of the server'),
),
async execute(interaction: CommandInteraction) {
let guildData: Guild;
@ -72,7 +72,8 @@ export default {
id: interaction.guild.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -84,9 +85,9 @@ export default {
}
const subcommand: string = interaction.options.getSubcommand();
switch (subcommand) {
case "user": {
case 'user': {
const targetGlobal: GuildMember =
interaction.options.getUser("target") || interaction.user;
interaction.options.getUser('target') || interaction.user;
await targetGlobal.fetch();
let userData: User;
try {
@ -95,7 +96,8 @@ export default {
id: targetGlobal.id,
},
});
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);
@ -108,7 +110,8 @@ export default {
try {
targetServer = await interaction.guild.members.fetch(targetGlobal.id);
} catch (err) {
}
catch (err) {
console.error(`\t⚠ | Cannot get the targetServer!\n\t\t(${err}).`);
await interaction.reply({
content: `${emoji.answer.error} | Cannot get the guild profile of the user`,
@ -152,7 +155,7 @@ export default {
});
return;
}
case "server": {
case 'server': {
const guild: Guild = interaction.guild;
const serverResult: EmbedBuilder = new EmbedBuilder()
.setTitle(`${guild.name} Informations`)
@ -167,9 +170,9 @@ export default {
${guild.id}
**🖊 | Description:**
${guild.description || "No description given."}
${guild.description || 'No description given.'}
**🔗 | VanityLink:**
${guild.vanityURLCode || "No custom link."}
${guild.vanityURLCode || 'No custom link.'}
**🆕 | Creation Date:**
<t:${parseInt(guild.createdTimestamp / 1000)}:R>

View file

@ -1,10 +1,10 @@
import { MessageFlags, SlashCommandBuilder } from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
import { MessageFlags, SlashCommandBuilder } from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Show your latency"),
.setName('ping')
.setDescription('Show your latency'),
async execute(interaction: CommandInteraction) {
const time: number = Date.now();
await interaction.reply({

View file

@ -1,5 +1,5 @@
import { Events } from "discord.js";
import { prisma } from "../../lib/prisma.ts";
import { Events } from 'discord.js';
import { prisma } from '../../lib/prisma.ts';
export default {
name: Events.GuildCreate,

View file

@ -1,5 +1,5 @@
import { ActivityType, PresenceUpdateStatus, Events } from "discord.js";
import { prisma } from "../../lib/prisma.ts";
import { ActivityType, PresenceUpdateStatus, Events } from 'discord.js';
import { prisma } from '../../lib/prisma.ts';
export default {
name: Events.ClientReady,
@ -15,50 +15,51 @@ export default {
const tmpType: string = botData.type;
let newType: ActivityType;
switch (tmpType) {
case "play":
case 'play':
newType = ActivityType.Playing;
break;
case "listen":
case 'listen':
newType = ActivityType.Listening;
break;
case "watch":
case 'watch':
newType = ActivityType.Watching;
break;
case "stream":
case 'stream':
newType = ActivityType.Streaming;
break;
case "comptet":
case 'comptet':
newType = ActivityType.Competing;
break;
}
const tmpPresence: string = botData.presence;
let newPresence: PresenceUpdateStatus;
switch (tmpPresence) {
case "online":
case 'online':
newPresence = PresenceUpdateStatus.Online;
break;
case "idle":
case 'idle':
newPresence = PresenceUpdateStatus.Idle;
break;
case "dnd":
case 'dnd':
newPresence = PresenceUpdateStatus.DoNotDisturb;
break;
case "invisible":
case 'invisible':
newPresence = PresenceUpdateStatus.Invisible;
break;
}
if (botData.type === "steam") {
if (botData.type === 'steam') {
client.user.setPresence({
status: newPresence,
activities: [
{
name: newStatus,
type: newType,
url: "https://twich.tv/EniumRaphael",
url: 'https://twich.tv/EniumRaphael',
},
],
});
} else {
}
else {
client.user.setPresence({
status: newPresence,
activities: [
@ -69,7 +70,8 @@ export default {
],
});
}
} catch (err) {
}
catch (err) {
console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`,
);

View file

@ -1,5 +1,5 @@
import { Events, MessageFlags } from "discord.js";
import emoji from "../../../assets/emoji.json" assert { type: "json" };
import { Events, MessageFlags } from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default {
name: Events.InteractionCreate,
@ -16,7 +16,8 @@ export default {
}
try {
await command.execute(interaction);
} catch (error) {
}
catch (error) {
console.error(
`⚠️ | Error when occured this command ${interaction.commandName}\n\t${error}`,
);
@ -25,7 +26,8 @@ export default {
content: `${emoji.answer.error} | ${interaction.commandName} seems have a problem, thanks report that to the support (After Print)`,
flags: MessageFlags.Ephemeral,
});
} else {
}
else {
await interaction.reply({
content: `${emoji.answer.error} | ${interaction.commandName} seems have a problem, thanks report that to the support (Before Print)`,
flags: MessageFlags.Ephemeral,

View file

@ -1,8 +1,8 @@
import fs from "node:fs";
import path from "node:path";
import "dotenv/config";
import { Client, Collection, GatewayIntentBits } from "discord.js";
import { PrismaClient } from "@prisma/client";
import fs from 'node:fs';
import path from 'node:path';
import 'dotenv/config';
import { Client, Collection, GatewayIntentBits } from 'discord.js';
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
@ -19,61 +19,64 @@ client.login(process.env.DSC_TOKEN);
client.commands = new Collection();
const commandFolderPath = path.join(__dirname, "commands");
const commandFolderPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(commandFolderPath);
console.log("\n🔍 | Commands search:");
console.log('\n🔍 | Commands search:');
for (const folder of commandFolders) {
const commandsPath = path.join(commandFolderPath, folder);
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
.filter((file) => file.endsWith('.js') || file.endsWith('.ts'));
for (const file of commandFiles) {
const fullCommandPath = path.join(commandsPath, file);
try {
const commandModule = await import(fullCommandPath);
const command = commandModule.default || commandModule;
if ("data" in command && "execute" in command) {
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
console.log(`\t✅ | ${command.data.name}`);
}
} catch (err) {
}
catch (err) {
console.error(`\t⚠ | Command at ${file}\n\t\t(${err}).`);
}
}
}
console.log("\n\n");
console.log('\n\n');
const eventFolderPath = path.join(__dirname, "events");
const eventFolderPath = path.join(__dirname, 'events');
const eventFolders = fs.readdirSync(eventFolderPath);
console.log("\n🔍 | Events search:");
console.log('\n🔍 | Events search:');
for (const folder of eventFolders) {
const eventsPath = path.join(eventFolderPath, folder);
const eventFiles = fs
.readdirSync(eventsPath)
.filter((file) => file.endsWith(".js") || file.endsWith(".ts"));
.filter((file) => file.endsWith('.js') || file.endsWith('.ts'));
for (const file of eventFiles) {
const fullEventPath = path.join(eventsPath, file);
try {
const eventModule = await import(fullEventPath);
const event = eventModule.default || eventModule;
if ("name" in event && "execute" in event) {
if ('name' in event && 'execute' in event) {
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
}
else {
client.on(event.name, (...args) => event.execute(...args));
}
console.log(`\t✅ | ${event.name}`);
}
} catch (err) {
}
catch (err) {
console.error(`\t⚠ | Event at ${file}\n\t\t(${err}).`);
}
}
}
console.log("\n\n");
console.log('\n\n');
client.once("ready", async () => {
client.once('ready', async () => {
console.log(`🤖 | Connecté en tant que ${client.user?.tag}`);
await prisma.bot.upsert({

View file

@ -1,8 +1,8 @@
import { REST, Routes } from "discord.js";
import { Client, Collection, GatewayIntentBits } from "discord.js";
import "dotenv/config";
import fs from "node:fs";
import path from "node:path";
import { REST, Routes } from 'discord.js';
import { Client, Collection, GatewayIntentBits } from 'discord.js';
import 'dotenv/config';
import fs from 'node:fs';
import path from 'node:path';
const client = new Client({
intents: [GatewayIntentBits.Guilds],
@ -12,21 +12,22 @@ client.commands = new Collection();
const commands = [];
const foldersPath = path.join(__dirname, "../commands");
const foldersPath = path.join(__dirname, '../commands');
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".ts") || file.endsWith(".js"));
.filter((file) => file.endsWith('.ts') || file.endsWith('.js'));
for (const file of commandFiles) {
const filesPath = path.join(commandsPath, file);
const commandModule = await import(filesPath);
const command = commandModule.default || commandModule;
if ("data" in command && "execute" in command) {
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
}
else {
console.log(
'⚠️ | A Command is missing a required "data" or "execute" property.',
);
@ -46,7 +47,8 @@ const rest = new REST().setToken(process.env.DSC_TOKEN);
},
);
console.log(`✅ | ${data.length} is now reloaded`);
} catch (error) {
}
catch (error) {
console.error(error);
}
})();

View file

@ -1,3 +1,3 @@
import { PrismaClient } from "@prisma/client";
import { PrismaClient } from '@prisma/client';
export const prisma = new PrismaClient();