Skip to content

Commit

Permalink
add eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-210 committed Dec 13, 2021
1 parent 116e377 commit cb65371
Show file tree
Hide file tree
Showing 40 changed files with 2,428 additions and 1,515 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.git
.vs_code
.idea
10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": {
"node": true,
"es2021": true
},
"extends": [
"prettier",
"eslint:recommended",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"plugins": ["prettier"],
"rules": {
"no-console": "warn",
"prefer-const": "error",
"no-var": "error",
"prettier/prettier": "error",
"eqeqeq": "error"
}
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.git
.vs_code
.idea
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf"
}
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"start": "node src/index.js",
"deploy-commands": "node src/deploy-commands.js",
"test": "eslint --ext .js .",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"setup": "node src/setup.js"
},
"repository": {
Expand All @@ -29,17 +30,21 @@
"discord-player": "^5.1.0",
"discord.js": "^13.3.1",
"dotenv": "^10.0.0",
"eslint": "^8.2.0",
"eslint-config-google": "^0.14.0",
"ffmpeg-static": "^4.4.0",
"googleapis": "^92.0.0",
"jimp": "^0.3.11",
"mongodb": "^4.1.4",
"node-cron": "^3.0.0",
"ffmpeg-static": "^4.4.0",
"ms": "^2.1.3",
"node-cron": "^3.0.0",
"opusscript": "^0.0.8",
"quick.eco": "^6.0.0",
"quickmongo": "^4.0.0",
"winston": "^3.3.3"
},
"devDependencies": {
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.5.1"
}
}
139 changes: 90 additions & 49 deletions src/commands/ban.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,99 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageButton, MessageActionRow, MessageEmbed} = require('discord.js');
const {isMod, isAdmin} = require("../functions/isModOrAdmin");
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageButton, MessageActionRow, MessageEmbed } = require("discord.js");
const { isMod, isAdmin } = require("../functions/isModOrAdmin");

module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Bannir un membre (ADMIN).')
.addUserOption(option => option.setName('utilisateur').setDescription('Le membre à bannir').setRequired(true))
.addStringOption(option => option.setName('raison').setDescription('La raison pour laquelle bannir le membre').setRequired(true)),
async execute(client, interaction) {
const author = interaction.member;
const user = interaction.options.getMember('utilisateur');
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('oui')
.setLabel('Oui')
.setStyle('SUCCESS'),
new MessageButton()
.setCustomId('non')
.setLabel('Non')
.setStyle('DANGER'),
);
if (!isMod(client, interaction.member) && !isAdmin(client, interaction.member) && !interaction.member.permissions.has("BAN_MEMBERS")) {
return interaction.reply({ content: `Vous n'avez pas le droit d'exécuter cette commande !`, ephemeral: true })
}
interaction.reply({ content: 'Voulez-vous bannir ' + user.user.username + "#" + user.user.discriminator + ' ?', components: [row], ephemeral: true })
const filter = i => i.user.id === author.id;
data: new SlashCommandBuilder()
.setName("ban")
.setDescription("Bannir un membre (ADMIN).")
.addUserOption(option =>
option
.setName("utilisateur")
.setDescription("Le membre à bannir")
.setRequired(true)
)
.addStringOption(option =>
option
.setName("raison")
.setDescription("La raison pour laquelle bannir le membre")
.setRequired(true)
),
async execute(client, interaction) {
const author = interaction.member;
const user = interaction.options.getMember("utilisateur");
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId("oui")
.setLabel("Oui")
.setStyle("SUCCESS"),
new MessageButton().setCustomId("non").setLabel("Non").setStyle("DANGER")
);
if (
!isMod(client, interaction.member) &&
!isAdmin(client, interaction.member) &&
!interaction.member.permissions.has("BAN_MEMBERS")
) {
return interaction.reply({
content: "Vous n'avez pas le droit d'exécuter cette commande !",
ephemeral: true,
});
}
interaction.reply({
content:
"Voulez-vous bannir " +
user.user.username +
"#" +
user.user.discriminator +
" ?",
components: [row],
ephemeral: true,
});
const filter = i => i.user.id === author.id;

const collector = interaction.channel.createMessageComponentCollector({ filter, time: 15000 });
const collector = interaction.channel.createMessageComponentCollector({
filter,
time: 15000,
});

const reason = interaction.options.getString('raison');
const reason = interaction.options.getString("raison");

collector.on('collect', async i => {
if (i.customId === 'oui') {
await user.send('Vous avez été banni de ' + interaction.guild.name + ' pour :\n`' + reason + "`");
await user.ban({reason: reason})
collector.on("collect", async i => {
if (i.customId === "oui") {
await user.send(
"Vous avez été banni de " +
interaction.guild.name +
" pour :\n`" +
reason +
"`"
);
await user.ban({ reason: reason });

const embed = new MessageEmbed()
.setAuthor("Membre banni")
.setColor("#ff1500")
.setTimestamp(Date.now())
.setThumbnail(user.avatarURL({ dynamic: true }))
.addField("Utilisateur :", `${user.id}`, true)
.addField("Modérateur :", `<@${author.id}>`, true)
.addField("Raison :", reason, true)
const embed = new MessageEmbed()
.setAuthor("Membre banni")
.setColor("#ff1500")
.setTimestamp(Date.now())
.setThumbnail(user.avatarURL({ dynamic: true }))
.addField("Utilisateur :", `${user.id}`, true)
.addField("Modérateur :", `<@${author.id}>`, true)
.addField("Raison :", reason, true);

const channel = await interaction.guild.channels.fetch(client.config.logs.modChannelId)
await channel.send({ embeds: [embed] })
const channel = await interaction.guild.channels.fetch(
client.config.logs.modChannelId
);
await channel.send({ embeds: [embed] });

await i.update({ content: 'Vous avez banni ' + user.user.username + "#" + user.user.discriminator + ' avec succès !', components: [] });
}else{
await i.update({ content: 'Opération annulée !', components: [] });
}
});
},
await i.update({
content:
"Vous avez banni " +
user.user.username +
"#" +
user.user.discriminator +
" avec succès !",
components: [],
});
} else {
await i.update({ content: "Opération annulée !", components: [] });
}
});
},
};
37 changes: 23 additions & 14 deletions src/commands/initcount.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions } = require('discord.js')
const { SlashCommandBuilder } = require("@discordjs/builders");
const { Permissions } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName('initcount')
.setDescription('Initialiser le système de comptage (ADMIN).'),
async execute(client, interaction) {
const author = interaction.member;
if (!author.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
return interaction.reply({ content: `Vous n'avez pas le droit d'exécuter cette commande !`, ephemeral: true })
}
await client.countdb.set(`${interaction.guild.id}`, ({author: "null", currentNumber: 0}));
interaction.reply({ content: `Système de comptage initialisé !`, ephemeral: true })
},
};
data: new SlashCommandBuilder()
.setName("initcount")
.setDescription("Initialiser le système de comptage (ADMIN)."),
async execute(client, interaction) {
const author = interaction.member;
if (!author.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) {
return interaction.reply({
content: "Vous n'avez pas le droit d'exécuter cette commande !",
ephemeral: true,
});
}
await client.countdb.set(`${interaction.guild.id}`, {
author: "null",
currentNumber: 0,
});
interaction.reply({
content: "Système de comptage initialisé !",
ephemeral: true,
});
},
};
Loading

0 comments on commit cb65371

Please sign in to comment.