diff --git a/commands/antiraid/bunker.js b/commands/antiraid/bunker.js new file mode 100644 index 0000000..bf665a2 --- /dev/null +++ b/commands/antiraid/bunker.js @@ -0,0 +1,30 @@ +module.exports = { + name: 'bunker', + description: 'Activer le bot bunker', + emote: '🛡️', + utilisation: 'bunker', + category: 'antiraid', + + async execute(message) { + const guild = message.guild; + const dangerousPermissions = [ + 'ADMINISTRATOR', 'VIEW_AUDIT_LOG', 'MANAGE_GUILD', 'MANAGE_ROLES', 'MANAGE_CHANNELS', 'KICK_MEMBERS', 'BAN_MEMBERS', + 'MANAGE_NICKNAMES', 'MANAGE_EMOJIS_AND_STICKERS', 'MANAGE_WEBHOOKS', 'MANAGE_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES', + 'SEND_TTS_MESSAGES', 'MENTION_EVERYONE', 'MUTE_MEMBERS', 'DEAFEN_MEMBERS', 'MOVE_MEMBERS', 'USE_VAD', 'PRIORITY_SPEAKER' + ]; + + // Kick all bots + await Promise.all(guild.members.cache.filter(member => member.user.bot).map(member => member.kick())); + + // Delete dangerous roles + await Promise.all(guild.roles.cache.filter(role => dangerousPermissions.some(permission => role.permissions.has(permission))).map(role => role.delete())); + + // Delete dangerous channel overrides + await Promise.all(guild.channels.cache.map(async (channel) => { + const permissionOverwrites = channel.permissionOverwrites.cache.filter(overwrite => dangerousPermissions.some(permission => overwrite.allow.has(permission) || overwrite.deny.has(permission))); + await Promise.all(permissionOverwrites.map(overwrite => channel.permissionOverwrites.edit(overwrite.id, {}))); + })); + + await message.reply('Le serveur a bien été sécurisé'); + }, +}; diff --git a/commands/botcontrol/invite.js b/commands/botcontrol/invite.js new file mode 100644 index 0000000..48a7e99 --- /dev/null +++ b/commands/botcontrol/invite.js @@ -0,0 +1,53 @@ +const { PermissionsBitField } = require('discord.js'); + +module.exports = { + name: 'invite', + aliases: ['inv'], + description: 'Crée un lien d\'invitation pour un serveur spécifique', + emote: '🔗', + utilisation: 'invite [guildId]', + category: 'botcontrol', + + async execute(message, args, client) { + // Vérifie si l'ID du serveur a été fourni + if (!args[0]) { + return message.reply('Veuillez fournir l\'ID du serveur.'); + } + + const guildId = args[0]; + let guild; + + // Tente de trouver le serveur par ID + try { + guild = await client.guilds.fetch(guildId); + } catch (error) { + console.error(error); + return message.reply('Je ne peux pas trouver le serveur avec cet ID.'); + } + + // Vérifie si le bot est membre du serveur + if (!guild) { + return message.reply('Le bot n\'est pas membre de ce serveur.'); + } + + const botMember = guild.members.cache.get(client.user.id); + + // Vérifie si le bot a la permission de créer des invitations + if (!botMember.permissions.has(PermissionsBitField.Flags.createInvite)) { + return message.reply('Le bot n\'a pas la permission de créer des invitations sur ce serveur.'); + } + + const channel = guild.channels.cache + .filter((channel) => channel.type === 'GUILD_TEXT') + .first(); + if (!channel) return message.channel.send(`Aucun channel textuel n'a été trouvé dans ce serveur.`); + + await channel + .createInvite({ + maxAge: 0, + maxUses: 0, + }).then(async (invite) => { + message.channel.send(`Invitation créée pour le serveur ${guild.name} : ${invite.url}`); + }) + }, +}; \ No newline at end of file diff --git a/commands/botcontrol/leave.js b/commands/botcontrol/leave.js new file mode 100644 index 0000000..63b5eb0 --- /dev/null +++ b/commands/botcontrol/leave.js @@ -0,0 +1,28 @@ +const fs = require('fs'); +const path = require('path'); + +module.exports = { + name: 'leave', + aliases: ['leaveguild'], + description: "Faire quitter le bot un serveur", + emote: '🚪', + utilisation: 'leave [guildId]', + category: 'botcontrol', + + async execute(message, args, client) { + + // If an ID is provided, try to get the guild with that ID + const guildId = args[0]; + if (guildId) { + const guild = client.guilds.cache.get(guildId); + if (guild) { + guild.leave(); + message.reply(`Je vien de quitté: ${guild.name}`); + } else { + message.reply('Je ne suis pas dans ce serveur.'); + } + } else { + message.guild.leave(); + } + }, +}; \ No newline at end of file diff --git a/commands/botcontrol/say.ts b/commands/botcontrol/say.ts new file mode 100644 index 0000000..4df7dd0 --- /dev/null +++ b/commands/botcontrol/say.ts @@ -0,0 +1,23 @@ +import { Message } from 'discord.js'; + +module.exports = { + aliases: ['dire'], + description: 'Fait dire quelque chose au bot', + emote: '💬', + utilisation: 'say ', + permission: '10', + + async execute(message: Message, args: string[]) { + if (args.length === 0) { + return message.reply('Veuillez spécifier un message.'); + } + + const text = args.join(' '); + try { + await message.delete(); + } catch { + console.log('Impossible de supprimer le message de la commande say'); + } + message.channel.send(text); + }, +}; \ No newline at end of file diff --git a/commands/botcontrol/servers.js b/commands/botcontrol/servers.js new file mode 100644 index 0000000..a370260 --- /dev/null +++ b/commands/botcontrol/servers.js @@ -0,0 +1,23 @@ +const { EmbedBuilder} = require('discord.js'); +const fs = require('fs'); +const path = require('path'); + +module.exports = { + name: 'servers', + aliases: ['serveurs'], + description: 'Liste les serveur du bot', + emote: '🌐', + utilisation: 'servers', + category: 'botcontrol', + async execute(message, args, client) { + + const guilds = Array.from(client.guilds.cache.values()).map((guild, index) => `${index + 1}. ${guild.name} : ${guild.id}`).join("\n\n"); + + const embed = new EmbedBuilder() + .setTitle('Liste des serveur du bot') + .setDescription(`\n${guilds}`) + .setColor('#0099ff'); + + message.channel.send({ embeds: [embed] }); + }, +}; \ No newline at end of file diff --git a/commands/botcontrol/set.js b/commands/botcontrol/set.js new file mode 100644 index 0000000..56f5e51 --- /dev/null +++ b/commands/botcontrol/set.js @@ -0,0 +1,48 @@ +module.exports = { + name: 'set', + aliases: ['changer'], + description: 'Modifier divers paramètres du bot.', + emote: '⚙️', + utilisation: 'set ', + category: 'botcontrol', + + async execute(message, args, client) { + if (args.length < 2) { + return message.reply('Veuillez fournir un paramètre parmis `name` ou `pic` pour sa valeur.'); + } + + const setting = args[0]; + + if (setting === 'name') { + const value = args.slice(1).join(' '); + if (value) { + try { + const botMember = await message.guild.members.fetch(client.user.id); + await botMember.setNickname(value); + return message.reply(`Mon nouveau pseudo est maintenant **${value}**.`); + } catch (error) { + console.error(error); + return message.reply('Une erreur est survenue lors de la tentative de changement de mon pseudo.'); + } + } else { + return message.reply('Veuillez fournir un nom valide.'); + } + } else if (setting === 'pic') { + const value = args[1]; + if (value && value.startsWith('http')) { + try { + await client.user.setAvatar(value); + return message.reply('Mon avatar a été mis à jour avec succès.'); + } catch (error) { + console.error(error); + return message.reply('Une erreur est survenue lors de la tentative de mise à jour de mon avatar.'); + } + } else { + return message.reply('Veuillez fournir un URL d\'image valide.'); + } + } else { + return message.reply('Paramètre invalide. Veuillez utiliser "name" ou "pic".'); + } + }, + }; + \ No newline at end of file diff --git a/commands/botcontrol/setactivity.ts b/commands/botcontrol/setactivity.ts new file mode 100644 index 0000000..6f8a80d --- /dev/null +++ b/commands/botcontrol/setactivity.ts @@ -0,0 +1,125 @@ +import { Message, Client, EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder, ActivityType, Activity } from "discord.js"; + +module.exports = { + description: 'Changer la présence du bot', + emote: '🎮', + utilisation: '', + permission: '8', + async execute(message: Message, args:string[], client: Client) { + if (!client.user) return + + const author = message.author; + + let currentActivitie = client.user.presence.activities[0]; + + const embed = new EmbedBuilder() + .setTitle('Changement d\'activité') + .setDescription(`Le bot est en mode :\`${currentActivitie}\``) + .setTimestamp() + .setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL()}); + + if (!currentActivitie) { + embed.setColor('#000000'); + } else if (currentActivitie.name === 'playing') { + embed.setColor('#FF0000'); + } else if (currentActivitie.name === 'streaming') { + embed.setColor('#FFA500'); + } else if (currentActivitie.name === 'listening') { + embed.setColor('#00FF00'); + } else if (currentActivitie.name === 'watching') { + embed.setColor('#000000'); + } + + const selectMenu = new StringSelectMenuBuilder() + .setCustomId('activity') + .setPlaceholder('Changer l\'activité') + .addOptions([ + { + label: 'Joue', + value: 'playing', + description: 'Le bot joue', + emoji: '🎮' + }, + { + label: 'Stream', + value: 'streaming', + description: 'Le bot stream', + emoji: '📺' + }, + { + label: 'Écoute', + value: 'listening', + description: 'Le bot écoute', + emoji: '🎵' + }, + { + label: 'Regarde', + value: 'watching', + description: 'Le bot regarde', + emoji: '👀' + } + ]); + + const row: any = new ActionRowBuilder() + .addComponents(selectMenu) + + const sendMessage = await message.reply({ embeds: [embed], components: [row] }); + + let filter = (interaction: any) => interaction.user.id === message.author.id; + const collector = sendMessage.createMessageComponentCollector({ filter, time: 60000 }); + collector.on('collect', async (interaction: any) => { + if (interaction.isStringSelectMenu()) { + const value = interaction.values[0]; + + interaction.reply(`Veuillez entrer le message que vous voulez afficher pour l'activité ${value}`); + filter = (message: Message) => message.author.id === author.id; + const messageCollector = message.channel.createMessageCollector({ filter, time: 60000 }); + messageCollector.on('collect', async (messageCollect: Message): Promise => { + const text = messageCollect.content; + const url = 'https://www.twitch.tv/tuturp33'; + + if (!client.user) return; + if (value === 'playing') { + client.user.setPresence({ + activities: [{ + name: text, + type: ActivityType.Playing, + url: url + }] + }); + } else if (value === 'streaming') { + client.user.setPresence({ + activities: [{ + name: text, + type: ActivityType.Streaming, + url: url + }] + }); + } else if (value === 'listening') { + client.user.setPresence({ + activities: [{ + name: text, + type: ActivityType.Listening, + url: url + }] + }); + } else if (value === 'watching') { + client.user.setPresence({ + activities: [{ + name: text, + type: ActivityType.Watching, + url: url + }] + }); + } else { + return; + } + }); + } + }); + + collector.on('end', async () => { + sendMessage.edit({ components: [] }); + }); + }, +}; \ No newline at end of file diff --git a/commands/botcontrol/setstatus.ts b/commands/botcontrol/setstatus.ts new file mode 100644 index 0000000..6f4611e --- /dev/null +++ b/commands/botcontrol/setstatus.ts @@ -0,0 +1,100 @@ +import { Message, Client, EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } from "discord.js"; + +module.exports = { + description: 'Changer le status du bot', + emote: '🟢', + utilisation: '', + permission: '8', + async execute(message: Message, args:string[], client: Client) { + if (!client.user) return + + let currentStatus = client.user.presence.status; + + const embed = new EmbedBuilder() + .setTitle('Changement de status') + .setDescription(`Le bot est en mode :\`${currentStatus}\``) + .setTimestamp() + .setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL()}); + + if (currentStatus === 'dnd') { + embed.setColor('#FF0000'); + } else if (currentStatus === 'idle') { + embed.setColor('#FFA500'); + } else if (currentStatus === 'online') { + embed.setColor('#00FF00'); + } else if (currentStatus === 'offline') { + embed.setColor('#000000'); + } else { + embed.setColor('#000000'); + } + + const selectMenu = new StringSelectMenuBuilder() + .setCustomId('status') + .setPlaceholder('Changer le status') + .addOptions([ + { + label: 'En ligne', + value: 'online', + description: 'Le bot sera en ligne', + emoji: '🟢' + }, + { + label: 'Absent', + value: 'idle', + description: 'Le bot sera absent', + emoji: '🟠' + }, + { + label: 'Ne pas déranger', + value: 'dnd', + description: 'Le bot ne sera pas déranger', + emoji: '🔴' + }, + { + label: 'Invisible', + value: 'offline', + description: 'Le bot sera invisible', + emoji: '⚫' + } + ]); + + const row: any = new ActionRowBuilder() + .addComponents(selectMenu) + + const sendMessage = await message.reply({ embeds: [embed], components: [row] }); + + const filter = (interaction: any) => interaction.user.id === message.author.id; + const collector = sendMessage.createMessageComponentCollector({ filter, time: 60000 }); + collector.on('collect', async (interaction: any) => { + if (interaction.isStringSelectMenu()) { + if (!client.user) return + const value = interaction.values[0]; + if (value === 'online') { + client.user.setStatus('online'); + embed.setDescription('Le bot est maintenant en ligne'); + embed.setColor('#00FF00'); + await interaction.update({ embeds: [embed], components: [row] }); + } else if (value === 'idle') { + client.user.setStatus('idle'); + embed.setDescription('Le bot est maintenant absent'); + embed.setColor('#FFA500'); + await interaction.update({ embeds: [embed], components: [row] }); + } else if (value === 'dnd') { + client.user.setStatus('dnd'); + embed.setDescription('Le bot est maintenant en mode ne pas déranger'); + embed.setColor('#FF0000'); + await interaction.update({ embeds: [embed], components: [row] }); + } else if (value === 'offline') { + client.user.setStatus('invisible'); + embed.setDescription('Le bot est maintenant invisible'); + embed.setColor('#000000'); + await interaction.update({ embeds: [embed], components: [row] }); + } + } + }); + + collector.on('end', async () => { + sendMessage.edit({ components: [] }); + }); + }, +}; \ No newline at end of file diff --git a/commands/setprefix.ts b/commands/setprefix.ts index ae4a28b..3e991f9 100644 --- a/commands/setprefix.ts +++ b/commands/setprefix.ts @@ -8,7 +8,6 @@ module.exports = { emote: '⏱️', utilisation: '', permission: 10, - category : 'admin', async execute(message: Message, args: string[]) { const prefix = await getServerPrefix(message.guild?.id);