From 53ef2abab49df3ed4d89e71a06d211e00556d913 Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 13 Nov 2023 23:04:32 +0100 Subject: [PATCH 1/2] Temporarily removed the mute command --- commands-testing/mute.js | 161 --------------------------------------- 1 file changed, 161 deletions(-) delete mode 100644 commands-testing/mute.js diff --git a/commands-testing/mute.js b/commands-testing/mute.js deleted file mode 100644 index 908e312..0000000 --- a/commands-testing/mute.js +++ /dev/null @@ -1,161 +0,0 @@ -const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); -const dev = process.env.DEV; -const { color } = require('../config/options.json'); -const { admin, helper, muted } = require('../config/roles.json'); -const { staffOtherChannel } = require('../config/options.json'); - -module.exports = { - name: 'mute', - description: 'Mute a user', - type: 'slash', - - data: new SlashCommandBuilder() - .setName('mute') - .setDescription('Mute a user') - .addUserOption(option => - option - .setName('user') - .setDescription('The user to mute') - .setRequired(true)) - .addStringOption(option => - option - .setName('reason') - .setDescription('The reason for the mute')) - .addStringOption(option => - option - .setName('duration') - .setDescription('The duration of the mute')) - .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) - .setDMPermission(false), - - async execute(interaction) { - - const member1 = interaction.options.getUser('user'); - const member = interaction.guild.members.cache.get(member1.id); - const reason = interaction.options.getString('reason') ?? 'No reason provided'; - const duration = interaction.options.getString('duration'); - const guild = interaction.guild; - const embedColor = Number(color.replace('#', '0x')); - - const userRoles = await guild.members.fetch(interaction.user.id).then(member => member.roles.cache.map(role => role.id)); - const memberRoles = await guild.members.fetch(member1.id).then(member => member.roles.cache.map(role => role.id)); - - await interaction.deferReply({}); - - if (!userRoles.includes(admin || helper)) { - await interaction.editReply({ - embeds: [{ - description: "You don't have permission to use this command.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - }] - }); - return - } - - if (member.id === interaction.user.id) { - await interaction.editReply({ - embeds: [{ - description: "You can't mute yourself.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - }] - }); - return - } - - if (member.id === dev) { - await interaction.editReply({ - embeds: [{ - description: "You can't mute my developer.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - }] - }); - return - } - - // if (memberRoles.includes(admin) || memberRoles.includes(helper)) { - // await interaction.editReply({ - // embeds: [{ - // description: "You can't mute a staff member.", - // color: embedColor, - // footer: { - // text: interaction.guild.name + " | Developed by @Taken#0002", - // icon_url: interaction.guild.iconURL({ dynamic: true }) - // } - // }] - // }); - // return - // } - - if (!duration) { - await member.roles.add(muted, reason); - await interaction.editReply({ - embeds: [{ - description: "Successfully muted " + userMention(member1.id) + " forever.", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - }] - }) - return - } - - console.log(duration); - - const weeks = duration.replace(/[0-9][dhms]/g, '').replace(/w/g, '') - const days = duration.replace(/[0-9][whms]/g, '').replace(/d/g, '') - const hours = duration.replace(/[0-9][wdms]/g, '').replace(/h/g, '') - const minutes = duration.replace(/[0-9][wdhs]/g, '').replace(/m/g, '') - const seconds = duration.replace(/[0-9][wdhm]/g, '').replace(/s/g, '') - - const nweeks = Number(weeks) ?? 0; - const ndays = Number(days) ?? 0; - const nhours = Number(hours) ?? 0; - const nminutes = Number(minutes) ?? 0; - const nseconds = Number(seconds) ?? 0; - - const time = nweeks * 604800000 + ndays * 86400000 + nhours * 3600000 + nminutes * 60000 + nseconds * 1000; - const mutedTime = (nweeks > 0 ? nweeks + " week(s), " : "") + (ndays > 0 ? ndays + " day(s), " : "") + (nhours > 0 ? nhours + " hour(s), " : "") + (nminutes > 0 ? nminutes + " minute(s), " : "") + (nseconds > 0 ? nseconds + " second(s)" : ""); - - await member.roles.add(muted, reason); - await interaction.editReply({ - embeds: [{ - description: "Successfully muted " + userMention(member1.id) + " for " + mutedTime + ".", - color: embedColor, - footer: { - text: interaction.guild.name + " | Developed by @Taken#0002", - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - }] - }); - - const logChannel = interaction.guild.channels.cache.get(staffOtherChannel); - - setTimeout(async () => { - await member.roles.remove(muted, "Mute duration has ended."); - await logChannel.send({ - embeds: [{ - description: userMention(member1.id) + " has been unmuted.", - color: embedColor, - footer: { - text: "ID: " + member1.id, - icon_url: interaction.guild.iconURL({ dynamic: true }) - } - }] - }) - }, time); - } -}; From 5774c25d2c797d154906f99eb216b88df0342498 Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 14 Nov 2023 00:01:48 +0100 Subject: [PATCH 2/2] Added kick command --- commands/kick.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 commands/kick.js diff --git a/commands/kick.js b/commands/kick.js new file mode 100644 index 0000000..f47751c --- /dev/null +++ b/commands/kick.js @@ -0,0 +1,82 @@ +const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js') +const { admin, helper } = require('../config/roles.json') +const { color } = require('../config/options.json') + +module.exports = { + name: 'kick', + description: 'Kick a member from the server.', + type: 'slash', + + data: new SlashCommandBuilder() + .setName('kick') + .setDescription('Kick a member from the server.') + .addUserOption(option => + option + .setName('member') + .setDescription('Member to kick.') + .setRequired(true)) + .addStringOption(option => + option + .setName('reason') + .setDescription('Reason for kicking the member.')) + .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers) + .setDMPermission(false), + + async execute(interaction) { + + await interaction.deferReply() + + const member = interaction.options.getMember('member') + const reason = interaction.options.getString('reason') ?? "No reason provided." + const mod = await interaction.guild.members.fetch(interaction.user.id) + const memberRoles = member.roles.cache.map(role => role.id) + const modRoles = mod.roles.cache.map(role => role.id) + const embedColor = Number(color.replace('#', '0x')) + + if (!modRoles.includes(helper) && !modRoles.includes(admin)) { + await interaction.editReply("You do not have permission to use this command.") + return + } + + if (member.id === interaction.applicationId) { + await interaction.editReply("I cannot kick myself.") + return + } + + if (member.id === interaction.guild.ownerId) { + await interaction.editReply("I cannot kick the server owner.") + return + } + + if (member.id === mod.id) { + return interaction.editReply("You cannot kick yourself.") + } + + if (memberRoles.includes(helper) || memberRoles.includes(admin)) { + await interaction.editReply("I cannot kick a moderator.") + return + } + + if (!member.kickable) { + await interaction.editReply("I cannot kick this member.") + return + } + + await member.kick(reason + ` - ${mod.user.username}`) + + await interaction.editReply({ + embeds: [{ + title: "Member Kicked", + description: "**User:** " + userMention(member.user.id) + "\n" + + "**Reason:** " + reason + "\n" + + "**Moderator:** " + mod.user.username, + color: embedColor, + footer: { + text: member.user.id, + icon_url: member.user.avatarURL({ dynamic: true }) + }, + }] + }) + + } +}