Fixed more formatting

This commit is contained in:
2024-01-19 18:40:45 +01:00
parent 0a315b18ed
commit ee217d5f64
15 changed files with 349 additions and 633 deletions

View File

@@ -7,7 +7,7 @@ const config = {
semi: false, semi: false,
singleQuote: false, singleQuote: false,
quoteProps: "as-needed", quoteProps: "as-needed",
trailingComma: "all", trailingComma: "none",
bracketSpacing: true, bracketSpacing: true,
arrowParens: "avoid", arrowParens: "avoid",
parser: "typescript", parser: "typescript",

View File

@@ -1,9 +1,4 @@
import { import { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention } from "discord.js"
ContextMenuCommandBuilder,
ApplicationCommandType,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { ContextMenu } from "interfaces" import { ContextMenu } from "interfaces"
export = { export = {
@@ -23,25 +18,23 @@ export = {
if (!message) { if (!message) {
return interaction.reply({ return interaction.reply({
content: "That user does not exist.", content: "That user does not exist.",
ephemeral: true, ephemeral: true
}) })
} }
const target = message.author const target = message.author
await message.reply({ await message.reply({
embeds: [ embeds: [{
{ title: "Congratulations!",
title: "Congratulations!", description: `GG to ${userMention(target.id)}!`
description: `GG to ${userMention(target.id)}!`, }]
},
],
}) })
await message.react("🎉") await message.react("🎉")
await interaction.reply({ await interaction.reply({
content: "Sent a congrats message", content: "Sent a congrats message",
ephemeral: true, ephemeral: true
}) })
}, }
} as ContextMenu } as ContextMenu

View File

@@ -1,8 +1,4 @@
import { import { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } from "discord.js"
ContextMenuCommandBuilder,
ApplicationCommandType,
PermissionFlagsBits,
} from "discord.js"
import { ContextMenu } from "interfaces" import { ContextMenu } from "interfaces"
export = { export = {
@@ -22,7 +18,7 @@ export = {
if (!target) { if (!target) {
interaction.reply({ interaction.reply({
content: "That user does not exist.", content: "That user does not exist.",
ephemeral: true, ephemeral: true
}) })
return return
} }
@@ -30,7 +26,7 @@ export = {
if (target.id === interaction.user.id) { if (target.id === interaction.user.id) {
interaction.reply({ interaction.reply({
content: "You can't reset your own nickname.", content: "You can't reset your own nickname.",
ephemeral: true, ephemeral: true
}) })
return return
} }
@@ -38,21 +34,18 @@ export = {
if (!target.manageable) { if (!target.manageable) {
interaction.reply({ interaction.reply({
content: "I cannot reset that user's nickname.", content: "I cannot reset that user's nickname.",
ephemeral: true, ephemeral: true
}) })
return return
} }
await target.setNickname( await target.setNickname(
target.user.username, target.user.username,
"Reset by " + "Reset by " + interaction.user.username + "#" + interaction.user.discriminator
interaction.user.username +
"#" +
interaction.user.discriminator,
) )
interaction.reply({ interaction.reply({
content: `Reset ${target.user.username}'s nickname.`, content: `Reset ${target.user.username}'s nickname.`,
ephemeral: true, ephemeral: true
}) })
}, }
} as ContextMenu } as ContextMenu

View File

@@ -1,9 +1,4 @@
import { import { ApplicationCommandType, ContextMenuCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
ApplicationCommandType,
ContextMenuCommandBuilder,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { color, devMessage, hypixelGuildID } from "config/options.json" import { color, devMessage, hypixelGuildID } from "config/options.json"
import { ContextMenu } from "interfaces" import { ContextMenu } from "interfaces"
import verifySchema from "schemas/verifySchema" import verifySchema from "schemas/verifySchema"
@@ -32,39 +27,33 @@ export = {
if (!verifyData) { if (!verifyData) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "User is not verified.",
description: "User is not verified.", color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching ign...",
description: "Fetching ign...", color: embedColor
color: embedColor, }]
},
],
}) })
const ign = (await getIGN(verifyData.uuid)) as string const ign = (await getIGN(verifyData.uuid)) as string
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching guild data...",
description: "Fetching guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = await getGuild(verifyData.uuid) const guild = await getGuild(verifyData.uuid)
@@ -78,141 +67,87 @@ export = {
if (responseGuildID !== hypixelGuildID) { if (responseGuildID !== hypixelGuildID) {
const roles = roleManage("default") const roles = roleManage("default")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove,
"User was force updated.",
)
await user.roles.add(roles.rolesToAdd, "User was force updated.") await user.roles.add(roles.rolesToAdd, "User was force updated.")
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: usermentioned + " was given the the Default Member role.",
description: color: embedColor,
usermentioned + thumbnail: {
" was given the the Default Member role.", url: head!
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
return return
} }
if (responseGuildID === hypixelGuildID) { if (responseGuildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find( const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid)!.rank
member => member.uuid === verifyData.uuid,
)!.rank
let replyRank: string | null = null let replyRank: string | null = null
await user.roles.add( await user.roles.add(roleManage("default").rolesToAdd, "User was force updated.")
roleManage("default").rolesToAdd,
"User was force updated.",
)
if (guildRank === "Guild Master") { if (guildRank === "Guild Master") {
const roles = roleManage("gm") const roles = roleManage("gm")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Guild Master" replyRank = "Guild Master"
} }
if (guildRank === "Manager") { if (guildRank === "Manager") {
const roles = roleManage("manager") const roles = roleManage("manager")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Manager" replyRank = "Manager"
} }
if (guildRank === "Moderator") { if (guildRank === "Moderator") {
const roles = roleManage("moderator") const roles = roleManage("moderator")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Moderator" replyRank = "Moderator"
} }
if (guildRank === "Beast") { if (guildRank === "Beast") {
const roles = roleManage("beast") const roles = roleManage("beast")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Beast" replyRank = "Beast"
} }
if (guildRank === "Elite") { if (guildRank === "Elite") {
const roles = roleManage("elite") const roles = roleManage("elite")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Elite" replyRank = "Elite"
} }
if (guildRank === "Member") { if (guildRank === "Member") {
const roles = roleManage("member") const roles = roleManage("member")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Member" replyRank = "Member"
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: usermentioned + " was given the " + replyRank + " role.",
description: color: embedColor,
usermentioned + thumbnail: {
" was given the " + url: head!
replyRank +
" role.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
} }
}, }
} as ContextMenu } as ContextMenu

View File

@@ -1,10 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, TextChannel, channelMention, userMention } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
TextChannel,
channelMention,
userMention,
} from "discord.js"
import { color } from "config/options.json" import { color } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
import logToChannel from "utils/functions/logtochannel" import logToChannel from "utils/functions/logtochannel"
@@ -22,7 +16,7 @@ export = {
option option
.setName("amount") .setName("amount")
.setDescription("Amount of messages to clear") .setDescription("Amount of messages to clear")
.setRequired(true), .setRequired(true)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -36,62 +30,52 @@ export = {
if (amount < 1 || amount > 100) { if (amount < 1 || amount > 100) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Please provide an amount of messages to clear between 1 and 100.",
description: color: embedColor
"Please provide an amount of messages to clear between 1 and 100.", }]
color: embedColor,
},
],
}) })
} }
channel.messages.fetch({ limit: amount }).then(async messages => { channel.messages.fetch({ limit: amount }).then(async messages => {
const messagesToDelete = messages const messagesToDelete = messages.map(m => m).filter(m =>
.map(m => m) m.pinned === false &&
.filter( m.system === false &&
m => m.createdTimestamp > Date.now() - 1209600000
m.pinned === false && )
m.system === false &&
m.createdTimestamp > Date.now() - 1209600000,
)
await channel.bulkDelete(messagesToDelete, true) await channel.bulkDelete(messagesToDelete, true)
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: interaction.user.username,
name: interaction.user.username, icon_url: interaction.user.avatarURL() || undefined
icon_url: interaction.user.avatarURL() || undefined, },
}, title: "Messages Cleared",
title: "Messages Cleared", description: `
description: `
**Channel:** ${channelMention(channel.id)} **Channel:** ${channelMention(channel.id)}
**Amount:** \`${messages.size}\` messages **Amount:** \`${messages.size}\` messages
**Mod:** ${userMention(interaction.user.id)} **Mod:** ${userMention(interaction.user.id)}
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: interaction.user.avatarURL() || "", url: interaction.user.avatarURL() || ""
},
footer: {
text: "ID: " + channel.id,
icon_url: interaction.guild!.iconURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
text: "ID: " + channel.id,
icon_url: interaction.guild!.iconURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: `Deleted ${messages.size} messages`,
description: `Deleted ${messages.size} messages`, color: embedColor
color: embedColor, }]
},
],
}) })
}) })
}, }
} as Command } as Command

View File

@@ -19,15 +19,15 @@ export = {
.setDescription("The setting to configure") .setDescription("The setting to configure")
.setChoices({ .setChoices({
name: "Staff Application status", name: "Staff Application status",
value: "staffAppStatus", value: "staffAppStatus"
}) })
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option option
.setName("value") .setName("value")
.setDescription("The value to set") .setDescription("The value to set")
.setRequired(true), .setRequired(true)
) )
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator), .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
@@ -44,39 +44,25 @@ export = {
const newSetting = new settings({ const newSetting = new settings({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
name: setting, name: setting,
value: value, value: value
}) })
await newSetting.save() await newSetting.save()
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Successfully created `" + setting + "` with value `" + value + "`.",
description: color: embedColor
"Successfully created `" + }]
setting +
"` with value `" +
value +
"`.",
color: embedColor,
},
],
}) })
} else { } else {
await settings.findOneAndUpdate({ name: setting }, { value: value }) await settings.findOneAndUpdate({ name: setting }, { value: value })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Successfully updated `" + setting + "` to value `" + value + "`."
description: }]
"Successfully updated `" +
setting +
"` to value `" +
value +
"`.",
},
],
}) })
} }
}, }
} as Command } as Command

View File

@@ -1,8 +1,4 @@
import { import { ChannelType, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"
ChannelType,
PermissionFlagsBits,
SlashCommandBuilder,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
import setup from "./counting/setup" import setup from "./counting/setup"
@@ -28,11 +24,8 @@ export = {
.setName("channel") .setName("channel")
.setDescription("The channel to setup counting in") .setDescription("The channel to setup counting in")
.setRequired(true) .setRequired(true)
.addChannelTypes( .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
ChannelType.GuildText, )
ChannelType.GuildAnnouncement,
),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -42,8 +35,8 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to ban") .setDescription("The user to ban")
.setRequired(true), .setRequired(true)
), )
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -53,8 +46,8 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to ban") .setDescription("The user to ban")
.setRequired(true), .setRequired(true)
), )
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -79,16 +72,14 @@ export = {
} }
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "This command is currently under development",
description: "This command is currently under development", color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
}, }
} as Command } as Command

View File

@@ -1,48 +1,34 @@
import { import { ChatInputCommandInteraction, GuildMember, userMention } from "discord.js"
ChatInputCommandInteraction,
GuildMember,
userMention,
} from "discord.js"
import { countingBanned } from "config/roles.json" import { countingBanned } from "config/roles.json"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
export default async function ban( export default async function ban(interaction: ChatInputCommandInteraction): Promise<void> {
interaction: ChatInputCommandInteraction,
): Promise<void> {
const member = interaction.options.getMember("user")! as GuildMember const member = interaction.options.getMember("user")! as GuildMember
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (member.roles.cache.has(countingBanned)) { if (member.roles.cache.has(countingBanned)) {
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: userMention(member.user.id) + " is currently banned from counting",
description: color: embedColor,
userMention(member.user.id) + footer: {
" is currently banned from counting", icon_url: interaction.guild!.iconURL() || undefined,
color: embedColor, text: interaction.guild!.name + " | " + devMessage
footer: { }
icon_url: interaction.guild!.iconURL() || undefined, }]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
}) })
} else { } else {
await member.roles.add(countingBanned) await member.roles.add(countingBanned)
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: userMention(member.user.id) + " has been banned from counting",
description: color: embedColor,
userMention(member.user.id) + footer: {
" has been banned from counting", icon_url: interaction.guild!.iconURL() || undefined,
color: embedColor, text: interaction.guild!.name + " | " + devMessage
footer: { }
icon_url: interaction.guild!.iconURL() || undefined, }]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
}) })
} }
} }

View File

@@ -1,15 +1,9 @@
import { import { ChatInputCommandInteraction, TextChannel, channelMention } from "discord.js"
ChatInputCommandInteraction,
TextChannel,
channelMention,
} from "discord.js"
import settingsSchema from "schemas/settingsSchema" import settingsSchema from "schemas/settingsSchema"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import mongoose from "mongoose" import mongoose from "mongoose"
export default async function setup( export default async function setup(interaction: ChatInputCommandInteraction): Promise<void> {
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply() await interaction.deferReply()
const channel = interaction.options.getChannel("channel") as TextChannel const channel = interaction.options.getChannel("channel") as TextChannel
@@ -18,44 +12,36 @@ export default async function setup(
if (await settingsSchema.findOne({ name: "counting" })) { if (await settingsSchema.findOne({ name: "counting" })) {
await settingsSchema.findOneAndUpdate( await settingsSchema.findOneAndUpdate(
{ name: "counting" }, { name: "counting" },
{ name: "counting", channel: channel.id }, { name: "counting", channel: channel.id }
) )
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Counting channel has been updated to " + channelMention(channel.id),
description: color: embedColor,
"Counting channel has been updated to " + footer: {
channelMention(channel.id), icon_url: interaction.guild!.iconURL() || undefined,
color: embedColor, text: interaction.guild!.name + " | " + devMessage
footer: { }
icon_url: interaction.guild!.iconURL() || undefined, }]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
}) })
} else { } else {
const counting = new settingsSchema({ const counting = new settingsSchema({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
name: "counting", name: "counting",
value: channel.id, value: channel.id
}) })
await counting.save() await counting.save()
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Counting channel has been set to " + channelMention(channel.id),
description: color: embedColor,
"Counting channel has been set to " + footer: {
channelMention(channel.id), icon_url: interaction.guild!.iconURL() || undefined,
color: embedColor, text: interaction.guild!.name + " | " + devMessage
footer: { }
icon_url: interaction.guild!.iconURL() || undefined, }]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
}) })
} }
} }

View File

@@ -1,48 +1,34 @@
import { import { ChatInputCommandInteraction, GuildMember, userMention } from "discord.js"
ChatInputCommandInteraction,
GuildMember,
userMention,
} from "discord.js"
import { countingBanned } from "config/roles.json" import { countingBanned } from "config/roles.json"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
export default async function ban( export default async function ban(interaction: ChatInputCommandInteraction): Promise<void> {
interaction: ChatInputCommandInteraction,
): Promise<void> {
const member = interaction.options.getMember("user")! as GuildMember const member = interaction.options.getMember("user")! as GuildMember
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!member.roles.cache.has(countingBanned)) { if (!member.roles.cache.has(countingBanned)) {
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: userMention(member.user.id) + " is currently not banned from counting",
description: color: embedColor,
userMention(member.user.id) + footer: {
" is currently not banned from counting", icon_url: interaction.guild!.iconURL() || undefined,
color: embedColor, text: interaction.guild!.name + " | " + devMessage
footer: { }
icon_url: interaction.guild!.iconURL() || undefined, }]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
}) })
} else { } else {
await member.roles.remove(countingBanned) await member.roles.remove(countingBanned)
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: userMention(member.user.id) + " has been unbanned from counting",
description: color: embedColor,
userMention(member.user.id) + footer: {
" has been unbanned from counting", icon_url: interaction.guild!.iconURL() || undefined,
color: embedColor, text: interaction.guild!.name + " | " + devMessage
footer: { }
icon_url: interaction.guild!.iconURL() || undefined, }]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
}) })
} }
} }

View File

@@ -1,8 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
ChatInputCommandInteraction,
} from "discord.js"
import { Command } from "interfaces" import { Command } from "interfaces"
export = { export = {
@@ -15,12 +11,14 @@ export = {
.setName("dev-info") .setName("dev-info")
.setDescription("Test command for the bot.") .setDescription("Test command for the bot.")
.addStringOption(option => .addStringOption(option =>
option.setName("test").setDescription("Test option."), option
.setName("test")
.setDescription("Test option.")
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction: ChatInputCommandInteraction) { async execute(interaction) {
const test = interaction.options.getString("test")! const test = interaction.options.getString("test")!
const message = await interaction.channel!.messages.fetch(test) const message = await interaction.channel!.messages.fetch(test)
@@ -31,5 +29,5 @@ export = {
console.log(field1.value) console.log(field1.value)
await interaction.reply({ content: "Test command.", ephemeral: true }) await interaction.reply({ content: "Test command.", ephemeral: true })
}, }
} as Command } as Command

View File

@@ -11,7 +11,9 @@ export = {
.setName("devel") .setName("devel")
.setDescription("Admin command.") .setDescription("Admin command.")
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand.setName("reload").setDescription("Reload the bot."), subcommand
.setName("reload")
.setDescription("Reload the bot.")
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -23,17 +25,17 @@ export = {
const { exec } = require("child_process") const { exec } = require("child_process")
await interaction.reply({ await interaction.reply({
content: "Reloading...", content: "Reloading...",
ephemeral: true, ephemeral: true
}) })
exec("pm2 restart 0", async (err: Error) => { exec("pm2 restart 0", async (err: Error) => {
if (err) { if (err) {
await interaction.reply({ await interaction.reply({
content: "Error while reloading: " + err, content: "Error while reloading: " + err,
ephemeral: true, ephemeral: true
}) })
} }
}) })
} }
}, }
} as Command } as Command

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import verify from "schemas/verifySchema" import verify from "schemas/verifySchema"
import { Command } from "interfaces" import { Command } from "interfaces"
@@ -24,7 +19,7 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to force unverify") .setDescription("The user to force unverify")
.setRequired(true), .setRequired(true)
) )
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator), .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
@@ -37,12 +32,10 @@ export = {
if (!verifiedUser) { if (!verifiedUser) {
return interaction.reply({ return interaction.reply({
embeds: [ embeds: [{
{ description: "This user is not verified",
description: "This user is not verified", color: embedColor
color: embedColor, }]
},
],
}) })
} }
@@ -51,49 +44,43 @@ export = {
await verify.findOneAndDelete({ userID: member.user.id }) await verify.findOneAndDelete({ userID: member.user.id })
await member.roles.remove( await member.roles.remove(
roleManage("all").rolesToRemove, roleManage("all").rolesToRemove,
"User force unverified by " + interaction.user.username, "User force unverified by " + interaction.user.username
) )
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ title: "Force Unverified",
title: "Force Unverified", author: {
author: { name: mod.username,
name: mod.username, icon_url: mod.avatarURL() || undefined
icon_url: mod.avatarURL() || undefined, },
}, description: `
description: `
**User:** ${userMention(member.user.id)} **User:** ${userMention(member.user.id)}
**Mod:** ${userMention(mod.id)} **Mod:** ${userMention(mod.id)}
**IGN:** \`${ign}\` **IGN:** \`${ign}\`
**UUID:** \`${uuid}\` **UUID:** \`${uuid}\`
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: mod.avatarURL() || "", url: mod.avatarURL() || ""
},
footer: {
icon_url: member.user.avatarURL() || undefined,
text: "ID: " + member.user.id,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
icon_url: member.user.avatarURL() || undefined,
text: "ID: " + member.user.id
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "Successfully unverified " + userMention(member.user.id),
description: color: embedColor,
"Successfully unverified " + footer: {
userMention(member.user.id), text: interaction.guild!.name + " | " + devMessage,
color: embedColor, icon_url: interaction.guild!.iconURL() || undefined
footer: { }
text: interaction.guild!.name + " | " + devMessage, }]
icon_url: interaction.guild!.iconURL() || undefined,
},
},
],
}) })
}, }
} as Command } as Command

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel" import { getGuild, getHeadURL, getIGN } from "utils/Hypixel"
import { hypixelGuildID, color, devMessage } from "config/options.json" import { hypixelGuildID, color, devMessage } from "config/options.json"
import verify from "schemas/verifySchema" import verify from "schemas/verifySchema"
@@ -23,7 +18,7 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to force update") .setDescription("The user to force update")
.setRequired(true), .setRequired(true)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -38,39 +33,33 @@ export = {
if (!verifyData) { if (!verifyData) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "User is not verified.",
description: "User is not verified.", color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching ign...",
description: "Fetching ign...", color: embedColor
color: embedColor, }]
},
],
}) })
const ign = (await getIGN(verifyData.uuid)) as string const ign = (await getIGN(verifyData.uuid)) as string
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching guild data...",
description: "Fetching guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = await getGuild(verifyData.uuid) const guild = await getGuild(verifyData.uuid)
@@ -84,141 +73,87 @@ export = {
if (responseGuildID !== hypixelGuildID) { if (responseGuildID !== hypixelGuildID) {
const roles = roleManage("default") const roles = roleManage("default")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove,
"User was force updated.",
)
await user.roles.add(roles.rolesToAdd, "User was force updated.") await user.roles.add(roles.rolesToAdd, "User was force updated.")
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: usermentioned + " was given the the Default Member role.",
description: color: embedColor,
usermentioned + thumbnail: {
" was given the the Default Member role.", url: head!
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
return return
} }
if (responseGuildID === hypixelGuildID) { if (responseGuildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find( const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid)!.rank
member => member.uuid === verifyData.uuid,
)!.rank
let replyRank: string | null = null let replyRank: string | null = null
await user.roles.add( await user.roles.add(roleManage("default").rolesToAdd, "User was force updated.")
roleManage("default").rolesToAdd,
"User was force updated.",
)
if (guildRank === "Guild Master") { if (guildRank === "Guild Master") {
const roles = roleManage("gm") const roles = roleManage("gm")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Guild Master" replyRank = "Guild Master"
} }
if (guildRank === "Manager") { if (guildRank === "Manager") {
const roles = roleManage("manager") const roles = roleManage("manager")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Manager" replyRank = "Manager"
} }
if (guildRank === "Moderator") { if (guildRank === "Moderator") {
const roles = roleManage("moderator") const roles = roleManage("moderator")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Moderator" replyRank = "Moderator"
} }
if (guildRank === "Beast") { if (guildRank === "Beast") {
const roles = roleManage("beast") const roles = roleManage("beast")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Beast" replyRank = "Beast"
} }
if (guildRank === "Elite") { if (guildRank === "Elite") {
const roles = roleManage("elite") const roles = roleManage("elite")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Elite" replyRank = "Elite"
} }
if (guildRank === "Member") { if (guildRank === "Member") {
const roles = roleManage("member") const roles = roleManage("member")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User was force updated.")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User was force updated.")
"User was force updated.",
)
await user.roles.add(
roles.rolesToAdd,
"User was force updated.",
)
replyRank = "Member" replyRank = "Member"
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: usermentioned + " was given the the " + replyRank + " role.",
description: color: embedColor,
usermentioned + thumbnail: {
" was given the the " + url: head!
replyRank +
" role.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
} }
}, }
} as Command } as Command

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, GuildMember, userMention } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
GuildMember,
userMention,
} from "discord.js"
import { getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel" import { getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
import { color, hypixelGuildID, devMessage } from "config/options.json" import { color, hypixelGuildID, devMessage } from "config/options.json"
import verify from "schemas/verifySchema" import verify from "schemas/verifySchema"
@@ -22,10 +17,14 @@ export = {
.setName("forceverify") .setName("forceverify")
.setDescription("Force verify a user.") .setDescription("Force verify a user.")
.addUserOption(option => .addUserOption(option =>
option.setName("user").setDescription("The user to force verify."), option
.setName("user")
.setDescription("The user to force verify.")
) )
.addStringOption(option => .addStringOption(option =>
option.setName("ign").setDescription("The user's in-game name."), option
.setName("ign")
.setDescription("The user's in-game name.")
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -45,9 +44,8 @@ export = {
} }
if (!user) { if (!user) {
interaction.editReply( interaction.editReply("Please provide a user to force verify.\n" +
"Please provide a user to force verify.\nThis can also mean the user is not in the server.", "This can also mean the user is not in the server.")
)
return return
} }
@@ -71,58 +69,46 @@ export = {
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching their uuid...",
description: "Fetching their uuid...", color: embedColor
color: embedColor, }]
},
],
}) })
const uuid = await getUUID(ign) const uuid = await getUUID(ign)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player doesn't exist.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player doesn't exist.", }]
color: embedColor,
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching their player data...",
description: "Fetching their player data...", color: embedColor
color: embedColor, }]
},
],
}) })
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.", }]
color: embedColor,
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching their guild data...",
description: "Fetching their guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = await getGuild(uuid) const guild = await getGuild(uuid)
@@ -136,119 +122,87 @@ export = {
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
if (responseGuildID === hypixelGuildID) { if (responseGuildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find( const guildRank = GuildMembers.find(member => member.uuid === player.uuid)!.rank
member => member.uuid === player.uuid,
)!.rank
if (guildRank === "Guild Master") { if (guildRank === "Guild Master") {
const roles = roleManage("gm") const roles = roleManage("gm")
await user.roles.add( await user.roles.add(roles.rolesToAdd, "User was force verified by " + modName)
roles.rolesToAdd,
"User was force verified by " + modName,
)
} }
if (guildRank === "Manager") { if (guildRank === "Manager") {
const roles = roleManage("manager") const roles = roleManage("manager")
await user.roles.add( await user.roles.add(roles.rolesToAdd, "User was force verified by " + modName)
roles.rolesToAdd,
"User was force verified by " + modName,
)
} }
if (guildRank === "Moderator") { if (guildRank === "Moderator") {
const roles = roleManage("moderator") const roles = roleManage("moderator")
await user.roles.add( await user.roles.add(roles.rolesToAdd, "User was force verified by " + modName)
roles.rolesToAdd,
"User was force verified by " + modName,
)
} }
if (guildRank === "Beast") { if (guildRank === "Beast") {
const roles = roleManage("beast") const roles = roleManage("beast")
await user.roles.add( await user.roles.add(roles.rolesToAdd, "User was force verified by " + modName)
roles.rolesToAdd,
"User was force verified by " + modName,
)
} }
if (guildRank === "Elite") { if (guildRank === "Elite") {
const roles = roleManage("elite") const roles = roleManage("elite")
await user.roles.add( await user.roles.add(roles.rolesToAdd, "User was force verified by " + modName)
roles.rolesToAdd,
"User was force verified by " + modName,
)
} }
if (guildRank === "Member") { if (guildRank === "Member") {
const roles = roleManage("member") const roles = roleManage("member")
await user.roles.add( await user.roles.add(roles.rolesToAdd, "User was force verified by " + modName)
roles.rolesToAdd,
"User was force verified by " + modName,
)
} }
} }
await user.roles.add( await user.roles.add( roleManage("default").rolesToAdd, "User was force verified by " + modName)
roleManage("default").rolesToAdd,
"User was force verified by " + modName,
)
const newVerify = new verify({ const newVerify = new verify({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.id, userID: user.id,
uuid: uuid, uuid: uuid
}) })
await newVerify.save() await newVerify.save()
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: modName,
name: modName, icon_url: mod.avatarURL() || undefined
icon_url: mod.avatarURL() || undefined, },
}, title: "Force Verified",
title: "Force Verified", description: `
description: `
**User:** ${userMention(user.id)} **User:** ${userMention(user.id)}
**Mod:** ${userMention(mod.id)} **Mod:** ${userMention(mod.id)}
**IGN:** \`${player.displayname}\` **IGN:** \`${player.displayname}\`
**UUID:** \`${uuid}\` **UUID:** \`${uuid}\`
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: mod.avatarURL() || "", url: mod.avatarURL() || ""
},
footer: {
icon_url: user.user.avatarURL() || undefined,
text: "ID: " + user.user.id,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
icon_url: user.user.avatarURL() || undefined,
text: "ID: " + user.user.id
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: interaction.guild!.name,
title: interaction.guild!.name, description: "You have successfully force verified `" + username + "` with the account `" + player.displayname + "`.",
description: color: embedColor,
"You have successfully force verified `" + thumbnail: {
username + url: head!
"` with the account `" +
player.displayname +
"`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
}) })
}, }
} as Command } as Command