Replaced clang format with prettuier (sadly)

This commit is contained in:
2023-12-28 16:47:52 +01:00
parent ca5bbd0b81
commit 117140fe9d
99 changed files with 13519 additions and 12011 deletions

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { admin, helper } from "../../config/roles.json"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
@@ -17,11 +22,11 @@ export = {
option
.setName("user")
.setDescription("User to ban")
.setRequired(true))
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription("Reason for ban"))
option.setName("reason").setDescription("Reason for ban"),
)
.addNumberOption(option =>
option
.setName("messagedeletiondays")
@@ -33,19 +38,22 @@ export = {
{ name: "4 days", value: 4 },
{ name: "5 days", value: 5 },
{ name: "6 days", value: 6 },
{ name: "7 days", value: 7 }
)
{ name: "7 days", value: 7 },
),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const member = interaction.options.getMember("user") as GuildMember | null
const reason = interaction.options.getString("reason") ?? "No reason provided."
const messageDeletionDays = interaction.options.getNumber("messagedeletiondays") ?? 0
const member = interaction.options.getMember(
"user",
) as GuildMember | null
const reason =
interaction.options.getString("reason") ?? "No reason provided."
const messageDeletionDays =
interaction.options.getNumber("messagedeletiondays") ?? 0
const embedColor = Number(color.replace("#", "0x"))
if (!member) {
@@ -57,13 +65,17 @@ export = {
const memberRoles = member.roles.cache.map(role => role.id)
const modRoles = mod.roles.cache.map(role => role.id)
if (!modRoles.includes(admin)) {
await interaction.editReply("You do not have permission to use this command.")
await interaction.editReply(
"You do not have permission to use this command.",
)
return
}
if (interaction.guild!.members.me!.roles.highest.position <= member.roles.highest.position) {
if (
interaction.guild!.members.me!.roles.highest.position <=
member.roles.highest.position
) {
await interaction.editReply("I cannot ban this member.")
return
}
@@ -95,24 +107,36 @@ export = {
await member.ban({
reason: reason,
deleteMessageDays: messageDeletionDays
deleteMessageDays: messageDeletionDays,
})
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",
color: embedColor,
footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL({ forceStatic: false }) || undefined
embeds: [
{
title: "Member Banned",
description:
"**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,
},
timestamp: new Date().toISOString(),
},
timestamp: new Date().toISOString()
}]
],
})
}
} as Command
},
} as Command

View File

@@ -1,7 +1,23 @@
import { SlashCommandBuilder } from "discord.js"
import { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "../../config/reqs.json"
import {
bwfkdr,
bwstars,
bwwins,
swstars,
swkdr,
duelswins,
duelswlr,
} from "../../config/reqs.json"
import { color, devMessage } from "../../config/options.json"
import { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild, getHeadURL } from "../utils/Hypixel"
import {
hypixelLevel,
bedwarsLevel,
skywarsLevel,
getUUID,
getPlayer,
getGuild,
getHeadURL,
} from "../utils/Hypixel"
import { Command } from "../interfaces"
export = {
@@ -14,12 +30,14 @@ export = {
data: new SlashCommandBuilder()
.setName("check")
.setDescription("Check a player's stats.")
.addStringOption((option) => option.setName("ign")
.setDescription("The player's IGN.")
.setRequired(true)),
.addStringOption(option =>
option
.setName("ign")
.setDescription("The player's IGN.")
.setRequired(true),
),
async execute(interaction) {
await interaction.deferReply({})
const ign = interaction.options.getString("ign")
@@ -31,37 +49,47 @@ export = {
}
await interaction.editReply({
embeds: [{
description: "Fetching your uuid...",
color: embedColor
}]
embeds: [
{
description: "Fetching your uuid...",
color: embedColor,
},
],
})
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [
{ description: "That player doesn't exist.", color: embedColor }
]
{
description: "That player doesn't exist.",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your player data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your player data...",
color: embedColor,
},
],
})
const head = await getHeadURL(ign)
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
description: "That player hasn't played Hypixel before.",
color: embedColor
}]
embeds: [
{
description:
"That player hasn't played Hypixel before.",
color: embedColor,
},
],
})
return
}
@@ -83,10 +111,12 @@ export = {
}
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
const guild = await getGuild(uuid)
@@ -110,7 +140,7 @@ export = {
if (!guild) {
guildRank = "N/A"
} else {
guildRank = guild.members.find((m) => m.uuid === uuid)!.rank
guildRank = guild.members.find(m => m.uuid === uuid)!.rank
}
const statsFields = []
@@ -118,7 +148,7 @@ export = {
if (!player.stats) {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played any games.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
} else {
if (player.stats.Bedwars) {
@@ -130,7 +160,11 @@ export = {
const hsbwwins = player.stats.Bedwars.wins_bedwars || 0
let bwtitle = ""
if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
if (
hsbwstars < bwstars ||
hsbwfkdr < bwfkdr ||
hsbwwins < bwwins
) {
bwtitle =
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
} else {
@@ -140,20 +174,27 @@ export = {
statsFields.push({
name: bwtitle,
value: "**➺ Stars:** `" +
hsbwstars.toFixed(2).toString() + " / " +
bwstars.toString() + "`\n" +
value:
"**➺ Stars:** `" +
hsbwstars.toFixed(2).toString() +
" / " +
bwstars.toString() +
"`\n" +
"**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() +
" / " + bwfkdr.toString() + "`\n" +
" / " +
bwfkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsbwwins.toString() + " / " +
bwwins.toString() + "`"
hsbwwins.toString() +
" / " +
bwwins.toString() +
"`",
})
} else {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played BedWars.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
}
@@ -176,19 +217,25 @@ export = {
statsFields.push({
name: swtitle,
value: "**➺ Stars:** `" +
hsswstars.toFixed(2).toString() + " / " +
swstars.toString() + "`\n" +
value:
"**➺ Stars:** `" +
hsswstars.toFixed(2).toString() +
" / " +
swstars.toString() +
"`\n" +
"**➺ KDR:** `" +
hsswkd.toFixed(2).toString() + " / " +
swkdr.toString() + "`\n" +
hsswkd.toFixed(2).toString() +
" / " +
swkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsswwins.toString() + "`"
hsswwins.toString() +
"`",
})
} else {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played SkyWars.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
}
@@ -213,18 +260,23 @@ export = {
name: duelstitle,
value:
"**➺ Wins:** `" +
hsduelswins.toString() + " / " +
duelswins.toString() + "`\n" +
hsduelswins.toString() +
" / " +
duelswins.toString() +
"`\n" +
"**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() + " / " +
duelswlr.toString() + "`\n" +
hsduelswlr.toFixed(2).toString() +
" / " +
duelswlr.toString() +
"`\n" +
"**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() + "`\n"
hsduelskd.toFixed(2).toString() +
"`\n",
})
} else {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played Duels.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
}
}
@@ -233,26 +285,38 @@ export = {
const hypixelExp = player.networkExp || 0
const level = hypixelLevel(hypixelExp)
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
title: rank + player.displayname + guildTag,
description: "**Network Level:** `" +
level.toFixed(2).toString() + "`\n" +
"**Current Guild:** `" + guildName + "`\n" +
"**Guild Rank:** `" + guildRank + "`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
title: rank + player.displayname + guildTag,
description:
"**Network Level:** `" +
level.toFixed(2).toString() +
"`\n" +
"**Current Guild:** `" +
guildName +
"`\n" +
"**Guild Rank:** `" +
guildRank +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!,
},
fields: statsFields,
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!
},
fields: statsFields
}]
],
})
}
} as Command
},
} as Command

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, GuildTextBasedChannel } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
ChannelType,
GuildTextBasedChannel,
} from "discord.js"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
@@ -16,12 +21,12 @@ export = {
option
.setName("amount")
.setDescription("Amount of messages to clear")
.setRequired(true))
.setRequired(true),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const amount = interaction.options.getInteger("amount")!
@@ -30,40 +35,50 @@ export = {
if (!amount || amount < 1 || amount > 100) {
await interaction.editReply({
embeds: [{
description: "Please provide an amount of messages to clear",
color: embedColor
}],
embeds: [
{
description:
"Please provide an amount of messages to clear",
color: embedColor,
},
],
})
}
if (channel2.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [{
description: "You can only clear messages in a text channel",
color: embedColor
}],
embeds: [
{
description:
"You can only clear messages in a text channel",
color: embedColor,
},
],
})
}
const channel = channel2 as GuildTextBasedChannel
channel.messages.fetch({ limit: amount }).then(async messages => {
const messagesToDelete = messages.map(m => m)
.filter(m =>
m.pinned === false &&
m.system === false &&
m.createdTimestamp > Date.now() - 1209600000
const messagesToDelete = messages
.map(m => m)
.filter(
m =>
m.pinned === false &&
m.system === false &&
m.createdTimestamp > Date.now() - 1209600000,
)
await channel.bulkDelete(messagesToDelete, true)
await interaction.editReply({
embeds: [{
description: `Deleted ${messages.size} messages`,
color: embedColor
}],
embeds: [
{
description: `Deleted ${messages.size} messages`,
color: embedColor,
},
],
})
})
}
} as Command
},
} as Command

View File

@@ -18,21 +18,22 @@ export = {
option
.setName("setting")
.setDescription("The setting to configure")
.setChoices(
{ name: "Staff Application status", value: "staffAppStatus" }
)
.setRequired(true))
.setChoices({
name: "Staff Application status",
value: "staffAppStatus",
})
.setRequired(true),
)
.addStringOption(option =>
option
.setName("value")
.setDescription("The value to set")
.setRequired(true)
.setRequired(true),
)
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) {
await interaction.deferReply()
const setting = interaction.options.getString("setting")
@@ -41,33 +42,42 @@ export = {
const settingsData = await settings.findOne({ name: setting })
if (!settingsData) {
const newSetting = new settings({
_id: new mongoose.Types.ObjectId(),
name: setting,
value: value
value: value,
})
await newSetting.save()
await interaction.editReply({
embeds: [{
description: "Successfully created `" + setting + "` with value `" + value + "`.",
color: embedColor
}]
embeds: [
{
description:
"Successfully created `" +
setting +
"` with value `" +
value +
"`.",
color: embedColor,
},
],
})
} else {
await settings.findOneAndUpdate(
{ name: setting },
{ value: value }
)
await settings.findOneAndUpdate({ name: setting }, { value: value })
await interaction.editReply({
embeds: [{
description: "Successfully updated `" + setting + "` to value `" + value + "`.",
}]
embeds: [
{
description:
"Successfully updated `" +
setting +
"` to value `" +
value +
"`.",
},
],
})
}
}
} as Command
},
} as Command

View File

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

View File

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

View File

@@ -1,9 +1,32 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { color, devMessage } from "../../config/options.json"
import verify = require("../schemas/verifySchema")
import { gm, manager, moderator, beast, member, guildRole, guildStaff, defaultMember } from "../../config/roles.json"
import {
gm,
manager,
moderator,
beast,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../config/roles.json"
import { Command } from "../interfaces"
const removeThese = [gm, manager, moderator, beast, member, guildRole, guildStaff, defaultMember]
const removeThese = [
gm,
manager,
moderator,
beast,
member,
guildRole,
guildStaff,
defaultMember,
]
export = {
name: "forceunverify",
@@ -19,7 +42,8 @@ export = {
option
.setName("user")
.setDescription("The user to force unverify")
.setRequired(true))
.setRequired(true),
)
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
@@ -30,10 +54,12 @@ export = {
if (!verifiedUser) {
return interaction.reply({
embeds: [{
description: "This user is not verified",
color: embedColor,
}]
embeds: [
{
description: "This user is not verified",
color: embedColor,
},
],
})
}
@@ -42,14 +68,20 @@ export = {
await member.roles.remove(removeThese)
await interaction.reply({
embeds: [{
description: "Successfully unverified " + userMention(member.user.id),
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
embeds: [
{
description:
"Successfully unverified " +
userMention(member.user.id),
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
})
}
} as Command
},
} as Command

View File

@@ -1,10 +1,34 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { getGuild, getHeadURL, getIGN } from "../utils/Hypixel"
import { hypixelGuildID, color, devMessage } from "../../config/options.json"
import { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../config/roles.json"
import {
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../config/roles.json"
import verify = require("../schemas/verifySchema")
import { Command } from "../interfaces"
const removeThese = [gm, manager, moderator, beast, elite, member, guildRole, guildStaff]
const removeThese = [
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
]
export = {
name: "forceupdate",
@@ -20,12 +44,12 @@ export = {
option
.setName("user")
.setDescription("The user to force update")
.setRequired(true))
.setRequired(true),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const user = interaction.options.getMember("user") as GuildMember
@@ -37,33 +61,41 @@ export = {
if (!verifyData) {
await interaction.editReply({
embeds: [{
description: "User is not verified.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
embeds: [
{
description: "User is not verified.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching ign...",
color: embedColor,
}]
embeds: [
{
description: "Fetching ign...",
color: embedColor,
},
],
})
const ign = await getIGN(verifyData.uuid) as string
const ign = (await getIGN(verifyData.uuid)) as string
const head = await getHeadURL(ign)
await interaction.editReply({
embeds: [{
description: "Fetching guild data...",
color: embedColor,
}]
embeds: [
{
description: "Fetching guild data...",
color: embedColor,
},
],
})
const guild = await getGuild(verifyData.uuid)
@@ -76,37 +108,48 @@ export = {
}
if (responseGuildID !== hypixelGuildID) {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)",
)
}
await interaction.editReply({
embeds: [{
description: usermentioned + " was given the the Default Member role.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
usermentioned +
" was given the the Default Member role.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
await roleManage.add(defaultMember)
return
}
if (responseGuildID === hypixelGuildID) {
const GuildMembers = guild!.members
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid)!.rank
const guildRank = GuildMembers.find(
member => member.uuid === verifyData.uuid,
)!.rank
if (guildRank === "Guild Master") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)",
)
}
await roleManage.add(guildRole, "User was force updated.")
@@ -114,26 +157,36 @@ export = {
await roleManage.add(gm, "User was force updated.")
await roleManage.add(defaultMember, "User was force updated.")
await interaction.editReply({
embeds: [{
description: usermentioned + "'s rank has been updated to `Guild Master`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
usermentioned +
"'s rank has been updated to `Guild Master`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
}
if (guildRank === "Manager") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)",
)
}
await roleManage.add(guildRole, "User was force updated.")
@@ -141,26 +194,36 @@ export = {
await roleManage.add(manager, "User was force updated.")
await roleManage.add(defaultMember, "User was force updated.")
await interaction.editReply({
embeds: [{
description: usermentioned + "'s rank has been updated to `Manager`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
usermentioned +
"'s rank has been updated to `Manager`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
}
if (guildRank === "Moderator") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)",
)
}
await roleManage.add(guildRole, "User was force updated.")
@@ -168,103 +231,140 @@ export = {
await roleManage.add(moderator, "User was force updated.")
await roleManage.add(defaultMember, "User was force updated.")
await interaction.editReply({
embeds: [{
description: usermentioned + "'s rank has been updated to `Moderator`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
usermentioned +
"'s rank has been updated to `Moderator`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
}
if (guildRank === "Beast") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)",
)
}
await roleManage.add(guildRole, "User was force updated.")
await roleManage.add(beast, "User was force updated.")
await roleManage.add(defaultMember, "User was force updated.")
await interaction.editReply({
embeds: [{
description: usermentioned + "'s rank has been updated to `Beast`.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
usermentioned +
"'s rank has been updated to `Beast`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
return
}
if (guildRank === "Elite") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)",
)
}
await roleManage.add(guildRole, "User was force updated.")
await roleManage.add(elite, "User was force updated.")
await roleManage.add(defaultMember, "User was force updated.")
await interaction.editReply({
embeds: [{
description: usermentioned + "'s rank has been updated to `Elite`.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
usermentioned +
"'s rank has been updated to `Elite`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
return
}
if (guildRank === "Member") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)",
)
}
await roleManage.add(guildRole, "User was force updated.")
await roleManage.add(member, "User was force updated.")
await roleManage.add(defaultMember, "User was force updated.")
await interaction.editReply({
embeds: [{
description: usermentioned + "'s rank has been updated to `Member`.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
usermentioned +
"'s rank has been updated to `Member`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
return
}
}
}
} as Command
},
} as Command

View File

@@ -1,9 +1,23 @@
import { SlashCommandBuilder, PermissionFlagsBits, GuildMember } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
GuildMember,
} from "discord.js"
import { getUUID, getPlayer, getGuild, getHeadURL } from "../utils/Hypixel"
import { color, hypixelGuildID, devMessage } from "../../config/options.json"
import verify = require("../schemas/verifySchema")
import mongoose from "mongoose"
import { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../config/roles.json"
import {
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../config/roles.json"
import { Command } from "../interfaces"
export = {
@@ -17,18 +31,15 @@ export = {
.setName("forceverify")
.setDescription("Force verify a user.")
.addUserOption(option =>
option
.setName("user")
.setDescription("The user to force verify."))
option.setName("user").setDescription("The user to force verify."),
)
.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)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const user = interaction.member as GuildMember
@@ -43,7 +54,9 @@ export = {
}
if (!user) {
interaction.editReply("Please provide a user to force verify.\nThis can also mean the user is not in the server.")
interaction.editReply(
"Please provide a user to force verify.\nThis can also mean the user is not in the server.",
)
return
}
@@ -67,46 +80,58 @@ export = {
}
await interaction.editReply({
embeds: [{
description: "Fetching their uuid...",
color: embedColor
}]
embeds: [
{
description: "Fetching their uuid...",
color: embedColor,
},
],
})
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [{
description: "<a:questionmark_pink:1130206038008803488> That player doesn't exist.",
color: embedColor
}]
embeds: [
{
description:
"<a:questionmark_pink:1130206038008803488> That player doesn't exist.",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching their player data...",
color: embedColor
}]
embeds: [
{
description: "Fetching their player data...",
color: embedColor,
},
],
})
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor
}]
embeds: [
{
description:
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching their guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching their guild data...",
color: embedColor,
},
],
})
const guild = await getGuild(uuid)
@@ -120,66 +145,125 @@ export = {
const head = await getHeadURL(ign)
if (responseGuildID === hypixelGuildID) {
const GuildMembers = guild!.members
const guildRank = GuildMembers.find(member => member.uuid === player.uuid)!.rank
const guildRank = GuildMembers.find(
member => member.uuid === player.uuid,
)!.rank
if (guildRank === "Guild Master") {
await user.roles.add(gm, "User was force verified by " + modName)
await user.roles.add(guildRole, "User was force verified by " + modName)
await user.roles.add(guildStaff, "User was force verified by " + modName)
await user.roles.add(
gm,
"User was force verified by " + modName,
)
await user.roles.add(
guildRole,
"User was force verified by " + modName,
)
await user.roles.add(
guildStaff,
"User was force verified by " + modName,
)
}
if (guildRank === "Manager") {
await user.roles.add(manager, "User was force verified by " + modName)
await user.roles.add(guildRole, "User was force verified by " + modName)
await user.roles.add(guildStaff, "User was force verified by " + modName)
await user.roles.add(
manager,
"User was force verified by " + modName,
)
await user.roles.add(
guildRole,
"User was force verified by " + modName,
)
await user.roles.add(
guildStaff,
"User was force verified by " + modName,
)
}
if (guildRank === "Moderator") {
await user.roles.add(moderator, "User was force verified by " + modName)
await user.roles.add(guildRole, "User was force verified by " + modName)
await user.roles.add(guildStaff, "User was force verified by " + modName)
await user.roles.add(
moderator,
"User was force verified by " + modName,
)
await user.roles.add(
guildRole,
"User was force verified by " + modName,
)
await user.roles.add(
guildStaff,
"User was force verified by " + modName,
)
}
if (guildRank === "Beast") {
await user.roles.add(beast, "User was force verified by " + modName)
await user.roles.add(guildRole, "User was force verified by " + modName)
await user.roles.add(
beast,
"User was force verified by " + modName,
)
await user.roles.add(
guildRole,
"User was force verified by " + modName,
)
}
if (guildRank === "Elite") {
await user.roles.add(elite, "User was force verified by " + modName)
await user.roles.add(guildRole, "User was force verified by " + modName)
await user.roles.add(
elite,
"User was force verified by " + modName,
)
await user.roles.add(
guildRole,
"User was force verified by " + modName,
)
}
if (guildRank === "Member") {
await user.roles.add(member, "User was force verified by " + modName)
await user.roles.add(guildRole, "User was force verified by " + modName)
await user.roles.add(
member,
"User was force verified by " + modName,
)
await user.roles.add(
guildRole,
"User was force verified by " + modName,
)
}
}
await user.roles.add(defaultMember, "User was force verified by " + modName)
await user.roles.add(
defaultMember,
"User was force verified by " + modName,
)
const newVerify = new verify({
_id: new mongoose.Types.ObjectId(),
userID: user.id,
uuid: uuid
uuid: uuid,
})
await newVerify.save()
await interaction.editReply({
embeds: [{
title: interaction.guild!.name,
description: "You have successfully force verified `" + username + "` with the account `" + player.displayname + "`.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
title: interaction.guild!.name,
description:
"You have successfully force verified `" +
username +
"` with the account `" +
player.displayname +
"`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
},
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
],
})
}
} as Command
},
} as Command

View File

@@ -24,8 +24,8 @@ export = {
option
.setName("ign")
.setDescription("The IGN of the player.")
.setRequired(true)
)
.setRequired(true),
),
)
.addSubcommand(subcommand =>
subcommand
@@ -34,19 +34,21 @@ export = {
.addStringOption(option =>
option
.setName("query")
.setDescription("The query to search for. [Default: player]")
.setRequired(true)
).
addStringOption(option =>
.setDescription(
"The query to search for. [Default: player]",
)
.setRequired(true),
)
.addStringOption(option =>
option
.setName("type")
.setDescription("The type of query.")
.addChoices(
{ name: "Guild Member", value: "ign" },
{ name: "Guild Name", value: "name" },
{ name: "Guild Id", value: "id" }
)
)
{ name: "Guild Id", value: "id" },
),
),
)
.addSubcommand(subcommand =>
subcommand
@@ -55,8 +57,11 @@ export = {
.addStringOption(option =>
option
.setName("query")
.setDescription("The query to search for. [Default: player]")
.setRequired(true))
.setDescription(
"The query to search for. [Default: player]",
)
.setRequired(true),
)
.addStringOption(option =>
option
.setName("type")
@@ -64,17 +69,19 @@ export = {
.addChoices(
{ name: "Guild Member", value: "ign" },
{ name: "Guild Name", value: "name" },
{ name: "Guild Id", value: "id" }
)
{ name: "Guild Id", value: "id" },
),
)
.addNumberOption(option =>
option
.setName("amount")
.setDescription("The amount of guild members to show. [Default: 10]"))
.setDescription(
"The amount of guild members to show. [Default: 10]",
),
),
),
async execute(interaction) {
const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x"))
@@ -93,18 +100,24 @@ export = {
return
}
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: true })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: true })
await interaction.reply({
embeds: [{
description: "This command is currently under development",
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!
}
}]
embeds: [
{
description: "This command is currently under development",
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!,
},
},
],
})
}
} as Command
},
} as Command

View File

@@ -1,9 +1,17 @@
import { getUUID, getIGN, getPlayer, getGuild, guildLevel } from "../../utils/Hypixel"
import {
getUUID,
getIGN,
getPlayer,
getGuild,
guildLevel,
} from "../../utils/Hypixel"
import { color, devMessage } from "../../../config/options.json"
import { ChatInputCommandInteraction } from "discord.js"
import { GuildData } from "../../interfaces/Guild"
async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void> {
async function guildInfo(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const query = interaction.options.getString("query")!
@@ -13,91 +21,111 @@ async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void
if (type === "ign") {
await interaction.editReply({
embeds: [{
description: "Fetching your uuid...",
color: embedColor
}]
embeds: [
{
description: "Fetching your uuid...",
color: embedColor,
},
],
})
const uuid = await getUUID(query)
if (!uuid) {
interaction.editReply({
embeds: [{
description: "That player doen't exist!",
color: embedColor
}]
embeds: [
{
description: "That player doen't exist!",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your player data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your player data...",
color: embedColor,
},
],
})
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
description: "That player has never joined the server!",
color: embedColor
}]
embeds: [
{
description: "That player has never joined the server!",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
guild = await getGuild(uuid, "player")
if (!guild) {
interaction.editReply({
embeds: [{
description: "That player is not in a guild!",
color: embedColor
}]
embeds: [
{
description: "That player is not in a guild!",
color: embedColor,
},
],
})
return
}
} else if (type === "name") {
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
guild = await getGuild(query, "name")
if (!guild) {
interaction.editReply({
embeds: [{
description: "That guild doesn't exist!",
color: embedColor
}]
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor,
},
],
})
return
}
} else if (type === "id") {
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
guild = await getGuild(query, "id")
if (!guild) {
interaction.editReply({
embeds: [{
description: "That guild doesn't exist!",
color: embedColor
}]
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor,
},
],
})
return
}
@@ -119,62 +147,105 @@ async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void
const guildCreatedMinute = guildCreated.getMinutes()
const guildCreatedSecond = guildCreated.getSeconds()
const guildCreatedTime = guildCreatedDate + "." +
guildCreatedMonth + "." +
guildCreatedYear + " " +
guildCreatedHour + ":" +
guildCreatedMinute + ":" +
const guildCreatedTime =
guildCreatedDate +
"." +
guildCreatedMonth +
"." +
guildCreatedYear +
" " +
guildCreatedHour +
":" +
guildCreatedMinute +
":" +
guildCreatedSecond
const guildOwner = guildMembers.find((m) => m.rank === "Guild Master")!.uuid
const guildOwner = guildMembers.find(m => m.rank === "Guild Master")!.uuid
const guildOwnerName = await getIGN(guildOwner)
const guildRanksUnsorted = guild!.ranks.sort((a, b) => b.priority - a.priority)
const guildRanks = guildRanksUnsorted.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n")
const guildRanksUnsorted = guild!.ranks.sort(
(a, b) => b.priority - a.priority,
)
const guildRanks = guildRanksUnsorted
.map(r => "**➺ " + r.name + "** `[" + r.tag + "]`")
.join("\n")
const allGuildMembersWeeklyXP = guildMembers.map(member => member.expHistory)
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map((member) => {
const allGuildMembersWeeklyXP = guildMembers.map(
member => member.expHistory,
)
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map(member => {
return Object.values(member).reduce((a, b) => a + b, 0)
})
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce((a, b) => a + b, 0)
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(totalGuildMembersWeeklyXPUnformatted)
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce(
(a, b) => a + b,
0,
)
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
totalGuildMembersWeeklyXPUnformatted,
)
const averageGuildMembersWeeklyXPUnformatted = Math.round(totalGuildMembersWeeklyXPUnformatted / 7)
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(averageGuildMembersWeeklyXPUnformatted)
const averageGuildMembersWeeklyXPUnformatted = Math.round(
totalGuildMembersWeeklyXPUnformatted / 7,
)
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
averageGuildMembersWeeklyXPUnformatted,
)
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
title: "**Info on** " + guildName,
description: "**Guild Name: **`" + guildName + "`\n" +
"**Guild Tag: **`" + guildTag + "`\n" +
"**Guild Level: **`" + guildLvl + "`\n" +
"**Guild Owner: **`" + guildOwnerName + "`",
fields: [
{
name: "**Guild Ranks**",
value: guildRanks
embeds: [
{
title: "**Info on** " + guildName,
description:
"**Guild Name: **`" +
guildName +
"`\n" +
"**Guild Tag: **`" +
guildTag +
"`\n" +
"**Guild Level: **`" +
guildLvl +
"`\n" +
"**Guild Owner: **`" +
guildOwnerName +
"`",
fields: [
{
name: "**Guild Ranks**",
value: guildRanks,
},
{
name: "**GEXP**",
value:
"**➺ Total weekly GEXP:** `" +
totalGuildMembersWeeklyXP +
"`\n" +
"**➺ Daily avarage:** `" +
averageGuildMembersWeeklyXP +
"`\n" +
"**➺ Total GEXP:** `" +
guildExp +
"`",
},
{
name: "**Guild Created**",
value: "**➺ **`" + guildCreatedTime + "`",
},
],
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!,
},
{
name: "**GEXP**",
value: "**➺ Total weekly GEXP:** `" + totalGuildMembersWeeklyXP + "`\n" +
"**➺ Daily avarage:** `" + averageGuildMembersWeeklyXP + "`\n" +
"**➺ Total GEXP:** `" + guildExp + "`"
},
{
name: "**Guild Created**",
value: "**➺ **`" + guildCreatedTime + "`"
}
],
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!
}
}]
},
],
})
}
export = guildInfo
export = guildInfo

View File

@@ -2,17 +2,21 @@ import { getUUID, getPlayer, getGuild, getHeadURL } from "../../utils/Hypixel"
import { color, devMessage } from "../../../config/options.json"
import { ChatInputCommandInteraction } from "discord.js"
async function guildMember(interaction: ChatInputCommandInteraction): Promise<void> {
async function guildMember(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const ign = interaction.options.getString("ign")!
const embedColor = Number(color.replace("#", "0x"))
await interaction.editReply({
embeds: [{
description: "Fetching your uuid...",
color: embedColor
}]
embeds: [
{
description: "Fetching your uuid...",
color: embedColor,
},
],
})
const uuid = await getUUID(ign)
@@ -29,10 +33,12 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
}
await interaction.editReply({
embeds: [{
description: "Fetching your player data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your player data...",
color: embedColor,
},
],
})
const head = await getHeadURL(ign)
@@ -48,7 +54,9 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
@@ -74,26 +82,32 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
}
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
const guild = await getGuild(uuid)
if (!guild) {
await interaction.editReply({
embeds: [{
description: "This user is not in a guild",
color: embedColor,
thumbnail: {
url: head!,
embeds: [
{
description: "This user is not in a guild",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
},
}],
],
})
return
}
@@ -102,17 +116,34 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
const guildTag = " [" + guild.tag + "]" ?? ""
const guildMembers = guild.members
const guildMember = guildMembers.find((member) => member.uuid === uuid)
const guildMember = guildMembers.find(member => member.uuid === uuid)
const guildRank = guildMember!.rank
const memberGexp = guildMember!.expHistory
const allDaysGexp = Object.keys(memberGexp).map((key) => {
return "**➺ " + key + ":** " + "`" + new Intl.NumberFormat("en-US").format(memberGexp[key]) + "`" + "\n"
const allDaysGexp = Object.keys(memberGexp).map(key => {
return (
"**➺ " +
key +
":** " +
"`" +
new Intl.NumberFormat("en-US").format(memberGexp[key]) +
"`" +
"\n"
)
})
const expValue = allDaysGexp.join("")
const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce((a, b) => a + b, 0)
const totalWeeklyGexp = new Intl.NumberFormat("en-US").format(totalWeeklyGexpUnformatted)
const averageWeeklyGexpUnformatted = Math.round(totalWeeklyGexpUnformatted / 7)
const averageWeeklyGexp = new Intl.NumberFormat("en-US").format(averageWeeklyGexpUnformatted)
const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce(
(a, b) => a + b,
0,
)
const totalWeeklyGexp = new Intl.NumberFormat("en-US").format(
totalWeeklyGexpUnformatted,
)
const averageWeeklyGexpUnformatted = Math.round(
totalWeeklyGexpUnformatted / 7,
)
const averageWeeklyGexp = new Intl.NumberFormat("en-US").format(
averageWeeklyGexpUnformatted,
)
const guildMemberJoinMS = guildMember!.joined
const guildMemberJoinTime = new Date(guildMemberJoinMS)
@@ -124,46 +155,67 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds()
const guildMemberJoin =
guildMemberJoinDate + "." +
guildMemberJoinMonth + "." +
guildMemberJoinYear + " " +
guildMemberJoinHours + ":" +
guildMemberJoinMinutes + ":" +
guildMemberJoinDate +
"." +
guildMemberJoinMonth +
"." +
guildMemberJoinYear +
" " +
guildMemberJoinHours +
":" +
guildMemberJoinMinutes +
":" +
guildMemberJoinSeconds
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
title: rank + displayName + guildTag,
description: "**Guild Name:** `" + guildName + "`\n" +
"**Guild Rank:** `" + guildRank + "`\n",
color: embedColor,
thumbnail: {
url: head!,
embeds: [
{
title: rank + displayName + guildTag,
description:
"**Guild Name:** `" +
guildName +
"`\n" +
"**Guild Rank:** `" +
guildRank +
"`\n",
color: embedColor,
thumbnail: {
url: head!,
},
fields: [
{
name: "**Daily GEXP**",
value: expValue,
},
{
name: "**Weekly GEXP**",
value:
"**➺ Total:** `" +
totalWeeklyGexp +
"`\n" +
"**➺ Daily avarage:** `" +
averageWeeklyGexp +
"`",
},
{
name: "**Join date**",
value: "**➺ **`" + guildMemberJoin + "`",
},
],
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!,
},
},
fields: [
{
name: "**Daily GEXP**",
value: expValue,
},
{
name: "**Weekly GEXP**",
value: "**➺ Total:** `" + totalWeeklyGexp + "`\n" +
"**➺ Daily avarage:** `" + averageWeeklyGexp + "`",
},
{
name: "**Join date**",
value: "**➺ **`" + guildMemberJoin + "`",
},
],
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!
},
}],
],
})
}
export = guildMember
export = guildMember

View File

@@ -4,7 +4,9 @@ import { ChannelType, ChatInputCommandInteraction } from "discord.js"
import { redis } from "../../utils/Redis"
import { GuildData } from "../../interfaces/Guild"
async function guildTop(interaction: ChatInputCommandInteraction): Promise<void> {
async function guildTop(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const query = interaction.options.getString("query")!
@@ -15,101 +17,123 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
if (interaction.channel!.type === ChannelType.DM) {
interaction.editReply({
embeds: [{
description: "You can't use this command in DMs!",
color: embedColor
}]
embeds: [
{
description: "You can't use this command in DMs!",
color: embedColor,
},
],
})
return
}
if (type === "ign") {
await interaction.editReply({
embeds: [{
description: "Fetching your uuid...",
color: embedColor
}]
embeds: [
{
description: "Fetching your uuid...",
color: embedColor,
},
],
})
const uuid = await getUUID(query)
if (!uuid) {
interaction.editReply({
embeds: [{
description: "That player doen't exist!",
color: embedColor
}]
embeds: [
{
description: "That player doen't exist!",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your player data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your player data...",
color: embedColor,
},
],
})
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
description: "That player has never joined the server!",
color: embedColor
}]
embeds: [
{
description: "That player has never joined the server!",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
guild = await getGuild(uuid, "player")
if (!guild) {
interaction.editReply({
embeds: [{
description: "That player is not in a guild!",
color: embedColor
}]
embeds: [
{
description: "That player is not in a guild!",
color: embedColor,
},
],
})
return
}
} else if (type === "name") {
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
guild = await getGuild(query, "name")
if (!guild) {
interaction.editReply({
embeds: [{
description: "That guild doesn't exist!",
color: embedColor
}]
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor,
},
],
})
return
}
} else if (type === "id") {
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
guild = await getGuild(query, "id")
if (!guild) {
interaction.editReply({
embeds: [{
description: "That guild doesn't exist!",
color: embedColor
}]
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor,
},
],
})
return
}
@@ -121,18 +145,26 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
const cachedData = await redis.get("guildTop+" + guildId)
const gexpTodayUnformatted = guildMembers.map((member) => {
return member.expHistory[Object.keys(member.expHistory)[0]]
}).reduce((a, b) => a + b, 0)
const gexpToday = new Intl.NumberFormat("en-US").format(gexpTodayUnformatted)
const gexpTodayUnformatted = guildMembers
.map(member => {
return member.expHistory[Object.keys(member.expHistory)[0]]
})
.reduce((a, b) => a + b, 0)
const gexpToday = new Intl.NumberFormat("en-US").format(
gexpTodayUnformatted,
)
const averageGuildMemberGEXPUnformatted = Math.floor(gexpTodayUnformatted / guildMembers.length)
const averageGuildMemberGEXP = new Intl.NumberFormat("en-US").format(averageGuildMemberGEXPUnformatted)
const averageGuildMemberGEXPUnformatted = Math.floor(
gexpTodayUnformatted / guildMembers.length,
)
const averageGuildMemberGEXP = new Intl.NumberFormat("en-US").format(
averageGuildMemberGEXPUnformatted,
)
const allMembersDailyGEXP = guildMembers.map((member) => {
const allMembersDailyGEXP = guildMembers.map(member => {
return {
uuid: member.uuid,
gexp: member.expHistory[Object.keys(member.expHistory)[0]]
gexp: member.expHistory[Object.keys(member.expHistory)[0]],
}
})
@@ -144,8 +176,8 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
amount = 1
}
type GuildTopData = { ign: string, gexp: string }[]
type NewList = { name: string, value: string, inline: boolean }[]
type GuildTopData = { ign: string; gexp: string }[]
type NewList = { name: string; value: string; inline: boolean }[]
let cacheStatus: boolean
let guildData: GuildTopData = []
@@ -155,14 +187,21 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
if (!cachedData) {
cacheStatus = false
await interaction.editReply({
embeds: [{
description: "Fetching the top " + amount + " members of " + guildName + "...",
color: embedColor
}]
embeds: [
{
description:
"Fetching the top " +
amount +
" members of " +
guildName +
"...",
color: embedColor,
},
],
})
for (let i = 0; i < allMembersSorted.length; i++) {
const ign = await getIGN(allMembersSorted[i].uuid) as string
const ign = (await getIGN(allMembersSorted[i].uuid)) as string
const gexpUnformatted = allMembersSorted[i].gexp
const gexp = new Intl.NumberFormat("en-US").format(gexpUnformatted)
@@ -172,14 +211,26 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
})
}
await redis.set("guildTop+" + guildId, JSON.stringify(guildData), "EX", 60 * 30)
await redis.set(
"guildTop+" + guildId,
JSON.stringify(guildData),
"EX",
60 * 30,
)
} else {
cacheStatus = true
await interaction.editReply({
embeds: [{
description: "Fetching the top " + amount + " members of " + guildName + "using cache...",
color: embedColor,
}]
embeds: [
{
description:
"Fetching the top " +
amount +
" members of " +
guildName +
"using cache...",
color: embedColor,
},
],
})
guildData = JSON.parse(cachedData)
}
@@ -196,7 +247,9 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
fieldsValueRaw.push("**#" + position + " " + ign + ":** `" + gexp + "`")
}
const list = Array.from({ length: sliceSize }, (_, i) => fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize))
const list = Array.from({ length: sliceSize }, (_, i) =>
fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize),
)
const newList: NewList = []
list.forEach((item, index) => {
@@ -205,27 +258,38 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
newList[index] = {
name: "",
value: item.join("\n"),
inline: true
inline: true,
}
})
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
const cacheStatusText = cacheStatus ? " | [Cache]" : ""
await interaction.editReply({
embeds: [{
title: "Top members of " + guildName,
description: "**Total daily GEXP:** `" + gexpToday + "`\n" +
"**Average guild memeber GEXP:** `" + averageGuildMemberGEXP + "`",
color: embedColor,
fields: newList,
footer: {
text: footerText + " | " + devMessage + cacheStatusText,
icon_url: footerIcon!
}
}]
embeds: [
{
title: "Top members of " + guildName,
description:
"**Total daily GEXP:** `" +
gexpToday +
"`\n" +
"**Average guild memeber GEXP:** `" +
averageGuildMemberGEXP +
"`",
color: embedColor,
fields: newList,
footer: {
text: footerText + " | " + devMessage + cacheStatusText,
icon_url: footerIcon!,
},
},
],
})
}
export = guildTop
export = guildTop

View File

@@ -18,14 +18,14 @@ export = {
await interaction.deferReply({ ephemeral: true })
type CommandList = {
name: string,
name: string
value: string
}
const commandList: CommandList[] = []
const commandRawList = client.commands.map((command) => {
const commandRawList = client.commands.map(command => {
return {
name: command.name,
command: command
command: command,
}
})
@@ -35,45 +35,53 @@ export = {
if (!command.command.subcommands && command.command.public) {
commandList.push({
name: "**/" + commandName + "**",
value: "`" + command.command.description + "`"
value: "`" + command.command.description + "`",
})
} else if (command.command.subcommands && command.command.public) {
const subcommands = command.command.data.options.map((subcommand) => {
return {
name: commandName + " " + subcommand.toJSON().name,
description: subcommand.toJSON().description
}
})
const subcommands = command.command.data.options.map(
subcommand => {
return {
name: commandName + " " + subcommand.toJSON().name,
description: subcommand.toJSON().description,
}
},
)
for (const subcommand of subcommands) {
commandList.push({
name: "**/" + subcommand.name + "**",
value: "`" + subcommand.description + "`"
value: "`" + subcommand.description + "`",
})
}
}
}
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction?.guild?.iconURL({ forceStatic: true })!
embeds: [
{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction?.guild?.iconURL({
forceStatic: true,
})!,
},
footer: {
icon_url: footerIcon!,
text: footerText + " | " + devMessage,
},
},
footer: {
icon_url: footerIcon!,
text: footerText + " | " + devMessage
}
}]
],
})
}
} as Command
},
} as Command

View File

@@ -18,25 +18,29 @@ export = {
const embedColor = Number(color.replace("#", "0x"))
await interaction.reply({
embeds: [{
title: "Verification",
description: "1. Log onto hypixel.\n" +
"2. Right click with the head in your hotbar.\n" +
"3. Click on the social media icon.\n" +
"4. Click on the discord icon.\n" +
"5. Type your username in the chat and press enter.\n" +
"6. Run the `/verify` command in this channel.\n",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
embeds: [
{
title: "Verification",
description:
"1. Log onto hypixel.\n" +
"2. Right click with the head in your hotbar.\n" +
"3. Click on the social media icon.\n" +
"4. Click on the discord icon.\n" +
"5. Type your username in the chat and press enter.\n" +
"6. Run the `/verify` command in this channel.\n",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
image: {
url: instructionsgif,
proxy_url: instructionsgif,
},
},
image: {
url: instructionsgif,
proxy_url: instructionsgif
}
}]
],
})
}
} as Command
},
} as Command

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { admin, helper } from "../../config/roles.json"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
@@ -17,20 +22,24 @@ export = {
option
.setName("member")
.setDescription("Member to kick.")
.setRequired(true))
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription("Reason for kicking the member."))
.setDescription("Reason for kicking the member."),
)
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
.setDMPermission(false),
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 | null
const reason =
interaction.options.getString("reason") ?? "No reason provided."
const embedColor = Number(color.replace("#", "0x"))
if (!member) {
@@ -43,7 +52,9 @@ export = {
const modRoles = mod.roles.cache.map(role => role.id)
if (!modRoles.includes(helper) && !modRoles.includes(admin)) {
await interaction.editReply("You do not have permission to use this command.")
await interaction.editReply(
"You do not have permission to use this command.",
)
return
}
@@ -75,19 +86,28 @@ export = {
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: "ID: " + member.user.id,
icon_url: member.user.avatarURL({ forceStatic: false }) || undefined
embeds: [
{
title: "Member Kicked",
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,
},
timestamp: new Date().toISOString(),
},
timestamp: new Date().toISOString()
}]
],
})
}
} as Command
},
} as Command

View File

@@ -18,19 +18,25 @@ export = {
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
description: "Ping of the bot is " + client.ws.ping + "ms.",
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon || undefined
embeds: [
{
description: "Ping of the bot is " + client.ws.ping + "ms.",
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon || undefined,
},
timestamp: new Date().toISOString(),
},
timestamp: new Date().toISOString()
}]
],
})
}
} as Command
},
} as Command

View File

@@ -1,4 +1,8 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { color } from "../../config/options.json"
import waitinglistSchema = require("../schemas/waitinglistSchema")
import { Command } from "../interfaces"
@@ -17,23 +21,23 @@ export = {
option
.setName("user")
.setDescription("The user to remove.")
.setRequired(true)
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription("The reason for removing the user.")
.setRequired(false)
.setRequired(false),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const user = interaction.options.getUser("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"))
@@ -41,10 +45,14 @@ export = {
if (!waitinglist) {
await interaction.editReply({
embeds: [{
description: userMention(user.id) + " is not on the waiting list.",
color: embedColor
}]
embeds: [
{
description:
userMention(user.id) +
" is not on the waiting list.",
color: embedColor,
},
],
})
return
}
@@ -52,17 +60,24 @@ export = {
await waitinglistSchema.findOneAndDelete({ UserID: user.id })
await interaction.editReply({
embeds: [{
description: userMention(user.id) + " has been removed from the waiting list.\n" +
"**Reason:** `" + reason + "`\n" +
"**Moderator:** " + userMention(mod.id),
color: embedColor,
footer: {
text: "User ID: " + user.id,
icon_url: user.displayAvatarURL({ forceStatic: false })
embeds: [
{
description:
userMention(user.id) +
" has been removed from the waiting list.\n" +
"**Reason:** `" +
reason +
"`\n" +
"**Moderator:** " +
userMention(mod.id),
color: embedColor,
footer: {
text: "User ID: " + user.id,
icon_url: user.displayAvatarURL({ forceStatic: false }),
},
timestamp: new Date().toISOString(),
},
timestamp: new Date().toISOString()
}]
],
})
}
} as Command
},
} as Command

View File

@@ -1,6 +1,14 @@
import { SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "../../config/reqs.json"
import {
bwfkdr,
bwstars,
bwwins,
swstars,
swkdr,
duelswins,
duelswlr,
} from "../../config/reqs.json"
import { Command } from "../interfaces"
export = {
@@ -15,44 +23,66 @@ export = {
.setDescription("Displays the requirements for the guild."),
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
title: "Requirements",
description: "**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**",
color: embedColor,
thumbnail: {
url: interaction?.guild?.iconURL({ forceStatic: false }) || ""
embeds: [
{
title: "Requirements",
description:
"**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**",
color: embedColor,
thumbnail: {
url:
interaction?.guild?.iconURL({
forceStatic: false,
}) || "",
},
fields: [
{
name: "**Bedwars**",
value:
"**Stars:** `" +
bwstars.toString() +
"`\n**Wins:** `" +
bwwins.toString() +
"`\n**FKDR:** `" +
bwfkdr.toString() +
"`",
},
{
name: "**Skywars**",
value:
"**Stars:** `" +
swstars.toString() +
"`\n**KDR:** `" +
swkdr.toString() +
"`",
},
{
name: "**Duels**",
value:
"**Wins:** `" +
duelswins.toString() +
"`\n**WLR:** `" +
duelswlr.toString() +
"`",
},
],
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon || undefined,
},
},
fields: [
{
name: "**Bedwars**",
value: "**Stars:** `" + bwstars.toString() +
"`\n**Wins:** `" + bwwins.toString() +
"`\n**FKDR:** `" + bwfkdr.toString() + "`"
},
{
name: "**Skywars**",
value: "**Stars:** `" + swstars.toString() +
"`\n**KDR:** `" + swkdr.toString() + "`"
},
{
name: "**Duels**",
value: "**Wins:** `" + duelswins.toString() +
"`\n**WLR:** `" + duelswlr.toString() + "`"
}
],
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon || undefined
}
}]
],
})
}
} as Command
},
} as Command

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, GuildTextBasedChannel } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
ChannelType,
GuildTextBasedChannel,
} from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
@@ -16,32 +21,40 @@ export = {
option
.setName("message")
.setDescription("The message to send.")
.setRequired(true))
.setRequired(true),
)
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to send the message to."))
.setDescription("The channel to send the message to."),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const message = interaction.options.getString("message")!
const channel2 = interaction.options.getChannel("channel") ?? interaction.channel
const channel2 =
interaction.options.getChannel("channel") ?? interaction.channel
const embedColor = Number(color.replace("#", "0x"))
if (channel2?.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [{
description: "You can only send a message to a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
embeds: [
{
description:
"You can only send a message to a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
},
],
})
return
}
@@ -55,25 +68,34 @@ export = {
description: message,
color: embedColor,
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
footer: {
text: interaction.guild!.id + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: true }) || undefined
}
}
]
icon_url:
interaction.guild!.iconURL({ forceStatic: true }) ||
undefined,
},
},
],
})
await interaction.editReply({
embeds: [{
description: "Message sent.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
embeds: [
{
description: "Message sent.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
},
],
})
}
} as Command
},
} as Command

View File

@@ -1,4 +1,8 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { Command } from "../interfaces"
export = {
@@ -15,29 +19,39 @@ export = {
option
.setName("user")
.setDescription("The user to set the nickname for")
.setRequired(true))
.setRequired(true),
)
.addStringOption(option =>
option
.setName("nickname")
.setDescription("The nickname to set")
.setRequired(true))
.setRequired(true),
)
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames)
.setDMPermission(false),
async execute(interaction) {
const user = interaction.options.getUser("user")!
const nickname = interaction.options.getString("nickname")
const member = await interaction.guild!.members.fetch(user.id)
if (!member.manageable) {
interaction.reply({ content: "I cannot set the nickname for this user!", ephemeral: true })
interaction.reply({
content: "I cannot set the nickname for this user!",
ephemeral: true,
})
return
}
await member.setNickname(nickname, `Set by ${interaction.user.tag}`)
await interaction.reply({ content: "Set the nickname of " + userMention(member.id) + " to " + nickname, ephemeral: true })
}
} as Command
await interaction.reply({
content:
"Set the nickname of " +
userMention(member.id) +
" to " +
nickname,
ephemeral: true,
})
},
} as Command

View File

@@ -1,4 +1,12 @@
import { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, ChannelType, GuildTextBasedChannel } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
ChannelType,
GuildTextBasedChannel,
} from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
@@ -13,52 +21,71 @@ export = {
data: new SlashCommandBuilder()
.setName("setup")
.setDescription("Configure the bot.")
.addSubcommand((subcommand) =>
.addSubcommand(subcommand =>
subcommand
.setName("sendguildapplication")
.setDescription("Send the application message to a channel.")
.addChannelOption((option) =>
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to send the application to.")
.setRequired(true))
.setDescription(
"The channel to send the application to.",
)
.setRequired(true),
),
)
.addSubcommand((subcommand) =>
.addSubcommand(subcommand =>
subcommand
.setName("sendstaffapplication")
.setDescription("Send the application message to a channel.")
.addChannelOption((option) =>
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to send the application to.")
.setRequired(true)))
.addSubcommand((subcommand) =>
.setDescription(
"The channel to send the application to.",
)
.setRequired(true),
),
)
.addSubcommand(subcommand =>
subcommand
.setName("sendverfiymessage")
.setDescription("Send the verfiy message to a channel.")
.addChannelOption((option) =>
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to send the verfiy message to.")
.setRequired(true)))
.addSubcommand((subcommand) =>
.setDescription(
"The channel to send the verfiy message to.",
)
.setRequired(true),
),
)
.addSubcommand(subcommand =>
subcommand
.setName("sendwaitinglistmessage")
.setDescription("Send the waiting list message to a channel.")
.addChannelOption((option) =>
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to send the waiting list message to.")
.setRequired(true)))
.addSubcommand((subcommand) =>
.setDescription(
"The channel to send the waiting list message to.",
)
.setRequired(true),
),
)
.addSubcommand(subcommand =>
subcommand
.setName("sendinactivityapplication")
.setDescription("Send the application message to a channel.")
.addChannelOption((option) =>
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to send the application to.")
.setRequired(true)))
.setDescription(
"The channel to send the application to.",
)
.setRequired(true),
),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
@@ -66,49 +93,65 @@ export = {
const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x"))
if (subcommand === "sendguildapplication") {
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [{
title: "Guild Application",
description: "You can apply for the guild by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
embeds: [
{
title: "Guild Application",
description:
"You can apply for the guild by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
thumbnail: {
url:
interaction.guild!.iconURL({
forceStatic: false,
}) || "",
},
},
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false }) || ""
}
}],
],
components: [
new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("guildapply")
.setLabel("Apply")
.setStyle(ButtonStyle.Primary)
.setEmoji({ name: "✅" })
)
]
.setEmoji({ name: "✅" }),
),
],
})
await interaction.reply({
content: "Message sent",
ephemeral: true,
})
await interaction.reply({ content: "Message sent", ephemeral: true })
}
if (subcommand === "sendstaffapplication") {
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
@@ -118,35 +161,47 @@ export = {
embeds: [
{
title: "Staff Application",
description: "You can apply for the staff team by clicking the button below.",
description:
"You can apply for the staff team by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}
url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
components: [
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("staffapply")
.setLabel("Apply")
.setStyle(ButtonStyle.Primary)
.setEmoji({ name: "✅" }))
]
.setEmoji({ name: "✅" }),
),
],
})
await interaction.reply({ content: "Message sent", ephemeral: true })
await interaction.reply({
content: "Message sent",
ephemeral: true,
})
}
if (subcommand === "sendinactivityapplication") {
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
@@ -156,101 +211,136 @@ export = {
embeds: [
{
title: "Inactivity Log",
description: "You can send an inactivity log by clicking the button below.",
description:
"You can send an inactivity log by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}
url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
components: [
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("guildinactivitylog")
.setLabel("Submit")
.setStyle(ButtonStyle.Primary)
.setEmoji({ name: "✅" }))
]
.setEmoji({ name: "✅" }),
),
],
})
await interaction.reply({ content: "Message sent", ephemeral: true })
await interaction.reply({
content: "Message sent",
ephemeral: true,
})
}
if (subcommand === "sendverfiymessage") {
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [{
title: "Verification",
description: "You can verify by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
embeds: [
{
title: "Verification",
description:
"You can verify by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
thumbnail: {
url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}],
],
components: [
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("verify")
.setLabel("Verify")
.setStyle(ButtonStyle.Primary)
.setEmoji({ name: "✅" }))
]
.setEmoji({ name: "✅" }),
),
],
})
await interaction.reply({
content: "Message sent",
ephemeral: true,
})
await interaction.reply({ content: "Message sent", ephemeral: true })
}
if (subcommand === "sendwaitinglistmessage") {
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
await interaction.reply({
content: "That channel is not a text channel.",
ephemeral: true,
})
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [{
title: "Waiting List",
description: "The people below were accepted into the guild\n" +
"Try to invite them in order.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
embeds: [
{
title: "Waiting List",
description:
"The people below were accepted into the guild\n" +
"Try to invite them in order.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
thumbnail: {
url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}],
],
components: [
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("waitinglistupdate")
.setLabel("Update")
.setStyle(ButtonStyle.Primary)
.setEmoji({ name: "🔄" }))
]
.setEmoji({ name: "🔄" }),
),
],
})
await interaction.reply({
content: "Message sent",
ephemeral: true,
})
await interaction.reply({ content: "Message sent", ephemeral: true })
}
}
} as Command
},
} as Command

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, GuildTextBasedChannel } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
ChannelType,
GuildTextBasedChannel,
} from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
@@ -15,32 +20,42 @@ export = {
.addIntegerOption(option =>
option
.setName("seconds")
.setDescription("The amount of seconds to set the slowmode to."))
.setDescription(
"The amount of seconds to set the slowmode to.",
),
)
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to set the slowmode of."))
.setDescription("The channel to set the slowmode of."),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const seconds = interaction.options.getInteger("seconds") ?? 5
const channel2 = interaction.options.getChannel("channel") ?? interaction.channel
const channel2 =
interaction.options.getChannel("channel") ?? interaction.channel
const embedColor = Number(color.replace("#", "0x"))
if (channel2?.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [{
description: "You can only set the slowmode of a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
embeds: [
{
description:
"You can only set the slowmode of a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
},
],
})
return
}
@@ -50,29 +65,37 @@ export = {
if (seconds > 21600) {
await channel.setRateLimitPerUser(21600)
await interaction.editReply({
embeds: [{
description: `Set the slowmode of ${channel} to 21600 seconds.`,
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
embeds: [
{
description: `Set the slowmode of ${channel} to 21600 seconds.`,
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({
forceStatic: false,
}) || undefined,
},
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: `Set the slowmode of ${channel} to ${seconds} seconds.`,
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: true }) || undefined
}
}]
embeds: [
{
description: `Set the slowmode of ${channel} to ${seconds} seconds.`,
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({ forceStatic: true }) ||
undefined,
},
},
],
})
await channel.setRateLimitPerUser(seconds)
}
} as Command
},
} as Command

View File

@@ -1,7 +1,7 @@
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
import { help} from "./staff/help"
import { help } from "./staff/help"
import { beast } from "./staff/beast"
import { updateDiscordRoles } from "./staff/updatediscordroles"
@@ -19,7 +19,8 @@ export = {
.addSubcommand(subcommand =>
subcommand
.setName("help")
.setDescription("Get help with staff commands"))
.setDescription("Get help with staff commands"),
)
.addSubcommand(subcommand =>
subcommand
.setName("beast")
@@ -28,19 +29,20 @@ export = {
option
.setName("ign")
.setDescription("The IGN of the player.")
.setRequired(true)
)
.setRequired(true),
),
)
.addSubcommand(subcommand =>
subcommand
.setName("updatediscordroles")
.setDescription("Update the discord roles of all guild members")
.setDescription(
"Update the discord roles of all guild members",
),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction, client) {
const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x"))
@@ -59,18 +61,24 @@ export = {
return
}
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.reply({
embeds: [{
description: "This command is currently under development",
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!
}
}]
embeds: [
{
description: "This command is currently under development",
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!,
},
},
],
})
}
} as Command
},
} as Command

View File

@@ -1,9 +1,27 @@
import { bwwins, beastbwfkdr, beastbwstars, beastswkdr, beastswstars, beastduelswins, duelswlr } from "../../../config/reqs.json"
import {
bwwins,
beastbwfkdr,
beastbwstars,
beastswkdr,
beastswstars,
beastduelswins,
duelswlr,
} from "../../../config/reqs.json"
import { color, devMessage } from "../../../config/options.json"
import { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild, getHeadURL } from "../../utils/Hypixel"
import {
hypixelLevel,
bedwarsLevel,
skywarsLevel,
getUUID,
getPlayer,
getGuild,
getHeadURL,
} from "../../utils/Hypixel"
import { ChatInputCommandInteraction } from "discord.js"
export async function beast(interaction: ChatInputCommandInteraction): Promise<void> {
export async function beast(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const ign = interaction.options.getString("ign")!
@@ -15,37 +33,46 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
}
await interaction.editReply({
embeds: [{
description: "Fetching your uuid...",
color: embedColor
}]
embeds: [
{
description: "Fetching your uuid...",
color: embedColor,
},
],
})
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [
{ description: "That player doesn't exist.", color: embedColor }
]
{
description: "That player doesn't exist.",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your player data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your player data...",
color: embedColor,
},
],
})
const head = await getHeadURL(ign)
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
description: "That player hasn't played Hypixel before.",
color: embedColor
}]
embeds: [
{
description: "That player hasn't played Hypixel before.",
color: embedColor,
},
],
})
return
}
@@ -67,10 +94,12 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
}
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
const guild = await getGuild(uuid)
@@ -95,7 +124,7 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
if (!player.stats) {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played any games.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
} else {
if (player.stats.Bedwars) {
@@ -107,7 +136,11 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
const hsbwwins = player.stats.Bedwars.wins_bedwars || 0
let bwtitle = ""
if (hsbwstars < beastbwstars || hsbwfkdr < beastbwfkdr || hsbwwins < bwwins) {
if (
hsbwstars < beastbwstars ||
hsbwfkdr < beastbwfkdr ||
hsbwwins < bwwins
) {
bwtitle =
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
} else {
@@ -117,20 +150,27 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
statsFields.push({
name: bwtitle,
value: "**➺ Stars:** `" +
hsbwstars.toFixed(2).toString() + " / " +
beastbwstars.toString() + "`\n" +
value:
"**➺ Stars:** `" +
hsbwstars.toFixed(2).toString() +
" / " +
beastbwstars.toString() +
"`\n" +
"**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() +
" / " + beastbwfkdr.toString() + "`\n" +
" / " +
beastbwfkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsbwwins.toString() + " / " +
bwwins.toString() + "`"
hsbwwins.toString() +
" / " +
bwwins.toString() +
"`",
})
} else {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played BedWars.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
}
@@ -153,19 +193,25 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
statsFields.push({
name: swtitle,
value: "**➺ Stars:** `" +
hsswstars.toFixed(2).toString() + " / " +
beastswstars.toString() + "`\n" +
value:
"**➺ Stars:** `" +
hsswstars.toFixed(2).toString() +
" / " +
beastswstars.toString() +
"`\n" +
"**➺ KDR:** `" +
hsswkd.toFixed(2).toString() + " / " +
beastswkdr.toString() + "`\n" +
hsswkd.toFixed(2).toString() +
" / " +
beastswkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsswwins.toString() + "`"
hsswwins.toString() +
"`",
})
} else {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played SkyWars.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
}
@@ -190,18 +236,23 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
name: duelstitle,
value:
"**➺ Wins:** `" +
hsduelswins.toString() + " / " +
beastduelswins.toString() + "`\n" +
hsduelswins.toString() +
" / " +
beastduelswins.toString() +
"`\n" +
"**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() + " / " +
duelswlr.toString() + "`\n" +
hsduelswlr.toFixed(2).toString() +
" / " +
duelswlr.toString() +
"`\n" +
"**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() + "`\n"
hsduelskd.toFixed(2).toString() +
"`\n",
})
} else {
statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played Duels.",
value: "**➺ Stats:** `None`"
value: "**➺ Stats:** `None`",
})
}
}
@@ -210,24 +261,34 @@ export async function beast(interaction: ChatInputCommandInteraction): Promise<v
const hypixelExp = player.networkExp || 0
const level = hypixelLevel(hypixelExp)
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
title: rank + player.displayname + guildTag,
description: "**Network Level:** `" +
level.toFixed(2).toString() + "`\n" +
"**Current Guild:** `" + guildName + "`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
title: rank + player.displayname + guildTag,
description:
"**Network Level:** `" +
level.toFixed(2).toString() +
"`\n" +
"**Current Guild:** `" +
guildName +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!,
},
fields: statsFields,
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon!
},
fields: statsFields
}]
],
})
}
}

View File

@@ -2,18 +2,21 @@ import { ChatInputCommandInteraction } from "discord.js"
import { color, devMessage } from "../../../config/options.json"
import { ExtendedClient as Client } from "../../utils/Client"
export async function help(interaction: ChatInputCommandInteraction, client: Client): Promise<void> {
export async function help(
interaction: ChatInputCommandInteraction,
client: Client,
): Promise<void> {
await interaction.deferReply({ ephemeral: true })
type CommandList = {
name: string,
name: string
value: string
}
const commandList: CommandList[] = []
const commandRawList = client.commands.map((command) => {
const commandRawList = client.commands.map(command => {
return {
name: command.name,
command: command
command: command,
}
})
@@ -23,43 +26,48 @@ export async function help(interaction: ChatInputCommandInteraction, client: Cli
if (!command.command.subcommands && !command.command.public) {
commandList.push({
name: "**/" + commandName + "**",
value: "`" + command.command.description + "`"
value: "`" + command.command.description + "`",
})
} else if (command.command.subcommands && !command.command.public) {
const subcommands = command.command.data.options.map((subcommand) => {
const subcommands = command.command.data.options.map(subcommand => {
return {
name: commandName + " " + subcommand.toJSON().name,
description: subcommand.toJSON().description
description: subcommand.toJSON().description,
}
})
for (const subcommand of subcommands) {
commandList.push({
name: "**/" + subcommand.name + "**",
value: "`" + subcommand.description + "`"
value: "`" + subcommand.description + "`",
})
}
}
}
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
embeds: [
{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!,
},
footer: {
icon_url: footerIcon!,
text: footerText + " | " + devMessage,
},
},
footer: {
icon_url: footerIcon!,
text: footerText + " | " + devMessage
}
}],
],
})
}
}

View File

@@ -1,19 +1,33 @@
import verify = require("../../schemas/verifySchema")
import { color, hypixelGuildID } from "../../../config/options.json"
import { admin, gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../../config/roles.json"
import {
admin,
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../../config/roles.json"
const removeThese = [gm, manager, beast, elite, member, guildRole, guildStaff]
import { getGuild } from "../../utils/Hypixel"
import { ChatInputCommandInteraction, GuildMember } from "discord.js"
import { GuildData } from "../../interfaces/Guild"
export async function updateDiscordRoles(interaction: ChatInputCommandInteraction): Promise<void> {
export async function updateDiscordRoles(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const user = interaction.member as GuildMember
if (!user.roles.cache.has(admin)) {
await interaction.editReply("You do not have permission to use this command.")
await interaction.editReply(
"You do not have permission to use this command.",
)
return
}
@@ -22,13 +36,13 @@ export async function updateDiscordRoles(interaction: ChatInputCommandInteractio
const memberList = guildMembers.map(member => {
return {
id: member.user.id,
member: member
member: member,
}
})
for (const guildMember of memberList) {
const memberData = await verify.findOne({
userID: guildMember.id
userID: guildMember.id,
})
if (!memberData) {
@@ -51,41 +65,106 @@ export async function updateDiscordRoles(interaction: ChatInputCommandInteractio
const hypixelGuildMember = isGuildMember as unknown as GuildData
const guildId = hypixelGuildMember!._id
const guildRank = hypixelGuildMember!.members!.find(member => member.uuid === memberData.uuid)!.rank
const guildRank = hypixelGuildMember!.members!.find(
member => member.uuid === memberData.uuid,
)!.rank
if (guildId === hypixelGuildID) {
if (guildRank === "Guild Master") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(guildStaff, "All users updated forcefully by staff")
guildMember.member.roles.add(gm, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
guildStaff,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
gm,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Manager") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(guildStaff, "All users updated forcefully by staff")
guildMember.member.roles.add(manager, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
guildStaff,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
manager,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Moderator") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(guildStaff, "All users updated forcefully by staff")
guildMember.member.roles.add(moderator, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
guildStaff,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
moderator,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Beast") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(beast, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
beast,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Elite") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(elite, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
elite,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Member") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(member, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
member,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
} else {
for (const role of removeThese) {
@@ -96,13 +175,17 @@ export async function updateDiscordRoles(interaction: ChatInputCommandInteractio
}
interaction.editReply({
embeds: [{
color: embedColor,
description: "Successfully updated all users.",
footer: {
text: interaction.guild!.name,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
embeds: [
{
color: embedColor,
description: "Successfully updated all users.",
footer: {
text: interaction.guild!.name,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
})
}
}

View File

@@ -1,4 +1,10 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, ChatInputCommandInteraction, GuildMember } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
ChatInputCommandInteraction,
GuildMember,
} from "discord.js"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
import ms from "ms"
@@ -17,26 +23,29 @@ const command: Command = {
option
.setName("user")
.setDescription("The user to timeout")
.setRequired(true))
.setRequired(true),
)
.addStringOption(option =>
option
.setName("time")
.setDescription("The time to timeout the user for")
.setRequired(true))
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription("The reason for the timeout"))
.setDescription("The reason for the timeout"),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction: ChatInputCommandInteraction) {
await interaction.deferReply()
const target = interaction.options.getMember("user")! as GuildMember
const timeString = interaction.options.getString("time")!
const reason = interaction.options.getString("reason") || "No reason provided"
const reason =
interaction.options.getString("reason") || "No reason provided"
const mod = interaction.member! as GuildMember
const embedColor = Number(color.replace("#", "0x"))
const time = ms(timeString)
@@ -45,50 +54,65 @@ const command: Command = {
if (target.user.bot) {
interaction.editReply({
embeds: [{
description: "You cannot timeout a bot.",
color: embedColor,
}]
embeds: [
{
description: "You cannot timeout a bot.",
color: embedColor,
},
],
})
return
}
if (target.id == interaction.guild!.ownerId) {
await interaction.editReply({
embeds: [{
description: "You cannot timeout the server owner.",
color: embedColor,
}]
embeds: [
{
description: "You cannot timeout the server owner.",
color: embedColor,
},
],
})
return
}
if (interaction.guild!.members.me!.roles.highest.position <= target.roles.highest.position) {
if (
interaction.guild!.members.me!.roles.highest.position <=
target.roles.highest.position
) {
interaction.editReply({
embeds: [{
description: "I cannot timeout this user because their role is higher than mine.",
color: embedColor,
}]
embeds: [
{
description:
"I cannot timeout this user because their role is higher than mine.",
color: embedColor,
},
],
})
return
}
if (mod.roles.highest.position <= target.roles.highest.position) {
await interaction.editReply({
embeds: [{
description: "You cannot timeout this user because their role is higher than yours.",
color: embedColor,
}]
embeds: [
{
description:
"You cannot timeout this user because their role is higher than yours.",
color: embedColor,
},
],
})
return
}
if (target.id == interaction.user.id) {
interaction.editReply({
embeds: [{
description: "You cannot timeout yourself.",
color: embedColor,
}]
embeds: [
{
description: "You cannot timeout yourself.",
color: embedColor,
},
],
})
return
}
@@ -97,47 +121,69 @@ const command: Command = {
if (time === 0) {
await target.timeout(null, reason)
await interaction.editReply({
embeds: [{
description: "Removed timeout of " + userMention(target.id) + " for " + reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined
embeds: [
{
description:
"Removed timeout of " +
userMention(target.id) +
" for " +
reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
},
timestamp: new Date().toISOString()
}]
],
})
return
}
await target.timeout(time, reason)
await interaction.editReply({
embeds: [{
description: "Updated timeout of " + userMention(target.id) + " to " + prettyTime + " for " + reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined
embeds: [
{
description:
"Updated timeout of " +
userMention(target.id) +
" to " +
prettyTime +
" for " +
reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
},
timestamp: new Date().toISOString()
}]
],
})
return
}
await target.timeout(time, reason)
await interaction.editReply({
embeds: [{
description: "Timed out " + userMention(target.id) + " for " + prettyTime + " for " + reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined
embeds: [
{
description:
"Timed out " +
userMention(target.id) +
" for " +
prettyTime +
" for " +
reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
},
timestamp: new Date().toISOString()
}]
],
})
}
},
}
export = command
export = command

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, User } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
User,
} from "discord.js"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
@@ -17,13 +22,13 @@ export = {
.setName("user")
.setDescription("The user to unban")
.setAutocomplete(true)
.setRequired(true)
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription("The reason for unbanning the user")
.setRequired(false)
.setRequired(false),
)
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.setDMPermission(false),
@@ -32,17 +37,20 @@ 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
if (userid === "none") {
await interaction.editReply({
embeds: [{
description: "You haven't specified a user to unban",
color: embedColor
}]
embeds: [
{
description: "You haven't specified a user to unban",
color: embedColor,
},
],
})
return
}
@@ -51,31 +59,43 @@ export = {
user = await interaction.client.users.fetch(userid)
} catch (error) {
await interaction.editReply({
embeds: [{
description: "The user you specified is not valid",
color: embedColor
}]
embeds: [
{
description: "The user you specified is not valid",
color: embedColor,
},
],
})
}
await interaction.guild!.members.unban(user!.id, reason)
await interaction.editReply({
embeds: [{
title: "User unbanned",
description: "The user " + user!.username + " has been unbanned.\n" +
"**Reason:** `" + reason + "`\n" +
"**Moderator:** " + userMention(mod.id),
color: embedColor,
thumbnail: {
url: user!.avatarURL({ forceStatic: false }) || ""
embeds: [
{
title: "User unbanned",
description:
"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,
})!,
},
timestamp: new Date().toISOString(),
},
footer: {
text: "ID: " + user!.id,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
timestamp: new Date().toISOString()
}]
],
})
}
} as Command
},
} as Command

View File

@@ -2,9 +2,28 @@ import { GuildMember, SlashCommandBuilder } from "discord.js"
import { getGuild, getIGN, getHeadURL } from "../utils/Hypixel"
import verify = require("../schemas/verifySchema")
import { color, hypixelGuildID, devMessage } from "../../config/options.json"
import { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../config/roles.json"
import {
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../config/roles.json"
import { Command } from "../interfaces"
const removeThese = [gm, manager, moderator, beast, elite, member, guildRole, guildStaff]
const removeThese = [
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
]
export = {
name: "update",
@@ -19,7 +38,6 @@ export = {
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const user = interaction.member as GuildMember
@@ -29,23 +47,30 @@ export = {
if (!verifyData) {
await interaction.editReply({
embeds: [{
description: "You are not verified. Please run `/verify` to verify yourself",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
embeds: [
{
description:
"You are not verified. Please run `/verify` to verify yourself",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor,
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
const guild = await getGuild(verifyData.uuid)
@@ -56,199 +81,277 @@ export = {
guildID = guild._id
}
const ign = await getIGN(verifyData.uuid) as string
const ign = (await getIGN(verifyData.uuid)) as string
const head = await getHeadURL(ign)
if (guildID !== hypixelGuildID) {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Update)",
)
}
await roleManage.add(defaultMember, "User used the update command")
await interaction.editReply({
embeds: [{
description: "Updated your roles to `Default Member`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description: "Updated your roles to `Default Member`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
return
}
if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid)!.rank
const guildRank = GuildMembers.find(
member => member.uuid === verifyData.uuid,
)!.rank
if (guildRank === "Guild Master") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Update)",
)
}
await roleManage.add(guildRole, "User used the update command")
await roleManage.add(guildStaff, "User used the update command")
await roleManage.add(gm, "User used the update command")
await roleManage.add(defaultMember, "User used the update command")
await roleManage.add(
defaultMember,
"User used the update command",
)
await interaction.editReply({
embeds: [{
description: "Your rank has been updated to `Guild Master`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
"Your rank has been updated to `Guild Master`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
}
if (guildRank === "Manager") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Update)",
)
}
await roleManage.add(guildRole, "User used the update command")
await roleManage.add(guildStaff, "User used the update command")
await roleManage.add(manager, "User used the update command")
await roleManage.add(defaultMember, "User used the update command")
await roleManage.add(
defaultMember,
"User used the update command",
)
await interaction.editReply({
embeds: [{
description: "Your rank has been updated to `Manager`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
"Your rank has been updated to `Manager`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
}
if (guildRank === "Moderator") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Update)",
)
}
await roleManage.add(guildRole, "User used the update command")
await roleManage.add(guildStaff, "User used the update command")
await roleManage.add(moderator, "User used the update command")
await roleManage.add(defaultMember, "User used the update command")
await roleManage.add(
defaultMember,
"User used the update command",
)
await interaction.editReply({
embeds: [{
description: "Your rank has been updated to `Moderator`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
"Your rank has been updated to `Moderator`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
}
if (guildRank === "Beast") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Update)",
)
}
await roleManage.add(guildRole, "User used the update command")
await roleManage.add(beast, "User used the update command")
await roleManage.add(defaultMember, "User used the update command")
await roleManage.add(
defaultMember,
"User used the update command",
)
await interaction.editReply({
embeds: [{
description: "Your rank has been updated to `Beast`.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
"Your rank has been updated to `Beast`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
return
}
if (guildRank === "Elite") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Update)",
)
}
await roleManage.add(guildRole, "User used the update command")
await roleManage.add(elite, "User used the update command")
await roleManage.add(defaultMember, "User used the update command")
await roleManage.add(
defaultMember,
"User used the update command",
)
await interaction.editReply({
embeds: [{
description: "Your rank has been updated to `Elite`.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
"Your rank has been updated to `Elite`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
return
}
if (guildRank === "Member") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
await roleManage.remove(
removeThese[i],
"Auto role removal. (Update)",
)
}
await roleManage.add(guildRole, "User used the update command")
await roleManage.add(member, "User used the update command")
await roleManage.add(defaultMember, "User used the update command")
await roleManage.add(
defaultMember,
"User used the update command",
)
await interaction.editReply({
embeds: [{
description: "Your rank has been updated to `Member`.",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
description:
"Your rank has been updated to `Member`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text:
interaction.guild!.name +
" | " +
devMessage,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
],
})
return
}
}
}
} as Command
},
} as Command

View File

@@ -13,48 +13,62 @@ export = {
data: new SlashCommandBuilder()
.setName("uuid")
.setDescription("Get a player's UUID")
.addStringOption(option => option
.setName("ign")
.setDescription("Player's name")
.setRequired(true)),
.addStringOption(option =>
option
.setName("ign")
.setDescription("Player's name")
.setRequired(true),
),
async execute(interaction) {
await interaction.deferReply()
const ign = interaction.options.getString("ign")!
const uuid = await getUUID(ign) as string
const uuid = (await getUUID(ign)) as string
const formattedUuid = formatUuid(uuid)
const newIgn = await getIGN(uuid) as string
const newIgn = (await getIGN(uuid)) as string
const head = await getHeadURL(ign)
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
if (!uuid) {
interaction.editReply({
embeds: [{
description: "That player doesn't exist!",
color: embedColor
}]
embeds: [
{
description: "That player doesn't exist!",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
title: newIgn,
description: "**UUID:** `" + uuid + "`\n" +
"**Formatted UUID:** `" + formattedUuid + "`",
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
title: newIgn,
description:
"**UUID:** `" +
uuid +
"`\n" +
"**Formatted UUID:** `" +
formattedUuid +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon || undefined,
},
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon || undefined
}
}]
],
})
}
} as Command
},
} as Command

View File

@@ -2,7 +2,17 @@ import { SlashCommandBuilder } from "discord.js"
import { getUUID, getPlayer, getGuild, getHeadURL } from "../utils/Hypixel"
import { color, hypixelGuildID, devMessage } from "../../config/options.json"
import mongoose from "mongoose"
import { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../config/roles.json"
import {
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../config/roles.json"
import { Command } from "../interfaces"
import verify = require("../schemas/verifySchema")
import { PlayerData } from "../interfaces/Player"
@@ -18,11 +28,12 @@ export = {
data: new SlashCommandBuilder()
.setName("verify")
.setDescription("Verify yourself as a member of the server.")
.addStringOption((option) =>
.addStringOption(option =>
option
.setName("ign")
.setDescription("Your in-game name.")
.setRequired(true))
.setRequired(true),
)
.setDMPermission(false),
async execute(interaction) {
@@ -35,53 +46,69 @@ export = {
const verifyData = await verify.findOne({ userID: user.id })
if (verifyData) {
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
interaction.editReply(
"You are already verified.\n" +
"Try running /update to update your roles.",
)
return
}
if (!ign) {
interaction.editReply({
embeds: [{
description: "<a:cross_a:1087808606897983539> Please provide your in-game name.",
color: embedColor
}]
embeds: [
{
description:
"<a:cross_a:1087808606897983539> Please provide your in-game name.",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your uuid...",
color: embedColor
}]
embeds: [
{
description: "Fetching your uuid...",
color: embedColor,
},
],
})
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [{
description: "<a:questionmark_pink:1130206038008803488> That player does not exist.",
color: embedColor
}]
embeds: [
{
description:
"<a:questionmark_pink:1130206038008803488> That player does not exist.",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your player data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your player data...",
color: embedColor,
},
],
})
const head = await getHeadURL(ign)
const player = await getPlayer(uuid) as PlayerData
const player = (await getPlayer(uuid)) as PlayerData
if (!player) {
interaction.editReply({
embeds: [{
description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor
}]
embeds: [
{
description:
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor,
},
],
})
return
}
@@ -94,10 +121,12 @@ export = {
}
await interaction.editReply({
embeds: [{
description: "Checking your Discord tag...",
color: embedColor
}]
embeds: [
{
description: "Checking your Discord tag...",
color: embedColor,
},
],
})
const linkedDiscord = player.socialMedia.links.DISCORD || null
@@ -105,11 +134,16 @@ export = {
interaction.editReply({
embeds: [
{
description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + player.displayname + "`.\n\n" +
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
color: embedColor
}
]
description:
"<a:cross_a:1087808606897983539> There is no Discord account linked to `" +
player.displayname +
"`.\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
})
return
}
@@ -118,23 +152,32 @@ export = {
interaction.editReply({
embeds: [
{
description: "<a:cross_a:1087808606897983539> The Discord account linked to `" + player.displayname + "` is currently `" + linkedDiscord + "`\n\n" +
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
color: embedColor
}
]
description:
"<a:cross_a:1087808606897983539> The Discord account linked to `" +
player.displayname +
"` is currently `" +
linkedDiscord +
"`\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
description: "Fetching your guild data...",
color: embedColor
}]
embeds: [
{
description: "Fetching your guild data...",
color: embedColor,
},
],
})
const guild = await getGuild(uuid) as GuildData | null
const guild = (await getGuild(uuid)) as GuildData | null
let guildID: string | null
if (!guild) {
guildID = null
@@ -143,9 +186,10 @@ export = {
}
if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members
const guildRank = GuildMembers.find((member) => member.uuid === player.uuid)!.rank
const guildRank = GuildMembers.find(
member => member.uuid === player.uuid,
)!.rank
if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
await user.roles.add(gm, "Verification")
@@ -186,7 +230,7 @@ export = {
const newVerify = new verify({
_id: new mongoose.Types.ObjectId(),
userID: user.id,
uuid: uuid
uuid: uuid,
})
await newVerify.save()
@@ -195,17 +239,22 @@ export = {
embeds: [
{
title: interaction.guild!.name,
description: "You have successfully verified `" + username + "` with the account `" + player.displayname + "`.",
description:
"You have successfully verified `" +
username +
"` with the account `" +
player.displayname +
"`.",
color: embedColor,
thumbnail: {
url: head || ""
url: head || "",
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}
]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
})
}
} as Command
},
} as Command

View File

@@ -1,4 +1,8 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { getIGN, getHeadURL } from "../utils/Hypixel"
import { color, devMessage } from "../../config/options.json"
import verify = require("../schemas/verifySchema")
@@ -18,12 +22,12 @@ export = {
option
.setName("user")
.setDescription("The user to get the ign of.")
.setRequired(true))
.setRequired(true),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction) {
await interaction.deferReply()
const user = interaction.options.getUser("user")!
@@ -31,27 +35,36 @@ export = {
const verifiedUser = await verify.findOne({ userID: user.id })
if (!verifiedUser) {
interaction.editReply({ content: "This user has not verified their account." })
interaction.editReply({
content: "This user has not verified their account.",
})
return
}
const ign = await getIGN(verifiedUser.uuid) as string
const ign = (await getIGN(verifiedUser.uuid)) as string
const head = await getHeadURL(ign)
await interaction.editReply({
embeds: [{
title: interaction.guild!.name,
description: "**User:** " + userMention(user.id) + "\n**IGN:** " + ign,
color: embedColor,
thumbnail: {
url: head!
embeds: [
{
title: interaction.guild!.name,
description:
"**User:** " +
userMention(user.id) +
"\n**IGN:** " +
ign,
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url:
interaction.guild!.iconURL({ forceStatic: true }) ||
undefined,
},
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: true }) || undefined
}
}]
],
})
}
} as Command
},
} as Command