diff --git a/src/commands/ban.ts b/src/commands/ban.ts index 8f34f39..f3749cc 100644 --- a/src/commands/ban.ts +++ b/src/commands/ban.ts @@ -5,8 +5,9 @@ import { GuildMember, } from "discord.js" import { admin, helper } from "../../config/roles.json" -import { color } from "../../config/options.json" +import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" +import logToChannel from "../utils/functions/logtochannel" export = { name: "ban", @@ -110,31 +111,52 @@ export = { deleteMessageDays: messageDeletionDays, }) + await logToChannel("mod", { + embeds: [{ + author: { + name: mod.user.username, + icon_url: mod.user.avatarURL({ forceStatic: false })!, + }, + title: "Member Banned", + description: ` + **User:** ${userMention(member.user.id)} + **Mod:** ${userMention(mod.user.id)} + **Reason:** ${reason} + **Messages Deleted:** ${messageDeletionDays} days + `, + color: embedColor, + thumbnail: { + url: mod.user.avatarURL({ forceStatic: false })!, + }, + footer: { + text: "ID: " + member.user.id, + icon_url: + member.user.avatarURL({ forceStatic: false }) || + undefined, + }, + timestamp: new Date().toISOString(), + }] + }) + await interaction.editReply({ embeds: [ { title: "Member Banned", description: - "**User:** " + - userMention(member.user.id) + - "\n" + - "**Reason:** " + - reason + - "\n" + - "**Moderator:** " + - mod.user.username + - "\n" + - "**Messages Deleted:** " + - messageDeletionDays + - " days", + "**User:** " + userMention(member.user.id) + "\n" + + "**Reason:** " + reason + "\n" + + "**Moderator:** " + mod.user.username + "\n" + + "**Messages Deleted:** " + messageDeletionDays + " days", color: embedColor, - footer: { - text: "ID: " + member.user.id, - icon_url: - member.user.avatarURL({ forceStatic: false }) || - undefined, + thumbnail: { + url: member.user.avatarURL({ forceStatic: false }) || interaction.guild!.iconURL({ forceStatic: false })!, + }, + footer: { + icon_url: interaction.guild!.iconURL({ + forceStatic: false, + })!, + text: interaction.guild!.name + " | " + devMessage, }, - timestamp: new Date().toISOString(), }, ], }) diff --git a/src/commands/clear.ts b/src/commands/clear.ts index db92a92..83124f5 100644 --- a/src/commands/clear.ts +++ b/src/commands/clear.ts @@ -2,9 +2,12 @@ import { SlashCommandBuilder, PermissionFlagsBits, TextChannel, + channelMention, + userMention, } from "discord.js" import { color } from "../../config/options.json" import { Command } from "../interfaces" +import logToChannel from "../utils/functions/logtochannel" export = { name: "clear", @@ -32,12 +35,12 @@ export = { const channel = interaction.channel as TextChannel const embedColor = Number(color.replace("#", "0x")) - if (!amount || amount < 1 || amount > 100) { + if (amount < 1 || amount > 100) { await interaction.editReply({ embeds: [ { description: - "Please provide an amount of messages to clear", + "Please provide an amount of messages to clear between 1 and 100.", color: embedColor, }, ], @@ -56,6 +59,30 @@ export = { await channel.bulkDelete(messagesToDelete, true) + await logToChannel("mod", { + embeds: [{ + author: { + name: interaction.user.username, + icon_url: interaction.user.avatarURL({ forceStatic: false }) || undefined, + }, + title: "Messages Cleared", + description: ` + **Channel:** ${channelMention(channel.id)} + **Amount:** \`${messages.size}\` messages + **Mod:** ${userMention(interaction.user.id)} + `, + color: embedColor, + thumbnail: { + url: interaction.guild!.iconURL({ forceStatic: false }) || "", + }, + footer: { + text: "ID: " + channel.id, + icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined, + }, + timestamp: new Date().toISOString() + }] + }) + await interaction.editReply({ embeds: [ { diff --git a/src/commands/forceunverify.ts b/src/commands/forceunverify.ts index f8d85cb..0675e15 100644 --- a/src/commands/forceunverify.ts +++ b/src/commands/forceunverify.ts @@ -8,6 +8,8 @@ import { color, devMessage } from "../../config/options.json" import verify = require("../schemas/verifySchema") import { Command } from "../interfaces" import roleManage from "../utils/functions/rolesmanage" +import logToChannel from "../utils/functions/logtochannel" +import { getIGN } from "../utils/Hypixel" export = { name: "forceunverify", @@ -32,6 +34,7 @@ export = { const member = interaction.options.getMember("user") as GuildMember const embedColor = Number(color.replace("#", "0x")) const verifiedUser = await verify.findOne({ userID: member.user.id }) + const mod = interaction.user if (!verifiedUser) { return interaction.reply({ @@ -43,10 +46,38 @@ export = { ], }) } - await verify.findOneAndDelete({ userID: member.user.id }) + const uuid = verifiedUser.uuid + const ign = await getIGN(uuid) + await verify.findOneAndDelete({ userID: member.user.id }) await member.roles.remove(roleManage("all").rolesToRemove, "User force unverified by " + interaction.user.username) + + await logToChannel("mod", { + embeds: [{ + title: "Force Unverified", + author: { + name: mod.username, + icon_url: mod.avatarURL({ forceStatic: false })!, + }, + description: ` + **User:** ${userMention(member.user.id)} + **Mod:** ${userMention(mod.id)} + **IGN:** \`${ign}\` + **UUID:** \`${uuid}\` + `, + color: embedColor, + thumbnail: { + url: mod.avatarURL({ forceStatic: false })!, + }, + footer: { + icon_url: member.user.avatarURL({ forceStatic: false }) || undefined, + text: "ID: " + member.user.id, + }, + timestamp: new Date().toISOString(), + }] + }) + await interaction.reply({ embeds: [ { diff --git a/src/commands/forceverify.ts b/src/commands/forceverify.ts index e68c6c1..bcf56f8 100644 --- a/src/commands/forceverify.ts +++ b/src/commands/forceverify.ts @@ -2,6 +2,7 @@ import { SlashCommandBuilder, PermissionFlagsBits, GuildMember, + userMention, } from "discord.js" import { getUUID, getPlayer, getGuild, getHeadURL } from "../utils/Hypixel" import { color, hypixelGuildID, devMessage } from "../../config/options.json" @@ -9,6 +10,7 @@ import verify = require("../schemas/verifySchema") import mongoose from "mongoose" import roleManage from "../utils/functions/rolesmanage" import { Command } from "../interfaces" +import logToChannel from "../utils/functions/logtochannel" export = { name: "forceverify", @@ -180,6 +182,31 @@ export = { await newVerify.save() + await logToChannel("mod", { + embeds: [{ + author: { + name: modName, + icon_url: mod.avatarURL({ forceStatic: false })!, + }, + title: "Force Verified", + description: ` + **User:** ${userMention(user.id)} + **Mod:** ${userMention(mod.id)} + **IGN:** \`${player.displayname}\` + **UUID:** \`${uuid}\` + `, + color: embedColor, + thumbnail: { + url: mod.avatarURL({ forceStatic: false })!, + }, + footer: { + icon_url: user.user.avatarURL({ forceStatic: false }) || undefined, + text: "ID: " + user.user.id + }, + timestamp: new Date().toISOString(), + }] + }) + await interaction.editReply({ embeds: [ { diff --git a/src/commands/kick.ts b/src/commands/kick.ts index b0bddd6..384ddbe 100644 --- a/src/commands/kick.ts +++ b/src/commands/kick.ts @@ -5,8 +5,9 @@ import { GuildMember, } from "discord.js" import { admin, helper } from "../../config/roles.json" -import { color } from "../../config/options.json" +import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" +import logToChannel from "../utils/functions/logtochannel" export = { name: "kick", @@ -35,18 +36,10 @@ export = { async execute(interaction) { await interaction.deferReply() - const member = interaction.options.getMember( - "member", - ) as GuildMember | null - const reason = - interaction.options.getString("reason") ?? "No reason provided." + const member = interaction.options.getMember( "member",) as GuildMember + const reason = interaction.options.getString("reason") ?? "No reason provided." const embedColor = Number(color.replace("#", "0x")) - if (!member) { - await interaction.editReply("You must specify a member.") - return - } - 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) @@ -85,27 +78,45 @@ export = { await member.kick(reason + ` - ${mod.user.username}`) + await logToChannel("mod", { + embeds: [{ + author: { + name: mod.user.username, + icon_url: mod.user.avatarURL({ forceStatic: false })!, + }, + title: "Member Kicked", + description: ` + **User:** ${userMention(member.user.id)} + **Mod:** ${userMention(mod.user.id)} + **Reason:** ${reason} + `, + color: embedColor, + thumbnail: { + url: mod.user.avatarURL({ forceStatic: false })!, + }, + footer: { + text: "ID: " + member.user.id, + icon_url: member.user.avatarURL({ forceStatic: false }) || undefined, + }, + timestamp: new Date().toISOString(), + }] + }) + await interaction.editReply({ embeds: [ { title: "Member Kicked", - description: - "**User:** " + - userMention(member.user.id) + - "\n" + - "**Reason:** " + - reason + - "\n" + - "**Moderator:** " + - mod.user.username, + description: "**User:** " + userMention(member.user.id) + "\n" + + "**Reason:** " + reason + "\n" + + "**Moderator:** " + mod.user.username, color: embedColor, - footer: { - text: "ID: " + member.user.id, - icon_url: - member.user.avatarURL({ forceStatic: false }) || - undefined, + thumbnail: { + url: member.user.avatarURL({ forceStatic: false }) || interaction.guild!.iconURL({ forceStatic: false, })!, }, - timestamp: new Date().toISOString(), + footer: { + icon_url: interaction.guild!.iconURL({ forceStatic: false, })!, + text: interaction.guild!.name + " | " + devMessage, + } }, ], }) diff --git a/src/commands/slowmode.ts b/src/commands/slowmode.ts index 9b2a639..75b6976 100644 --- a/src/commands/slowmode.ts +++ b/src/commands/slowmode.ts @@ -3,9 +3,12 @@ import { PermissionFlagsBits, ChannelType, TextChannel, + channelMention, + userMention, } from "discord.js" import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" +import logToChannel from "../utils/functions/logtochannel" export = { name: "slowmode", @@ -60,6 +63,30 @@ export = { return } + await logToChannel("mod", { + embeds: [{ + author: { + name: interaction.user.username, + icon_url: interaction.user.avatarURL({ forceStatic: false }) || undefined, + }, + title: "Slowmode Update", + description: ` + **Channel:** ${channelMention(channel.id)} + **Slowmode:** ${seconds} seconds + **Mod:** ${userMention(interaction.user.id)} + `, + color: embedColor, + thumbnail: { + url: interaction.user.avatarURL({ forceStatic: false }) || "", + }, + footer: { + icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined, + text: " ID: " + channel.id + }, + timestamp: new Date().toISOString() + }] + }) + await interaction.editReply({ embeds: [ { diff --git a/src/commands/timeout.ts b/src/commands/timeout.ts index aaf6b6e..ac0109b 100644 --- a/src/commands/timeout.ts +++ b/src/commands/timeout.ts @@ -5,9 +5,10 @@ import { ChatInputCommandInteraction, GuildMember, } from "discord.js" -import { color } from "../../config/options.json" +import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" import ms from "ms" +import logToChannel from "../utils/functions/logtochannel" const command: Command = { name: "timeout", @@ -164,22 +165,44 @@ const command: Command = { } await target.timeout(time, reason) + + await logToChannel("mod", { + embeds: [{ + author: { + name: mod.user.username, + icon_url: mod.user.avatarURL({ forceStatic: false }) || undefined, + }, + title: "Member Timed Out", + description: ` + **User:** ${userMention(target.id)} + **Time:** ${prettyTime} + **Reason:** ${reason} + **Mod:** ${userMention(mod.id)} + `, + color: embedColor, + thumbnail: { + url: mod.user.avatarURL({ forceStatic: false }) || "", + }, + footer: { + text: "ID: " + target.id, + icon_url: target.user.avatarURL({ forceStatic: false }) || undefined, + }, + timestamp: new Date().toISOString() + }] + }) + await interaction.editReply({ embeds: [ { description: - "Timed out " + - userMention(target.id) + - " for " + - prettyTime + - " for " + - reason, + "Timed out " + userMention(target.id) + + " for " + prettyTime + + " for " + reason, color: embedColor, footer: { - text: "ID: " + target.id, - icon_url: target.avatarURL() || undefined, + text: interaction.guild!.name + " | " + devMessage, + icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined, }, - timestamp: new Date().toISOString(), }, ], }) diff --git a/src/commands/unban.ts b/src/commands/unban.ts index 78e33b5..1f1992e 100644 --- a/src/commands/unban.ts +++ b/src/commands/unban.ts @@ -4,8 +4,9 @@ import { userMention, User, } from "discord.js" -import { color } from "../../config/options.json" +import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" +import logToChannel from "../utils/functions/logtochannel" export = { name: "unban", @@ -37,11 +38,10 @@ export = { await interaction.deferReply() const userid = interaction.options.getString("user")! - const reason = - interaction.options.getString("reason") || "No reason provided" + const reason = interaction.options.getString("reason") || "No reason provided" const mod = interaction.user const embedColor = Number(color.replace("#", "0x")) - let user: User | null + let user: User if (userid === "none") { await interaction.editReply({ @@ -66,34 +66,55 @@ export = { }, ], }) + return } - await interaction.guild!.members.unban(user!.id, reason) + await interaction.guild!.members.unban(user.id, reason) + + await logToChannel("mod", { + embeds: [ + { + author: { + name: mod.username, + icon_url: mod.avatarURL({ forceStatic: false })!, + }, + title: "Member Unbanned", + description: ` + **User:** ${userMention(user!.id)} + **Mod:** ${userMention(mod.id)} + **Reason:** ${reason} + `, + color: embedColor, + thumbnail: { + url: mod.avatarURL({ forceStatic: false })!, + }, + footer: { + text: "ID: " + user!.id, + icon_url: user.avatarURL({ forceStatic: false}) || undefined, + }, + timestamp: new Date().toISOString(), + }, + ], + }) await interaction.editReply({ embeds: [ { title: "User unbanned", description: - "The user " + - user!.username + - " has been unbanned.\n" + - "**Reason:** `" + - reason + - "`\n" + - "**Moderator:** " + - userMention(mod.id), + "The user " + user!.username + " has been unbanned.\n" + + "**Reason:** `" + reason + "`\n" + + "**Moderator:** " + userMention(mod.id), color: embedColor, thumbnail: { url: user!.avatarURL({ forceStatic: false }) || "", }, footer: { - text: "ID: " + user!.id, icon_url: interaction.guild!.iconURL({ forceStatic: false, })!, + text: interaction.guild!.name + " | " + devMessage, }, - timestamp: new Date().toISOString(), }, ], })