Merge branch 'dev' into 'main'

Fixed formatting

See merge request illegitimate/illegitimate-bot!183
This commit is contained in:
2024-01-20 23:36:28 +00:00
102 changed files with 2733 additions and 4515 deletions

View File

@@ -11,9 +11,8 @@ scripts
.eslintrc.js .eslintrc.js
.gitignore .gitignore
.gitlab-ci.yml .gitlab-ci.yml
.prettierrc.js
docker-compose.yml docker-compose.yml
Dockerfile Dockerfile
Dockerfile.cache Dockerfile.cache
nodemon-js.json nodemon-js.json
nodemon.json nodemon.json

View File

@@ -1,75 +1,59 @@
module.exports = { module.exports = {
"env": { env: {
"node": true, node: true,
"es2021": true, es2021: true,
"browser": true browser: true,
}, },
"extends": [ extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"eslint:recommended", overrides: [
"plugin:@typescript-eslint/recommended"
],
"overrides": [
{ {
"env": { env: {
"node": true node: true,
}, },
"files": [ files: [".eslintrc.{js,cjs}"],
".eslintrc.{js,cjs}" parserOptions: {
], sourceType: "script",
"parserOptions": { },
"sourceType": "script" },
}
}
], ],
"parser": "@typescript-eslint/parser", parser: "@typescript-eslint/parser",
"parserOptions": { parserOptions: {
"ecmaVersion": "latest", ecmaVersion: "latest",
"sourceType": "module" sourceType: "module",
}, },
"plugins": [ plugins: ["@typescript-eslint"],
"@typescript-eslint" rules: {
], indent: ["error", 4, { SwitchCase: 1 }],
"rules": { "linebreak-style": ["error", "windows"],
"indent": [ quotes: ["warn", "double"],
"error", semi: ["error", "never"],
4
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"warn",
"double"
],
"semi": [
"error",
"never"
],
"no-unused-vars": "off", "no-unused-vars": "off",
"prefer-const": "warn", "prefer-const": "warn",
"no-var": "error", "no-var": "error",
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }], "no-multiple-empty-lines": ["error", { max: 2, maxEOF: 1, maxBOF: 0 }],
"no-lonely-if": "error", "no-lonely-if": "error",
"no-empty-function": "error", "no-empty-function": "error",
"no-inline-comments": "error", "no-inline-comments": "error",
"no-trailing-spaces": ["error"], "no-trailing-spaces": ["error"],
"arrow-spacing": ["warn", { "before": true, "after": true }], "arrow-spacing": ["warn", { before: true, after: true }],
"space-before-function-paren": ["error", { "space-before-function-paren": [
"anonymous": "never", "error",
"named": "never", {
"asyncArrow": "always" anonymous: "never",
}], named: "never",
asyncArrow: "always",
},
],
"comma-spacing": "error", "comma-spacing": "error",
"@typescript-eslint/no-var-requires": "off", "@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
"warn", "warn",
{ {
"vars": "all", vars: "all",
"args": "after-used", args: "after-used",
"ignoreRestSiblings": false ignoreRestSiblings: false,
} },
], ],
} },
} }

View File

@@ -1 +0,0 @@
src/config/

View File

@@ -1,17 +0,0 @@
/** @type { import('prettier').Config } */
const config = {
printWidth: 80,
tabWidth: 4,
useTabs: false,
semi: false,
singleQuote: false,
quoteProps: "as-needed",
trailingComma: "all",
bracketSpacing: true,
arrowParens: "avoid",
parser: "typescript",
endOfLine: "crlf"
}
module.exports = config

View File

@@ -11,7 +11,6 @@
"dev:js": "nodemon --config nodemon-js.json dist/index.js", "dev:js": "nodemon --config nodemon-js.json dist/index.js",
"dev:build": "ts-node scripts/dev-deploy.ts", "dev:build": "ts-node scripts/dev-deploy.ts",
"dev:delete": "ts-node scripts/delete-commands.ts", "dev:delete": "ts-node scripts/delete-commands.ts",
"format": "prettier --write src/",
"lint": "eslint src", "lint": "eslint src",
"lint:fix": "eslint --fix src", "lint:fix": "eslint --fix src",
"prod:build": "ts-node scripts/deploy-commands.ts" "prod:build": "ts-node scripts/deploy-commands.ts"
@@ -35,7 +34,6 @@
"@typescript-eslint/eslint-plugin": "^6.18.1", "@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1", "@typescript-eslint/parser": "^6.18.1",
"eslint": "^8.56.0", "eslint": "^8.56.0",
"prettier": "^3.2.1",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember, } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { admin, helper } from "config/roles.json" import { admin, helper } from "config/roles.json"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
@@ -22,10 +17,12 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("User to ban") .setDescription("User to ban")
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option.setName("reason").setDescription("Reason for ban"), option
.setName("reason")
.setDescription("Reason for ban")
) )
.addNumberOption(option => .addNumberOption(option =>
option option
@@ -39,7 +36,7 @@ export = {
{ name: "5 days", value: 5 }, { name: "5 days", value: 5 },
{ name: "6 days", value: 6 }, { name: "6 days", value: 6 },
{ name: "7 days", value: 7 }, { name: "7 days", value: 7 },
), )
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -47,13 +44,9 @@ export = {
async execute(interaction) { async execute(interaction) {
await interaction.deferReply() await interaction.deferReply()
const member = interaction.options.getMember( const member = interaction.options.getMember("user") as GuildMember | null
"user", const reason = interaction.options.getString("reason") ?? "No reason provided."
) as GuildMember | null const messageDeletionDays = interaction.options.getNumber("messagedeletiondays") ?? 0
const reason =
interaction.options.getString("reason") ?? "No reason provided."
const messageDeletionDays =
interaction.options.getNumber("messagedeletiondays") ?? 0
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!member) { if (!member) {
@@ -66,16 +59,11 @@ export = {
const modRoles = mod.roles.cache.map(role => role.id) const modRoles = mod.roles.cache.map(role => role.id)
if (!modRoles.includes(admin)) { if (!modRoles.includes(admin)) {
await interaction.editReply( await interaction.editReply("You do not have permission to use this command.")
"You do not have permission to use this command.",
)
return return
} }
if ( if (interaction.guild!.members.me!.roles.highest.position <= member.roles.highest.position) {
interaction.guild!.members.me!.roles.highest.position <=
member.roles.highest.position
) {
await interaction.editReply("I cannot ban this member.") await interaction.editReply("I cannot ban this member.")
return return
} }
@@ -105,62 +93,48 @@ export = {
return return
} }
await member.ban({ await member.ban({ reason: reason, deleteMessageDays: messageDeletionDays })
reason: reason,
deleteMessageDays: messageDeletionDays,
})
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: mod.user.username,
name: mod.user.username, icon_url: mod.user.avatarURL() || undefined
icon_url: mod.user.avatarURL() || undefined, },
}, title: "Member Banned",
title: "Member Banned", description: `
description: `
**User:** ${userMention(member.user.id)} **User:** ${userMention(member.user.id)}
**Mod:** ${userMention(mod.user.id)} **Mod:** ${userMention(mod.user.id)}
**Reason:** ${reason} **Reason:** ${reason}
**Messages Deleted:** ${messageDeletionDays} days **Messages Deleted:** ${messageDeletionDays} days
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: mod.user.avatarURL() || "", url: mod.user.avatarURL() || ""
},
footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "Member Banned",
title: "Member Banned", description: "**User:** " + userMention(member.user.id) + "\n" +
description: "**Reason:** " + reason + "\n" +
"**User:** " + "**Messages Deleted:** " + messageDeletionDays + " days",
userMention(member.user.id) + color: embedColor,
"\n" + thumbnail: {
"**Reason:** " + url: member.user.avatarURL() || ""
reason +
"\n" +
"**Messages Deleted:** " +
messageDeletionDays +
" days",
color: embedColor,
thumbnail: {
url: member.user.avatarURL() || "",
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
}) })
}, },
} as Command } as Command

View File

@@ -1,23 +1,7 @@
import { SlashCommandBuilder } from "discord.js" import { SlashCommandBuilder } from "discord.js"
import { import { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "config/reqs.json"
bwfkdr,
bwstars,
bwwins,
swstars,
swkdr,
duelswins,
duelswlr,
} from "config/reqs.json"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { import { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
hypixelLevel,
bedwarsLevel,
skywarsLevel,
getUUID,
getPlayer,
getGuild,
getHeadURL,
} from "utils/Hypixel"
import { Command } from "interfaces" import { Command } from "interfaces"
export = { export = {
@@ -33,7 +17,7 @@ export = {
option option
.setName("ign") .setName("ign")
.setDescription("The player's IGN.") .setDescription("The player's IGN.")
.setRequired(true), .setRequired(true)
) )
.setDMPermission(false), .setDMPermission(false),
@@ -44,47 +28,38 @@ export = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your uuid...",
description: "Fetching your uuid...", color: embedColor
color: embedColor, }]
},
],
}) })
const uuid = await getUUID(ign) const uuid = await getUUID(ign)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player doesn't exist.",
description: "That player doesn't exist.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your player data...",
description: "Fetching your player data...", color: embedColor
color: embedColor, }]
},
],
}) })
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player hasn't played Hypixel before.",
description: color: embedColor
"That player hasn't played Hypixel before.", }]
color: embedColor,
},
],
}) })
return return
} }
@@ -106,12 +81,10 @@ export = {
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = await getGuild(uuid) const guild = await getGuild(uuid)
@@ -143,168 +116,121 @@ export = {
if (!player.stats) { if (!player.stats) {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played any games.", name: "<a:_warning:1178350183457751100> This player never played any games.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} else { } else {
if (player.stats.Bedwars) { if (player.stats.Bedwars) {
const hsbwexp = player.stats.Bedwars.Experience || 0 const hsbwexp = player.stats.Bedwars?.Experience || 0
const hsbwfk = player.stats.Bedwars?.final_kills_bedwars || 0
const hsbwfd = player.stats.Bedwars?.final_deaths_bedwars || 0
const hsbwwins = player.stats.Bedwars?.wins_bedwars || 0
const hsbwstars = bedwarsLevel(hsbwexp) const hsbwstars = bedwarsLevel(hsbwexp)
const hsbwfk = player.stats?.Bedwars?.final_kills_bedwars || 0
const hsbwfd = player.stats?.Bedwars?.final_deaths_bedwars || 0
const hsbwfkdr = hsbwfk / hsbwfd || 0 const hsbwfkdr = hsbwfk / hsbwfd || 0
const hsbwwins = player.stats.Bedwars.wins_bedwars || 0
let bwtitle = "" let bwtitle = ""
if ( if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
hsbwstars < bwstars || bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
hsbwfkdr < bwfkdr ||
hsbwwins < bwwins
) {
bwtitle =
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
} else { } else {
bwtitle = bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements."
"<a:check_a:1087808632172847134> This player meets the BedWars requirements."
} }
statsFields.push({ statsFields.push({
name: bwtitle, name: bwtitle,
value: value: "**➺ Stars:** `" + hsbwstars.toFixed(2).toString() +
"**➺ Stars:** `" + " / " + bwstars.toString() + "`\n" +
hsbwstars.toFixed(2).toString() + "**➺ FKDR:** `" + hsbwfkdr.toFixed(2).toString() +
" / " + " / " + bwfkdr.toString() + "`\n" +
bwstars.toString() + "**➺ Wins:** `" + hsbwwins.toString() +
"`\n" + " / " + bwwins.toString() + "`"
"**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() +
" / " +
bwfkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsbwwins.toString() +
" / " +
bwwins.toString() +
"`",
}) })
} else { } else {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played BedWars.", name: "<a:_warning:1178350183457751100> This player never played BedWars.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} }
if (player.stats.SkyWars) { if (player.stats.SkyWars) {
const hsswexp = player.stats?.SkyWars?.skywars_experience || 0 const hsswexp = player.stats.SkyWars?.skywars_experience || 0
const hsswkills = player.stats.SkyWars?.kills || 0
const hsswdeaths = player.stats.SkyWars?.deaths || 0
const hsswwins = player.stats.SkyWars?.wins || 0
const hsswstars = skywarsLevel(hsswexp) const hsswstars = skywarsLevel(hsswexp)
const hsswkills = player.stats?.SkyWars?.kills || 0
const hsswdeaths = player.stats?.SkyWars?.deaths || 0
const hsswkd = hsswkills / hsswdeaths || 0 const hsswkd = hsswkills / hsswdeaths || 0
const hsswwins = player.stats?.SkyWars?.wins || 0
let swtitle = "" let swtitle = ""
if (hsswstars < swstars || hsswkd < swkdr) { if (hsswstars < swstars || hsswkd < swkdr) {
swtitle = swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
} else { } else {
swtitle = swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
"<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
} }
statsFields.push({ statsFields.push({
name: swtitle, name: swtitle,
value: value: "**➺ Stars:** `" + hsswstars.toFixed(2).toString() +
"**➺ Stars:** `" + " / " + swstars.toString() + "`\n" +
hsswstars.toFixed(2).toString() + "**➺ KDR:** `" + hsswkd.toFixed(2).toString() +
" / " + " / " + swkdr.toString() + "`\n" +
swstars.toString() + "**➺ Wins:** `" + hsswwins.toString() + "`"
"`\n" +
"**➺ KDR:** `" +
hsswkd.toFixed(2).toString() +
" / " +
swkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsswwins.toString() +
"`",
}) })
} else { } else {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played SkyWars.", name: "<a:_warning:1178350183457751100> This player never played SkyWars.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} }
if (player.stats.Duels) { if (player.stats.Duels) {
const hsduelskills = player.stats?.Duels?.kills || 0 const hsduelskills = player.stats.Duels?.kills || 0
const hsduelsdeaths = player.stats?.Duels?.deaths || 0 const hsduelsdeaths = player.stats.Duels?.deaths || 0
const hsduelswins = player.stats.Duels?.wins || 0
const hsduelslosses = player.stats.Duels?.losses || 0
const hsduelskd = hsduelskills / hsduelsdeaths || 0 const hsduelskd = hsduelskills / hsduelsdeaths || 0
const hsduelswins = player.stats?.Duels?.wins || 0
const hsduelslosses = player.stats?.Duels?.losses || 0
const hsduelswlr = hsduelswins / hsduelslosses || 0 const hsduelswlr = hsduelswins / hsduelslosses || 0
let duelstitle = "" let duelstitle = ""
if (hsduelswins < duelswins || hsduelswlr < duelswlr) { if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
duelstitle = duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
} else { } else {
duelstitle = duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
"<a:check_a:1087808632172847134> This player meets the Duels requirements."
} }
statsFields.push({ statsFields.push({
name: duelstitle, name: duelstitle,
value: value: "**➺ Wins:** `" + hsduelswins.toString() +
"**➺ Wins:** `" + " / " + duelswins.toString() + "`\n" +
hsduelswins.toString() + "**➺ WLR:** `" + hsduelswlr.toFixed(2).toString() +
" / " + " / " + duelswlr.toString() + "`\n" +
duelswins.toString() + "**➺ KDR:** `" + hsduelskd.toFixed(2).toString() + "`",
"`\n" +
"**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() +
" / " +
duelswlr.toString() +
"`\n" +
"**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() +
"`\n",
}) })
} else { } else {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played Duels.", name: "<a:_warning:1178350183457751100> This player never played Duels.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} }
} }
// network level // network level
const hypixelExp = player.networkExp || 0 const hypixelExp = player?.networkExp || 0
const level = hypixelLevel(hypixelExp) const level = hypixelLevel(hypixelExp)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: rank + player.displayname + guildTag,
title: rank + player.displayname + guildTag, description: "**Network Level:** `" + level.toFixed(2).toString() + "`\n" +
description: "**Current Guild:** `" + guildName + "`\n" +
"**Network Level:** `" + "**Guild Rank:** `" + guildRank + "`",
level.toFixed(2).toString() + color: embedColor,
"`\n" + thumbnail: {
"**Current Guild:** `" + url: head!
guildName +
"`\n" +
"**Guild Rank:** `" +
guildRank +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
fields: statsFields,
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
},
fields: statsFields
}]
}) })
}, }
} as Command } as Command

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,8 +23,8 @@ export = {
option option
.setName("ign") .setName("ign")
.setDescription("The IGN of the player.") .setDescription("The IGN of the player.")
.setRequired(true), .setRequired(true)
), )
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -33,10 +33,8 @@ export = {
.addStringOption(option => .addStringOption(option =>
option option
.setName("query") .setName("query")
.setDescription( .setDescription("The query to search for. [Default: player]")
"The query to search for. [Default: player]", .setRequired(true)
)
.setRequired(true),
) )
.addStringOption(option => .addStringOption(option =>
option option
@@ -45,9 +43,9 @@ export = {
.addChoices( .addChoices(
{ name: "Guild Member", value: "ign" }, { name: "Guild Member", value: "ign" },
{ name: "Guild Name", value: "name" }, { name: "Guild Name", value: "name" },
{ name: "Guild Id", value: "id" }, { name: "Guild Id", value: "id" }
), )
), )
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -56,10 +54,8 @@ export = {
.addStringOption(option => .addStringOption(option =>
option option
.setName("query") .setName("query")
.setDescription( .setDescription("The query to search for. [Default: player]")
"The query to search for. [Default: player]", .setRequired(true)
)
.setRequired(true),
) )
.addStringOption(option => .addStringOption(option =>
option option
@@ -68,16 +64,14 @@ export = {
.addChoices( .addChoices(
{ name: "Guild Member", value: "ign" }, { name: "Guild Member", value: "ign" },
{ name: "Guild Name", value: "name" }, { name: "Guild Name", value: "name" },
{ name: "Guild Id", value: "id" }, { name: "Guild Id", value: "id" }
), )
) )
.addNumberOption(option => .addNumberOption(option =>
option option
.setName("amount") .setName("amount")
.setDescription( .setDescription("The amount of guild members to show. [Default: 10]")
"The amount of guild members to show. [Default: 10]", )
),
),
) )
.setDMPermission(false), .setDMPermission(false),
@@ -101,16 +95,14 @@ export = {
} }
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "This command is currently under development",
description: "This command is currently under development", color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
}, }
} as Command } as Command

View File

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

View File

@@ -2,62 +2,52 @@ import { getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { ChatInputCommandInteraction } from "discord.js" import { ChatInputCommandInteraction } from "discord.js"
export default async function guildMember( export default async function guildMember(interaction: ChatInputCommandInteraction): Promise<void> {
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply() await interaction.deferReply()
const ign = interaction.options.getString("ign")! const ign = interaction.options.getString("ign")!
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your uuid...",
description: "Fetching your uuid...", color: embedColor
color: embedColor, }]
},
],
}) })
const uuid = await getUUID(ign) const uuid = await getUUID(ign)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "This user does not exist",
description: "This user does not exist", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your player data...",
description: "Fetching your player data...", color: embedColor
color: embedColor, }]
},
],
}) })
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "This user never logged on to hypixel",
description: "This user never logged on to hypixel", color: embedColor,
color: embedColor, thumbnail: {
thumbnail: { url: head!
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
return return
} }
@@ -80,30 +70,26 @@ export default async function guildMember(
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = await getGuild(uuid) const guild = await getGuild(uuid)
if (!guild) { if (!guild) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "This user is not in a guild",
description: "This user is not in a guild", color: embedColor,
color: embedColor, thumbnail: {
thumbnail: { url: head!
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
return return
} }
@@ -116,30 +102,13 @@ export default async function guildMember(
const guildRank = guildMember!.rank const guildRank = guildMember!.rank
const memberGexp = guildMember!.expHistory const memberGexp = guildMember!.expHistory
const allDaysGexp = Object.keys(memberGexp).map(key => { const allDaysGexp = Object.keys(memberGexp).map(key => {
return ( return ("**➺ " + key + ":** " + "`" + new Intl.NumberFormat("en-US").format(memberGexp[key]) + "`" + "\n")
"**➺ " +
key +
":** " +
"`" +
new Intl.NumberFormat("en-US").format(memberGexp[key]) +
"`" +
"\n"
)
}) })
const expValue = allDaysGexp.join("") const expValue = allDaysGexp.join("")
const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce( const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce((a, b) => a + b, 0)
(a, b) => a + b, const totalWeeklyGexp = new Intl.NumberFormat("en-US").format(totalWeeklyGexpUnformatted)
0, const averageWeeklyGexpUnformatted = Math.round(totalWeeklyGexpUnformatted / 7)
) const averageWeeklyGexp = new Intl.NumberFormat("en-US").format(averageWeeklyGexpUnformatted)
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 guildMemberJoinMS = guildMember!.joined
const guildMemberJoinTime = new Date(guildMemberJoinMS) const guildMemberJoinTime = new Date(guildMemberJoinMS)
@@ -151,58 +120,41 @@ export default async function guildMember(
const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds() const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds()
const guildMemberJoin = const guildMemberJoin =
guildMemberJoinDate + guildMemberJoinDate + "." +
"." + guildMemberJoinMonth + "." +
guildMemberJoinMonth + guildMemberJoinYear + " " +
"." + guildMemberJoinHours + ":" +
guildMemberJoinYear + guildMemberJoinMinutes + ":" +
" " +
guildMemberJoinHours +
":" +
guildMemberJoinMinutes +
":" +
guildMemberJoinSeconds guildMemberJoinSeconds
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: rank + displayName + guildTag,
title: rank + displayName + guildTag, description: "**Guild Name:** `" + guildName + "`\n" +
description: "**Guild Rank:** `" + guildRank + "`\n",
"**Guild Name:** `" + color: embedColor,
guildName + thumbnail: {
"`\n" + url: head!
"**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: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], fields: [
{
name: "**Daily GEXP**",
value: expValue
},
{
name: "**Weekly GEXP**",
value: "**➺ Total:** `" + totalWeeklyGexp + "`\n" +
"**➺ Daily avarage:** `" + averageWeeklyGexp + "`"
},
{
name: "**Join date**",
value: "**➺ **`" + guildMemberJoin + "`"
}
],
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
} }

View File

@@ -5,9 +5,7 @@ import { GuildData } from "interfaces"
import Illegitimate from "utils/Illegitimate" import Illegitimate from "utils/Illegitimate"
const redis = Illegitimate.redis const redis = Illegitimate.redis
export default async function guildTop( export default async function guildTop(interaction: ChatInputCommandInteraction): Promise<void> {
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply() await interaction.deferReply()
const query = interaction.options.getString("query")! const query = interaction.options.getString("query")!
@@ -18,123 +16,101 @@ export default async function guildTop(
if (interaction.channel!.type === ChannelType.DM) { if (interaction.channel!.type === ChannelType.DM) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "You can't use this command in DMs!",
description: "You can't use this command in DMs!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
if (type === "ign") { if (type === "ign") {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your uuid...",
description: "Fetching your uuid...", color: embedColor
color: embedColor, }]
},
],
}) })
const uuid = await getUUID(query) const uuid = await getUUID(query)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player doen't exist!",
description: "That player doen't exist!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your player data...",
description: "Fetching your player data...", color: embedColor
color: embedColor, }]
},
],
}) })
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player has never joined the server!",
description: "That player has never joined the server!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
guild = await getGuild(uuid, "player") guild = await getGuild(uuid, "player")
if (!guild) { if (!guild) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player is not in a guild!",
description: "That player is not in a guild!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
} else if (type === "name") { } else if (type === "name") {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
guild = await getGuild(query, "name") guild = await getGuild(query, "name")
if (!guild) { if (!guild) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That guild doesn't exist!",
description: "That guild doesn't exist!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
} else if (type === "id") { } else if (type === "id") {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
guild = await getGuild(query, "id") guild = await getGuild(query, "id")
if (!guild) { if (!guild) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That guild doesn't exist!",
description: "That guild doesn't exist!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -146,26 +122,18 @@ export default async function guildTop(
const cachedData = await redis.get("guildTop+" + guildId) const cachedData = await redis.get("guildTop+" + guildId)
const gexpTodayUnformatted = guildMembers const gexpTodayUnformatted = guildMembers.map(member => {
.map(member => { return member.expHistory[Object.keys(member.expHistory)[0]]
return member.expHistory[Object.keys(member.expHistory)[0]] }).reduce((a, b) => a + b, 0)
}) const gexpToday = new Intl.NumberFormat("en-US").format(gexpTodayUnformatted)
.reduce((a, b) => a + b, 0)
const gexpToday = new Intl.NumberFormat("en-US").format(
gexpTodayUnformatted,
)
const averageGuildMemberGEXPUnformatted = Math.floor( const averageGuildMemberGEXPUnformatted = Math.floor(gexpTodayUnformatted / guildMembers.length)
gexpTodayUnformatted / guildMembers.length, const averageGuildMemberGEXP = new Intl.NumberFormat("en-US").format(averageGuildMemberGEXPUnformatted)
)
const averageGuildMemberGEXP = new Intl.NumberFormat("en-US").format(
averageGuildMemberGEXPUnformatted,
)
const allMembersDailyGEXP = guildMembers.map(member => { const allMembersDailyGEXP = guildMembers.map(member => {
return { return {
uuid: member.uuid, uuid: member.uuid,
gexp: member.expHistory[Object.keys(member.expHistory)[0]], gexp: member.expHistory[Object.keys(member.expHistory)[0]]
} }
}) })
@@ -184,24 +152,15 @@ export default async function guildTop(
let guildData: GuildTopData = [] let guildData: GuildTopData = []
const fieldsValueRaw: string[] = [] const fieldsValueRaw: string[] = []
const allMembersSorted = allMembersDailyGEXP.sort((a, b) => b.gexp - a.gexp) const allMembersSorted = allMembersDailyGEXP.sort((a, b) => b.gexp - a.gexp)
const allMembersSortedUUIDArray = allMembersSorted.map(member => { const allMembersSortedUUIDArray = allMembersSorted.map(member => member.uuid)
return member.uuid
})
if (!cachedData) { if (!cachedData) {
cacheStatus = false cacheStatus = false
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching the top " + amount + " members of " + guildName + "...",
description: color: embedColor
"Fetching the top " + }]
amount +
" members of " +
guildName +
"...",
color: embedColor,
},
],
}) })
for (let i = 0; i < allMembersSortedUUIDArray.length; i++) { for (let i = 0; i < allMembersSortedUUIDArray.length; i++) {
@@ -210,30 +169,18 @@ export default async function guildTop(
guildData.push({ guildData.push({
ign: ign!, ign: ign!,
uuid: uuid, uuid: uuid
}) })
} }
await redis.set( await redis.set("guildTop+" + guildId, JSON.stringify(guildData), "EX", 60 * 30)
"guildTop+" + guildId,
JSON.stringify(guildData),
"EX",
60 * 30,
)
} else { } else {
cacheStatus = true cacheStatus = true
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching the top " + amount + " members of " + guildName + "using cache...",
description: color: embedColor
"Fetching the top " + }]
amount +
" members of " +
guildName +
"using cache...",
color: embedColor,
},
],
}) })
guildData = JSON.parse(cachedData) guildData = JSON.parse(cachedData)
} }
@@ -243,18 +190,14 @@ export default async function guildTop(
for (let i = 0; i < amount; i++) { for (let i = 0; i < amount; i++) {
const gexp = new Intl.NumberFormat("en-US").format(topMembers[i].gexp) const gexp = new Intl.NumberFormat("en-US").format(topMembers[i].gexp)
const ign = guildData.find( const ign = guildData.find(member => member.uuid === topMembers[i].uuid)?.ign
member => member.uuid === topMembers[i].uuid,
)?.ign
const position = i + 1 const position = i + 1
fieldsValueRaw.push("**#" + position + " " + ign + ":** `" + gexp + "`") fieldsValueRaw.push("**#" + position + " " + ign + ":** `" + gexp + "`")
} }
const list = Array.from({ length: sliceSize }, (_, i) => const list = Array.from({ length: sliceSize }, (_, i) => fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize))
fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize),
)
const newList: NewList = [] const newList: NewList = []
list.forEach((item, index) => { list.forEach((item, index) => {
@@ -263,34 +206,23 @@ export default async function guildTop(
newList[index] = { newList[index] = {
name: "", name: "",
value: item.join("\n"), value: item.join("\n"),
inline: false, inline: false
} }
}) })
const cacheStatusText = cacheStatus ? " | [Cache]" : "" const cacheStatusText = cacheStatus ? " | [Cache]" : ""
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "Top members of " + guildName,
title: "Top members of " + guildName, description: "**Total daily GEXP:** `" + gexpToday + "`\n" +
description: "**Average guild memeber GEXP:** `" + averageGuildMemberGEXP + "`",
"**Total daily GEXP:** `" + color: embedColor,
gexpToday + fields: newList,
"`\n" + footer: {
"**Average guild memeber GEXP:** `" + text: interaction.guild!.name + " | " + devMessage + cacheStatusText,
averageGuildMemberGEXP + icon_url: interaction.guild!.iconURL() || undefined
"`", }
color: embedColor, }]
fields: newList,
footer: {
text:
interaction.guild!.name +
" | " +
devMessage +
cacheStatusText,
icon_url: interaction.guild!.iconURL() || undefined,
},
},
],
}) })
} }

View File

@@ -24,7 +24,7 @@ export = {
const commandRawList = client.commands.map(command => { const commandRawList = client.commands.map(command => {
return { return {
name: command.name, name: command.name,
command: command, command: command
} }
}) })
@@ -34,22 +34,22 @@ export = {
if (!command.command.subcommands && command.command.public) { if (!command.command.subcommands && command.command.public) {
commandList.push({ commandList.push({
name: "**/" + commandName + "**", name: "**/" + commandName + "**",
value: "`" + command.command.description + "`", value: "`" + command.command.description + "`"
}) })
} else if (command.command.subcommands && command.command.public) { } else if (command.command.subcommands && command.command.public) {
const subcommands = command.command.data.options.map( const subcommands = command.command.data.options.map(
subcommand => { subcommand => {
return { return {
name: commandName + " " + subcommand.toJSON().name, name: commandName + " " + subcommand.toJSON().name,
description: subcommand.toJSON().description, description: subcommand.toJSON().description
} }
}, }
) )
for (const subcommand of subcommands) { for (const subcommand of subcommands) {
commandList.push({ commandList.push({
name: "**/" + subcommand.name + "**", name: "**/" + subcommand.name + "**",
value: "`" + subcommand.description + "`", value: "`" + subcommand.description + "`"
}) })
} }
} }
@@ -58,21 +58,19 @@ export = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "Commands",
title: "Commands", description: "List of commands",
description: "List of commands", fields: commandList,
fields: commandList, color: embedColor,
color: embedColor, thumbnail: {
thumbnail: { url: interaction.guild!.iconURL() || ""
url: interaction.guild!.iconURL() || "",
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
}) })
}, }
} as Command } as Command

View File

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

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { admin, helper } from "config/roles.json" import { admin, helper } from "config/roles.json"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
@@ -22,12 +17,12 @@ export = {
option option
.setName("member") .setName("member")
.setDescription("Member to kick.") .setDescription("Member to kick.")
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option option
.setName("reason") .setName("reason")
.setDescription("Reason for kicking the member."), .setDescription("Reason for kicking the member.")
) )
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers) .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
.setDMPermission(false), .setDMPermission(false),
@@ -36,8 +31,7 @@ export = {
await interaction.deferReply() await interaction.deferReply()
const member = interaction.options.getMember("member") as GuildMember const member = interaction.options.getMember("member") as GuildMember
const reason = const reason = interaction.options.getString("reason") ?? "No reason provided."
interaction.options.getString("reason") ?? "No reason provided."
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const mod = await interaction.guild!.members.fetch(interaction.user.id) const mod = await interaction.guild!.members.fetch(interaction.user.id)
@@ -45,9 +39,7 @@ export = {
const modRoles = mod.roles.cache.map(role => role.id) const modRoles = mod.roles.cache.map(role => role.id)
if (!modRoles.includes(helper) && !modRoles.includes(admin)) { if (!modRoles.includes(helper) && !modRoles.includes(admin)) {
await interaction.editReply( await interaction.editReply("You do not have permission to use this command.")
"You do not have permission to use this command.",
)
return return
} }
@@ -79,54 +71,44 @@ export = {
await member.kick(reason + ` - ${mod.user.username}`) await member.kick(reason + ` - ${mod.user.username}`)
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: mod.user.username,
name: mod.user.username, icon_url: mod.user.avatarURL() || undefined
icon_url: mod.user.avatarURL() || undefined, },
}, title: "Member Kicked",
title: "Member Kicked", description: `
description: `
**User:** ${userMention(member.user.id)} **User:** ${userMention(member.user.id)}
**Mod:** ${userMention(mod.user.id)} **Mod:** ${userMention(mod.user.id)}
**Reason:** ${reason} **Reason:** ${reason}
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: mod.user.avatarURL() || "", url: mod.user.avatarURL() || ""
},
footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "Member Kicked",
title: "Member Kicked", description: "**User:** " + userMention(member.user.id) + "\n" +
description: "**Reason:** " + reason + "\n" +
"**User:** " + "**Moderator:** " + mod.user.username,
userMention(member.user.id) + color: embedColor,
"\n" + thumbnail: {
"**Reason:** " + url: member.user.avatarURL() || ""
reason +
"\n" +
"**Moderator:** " +
mod.user.username,
color: embedColor,
thumbnail: {
url: member.user.avatarURL() || "",
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
}) })
}, }
} as Command } as Command

View File

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

View File

@@ -7,7 +7,7 @@ export = {
name: "pp", name: "pp",
description: "Shows pp size", description: "Shows pp size",
public: true, public: true,
dev: true, dev: false,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("pp") .setName("pp")
@@ -16,13 +16,12 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("User to show pp size") .setDescription("User to show pp size")
.setRequired(false), .setRequired(false)
) )
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
const user = (interaction.options.getUser("user") || const user = (interaction.options.getUser("user") || interaction.user) as User
interaction.user) as User
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
let size: number let size: number
@@ -33,13 +32,11 @@ export = {
} }
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ title: `${user.username}'s pp size`,
title: `${user.username}'s pp size`, description: `8${"=".repeat(size)}D`,
description: `8${"=".repeat(size)}D`, color: embedColor
color: embedColor, }]
},
],
}) })
}, }
} as Command } as Command

View File

@@ -1,8 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import waitinglistSchema from "schemas/waitinglistSchema" import waitinglistSchema from "schemas/waitinglistSchema"
import { Command } from "interfaces" import { Command } from "interfaces"
@@ -21,13 +17,13 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to remove.") .setDescription("The user to remove.")
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option option
.setName("reason") .setName("reason")
.setDescription("The reason for removing the user.") .setDescription("The reason for removing the user.")
.setRequired(false), .setRequired(false)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -36,8 +32,7 @@ export = {
await interaction.deferReply() await interaction.deferReply()
const user = interaction.options.getUser("user")! const user = interaction.options.getUser("user")!
const reason = const reason = interaction.options.getString("reason") ?? "No reason provided."
interaction.options.getString("reason") ?? "No reason provided."
const mod = interaction.user! const mod = interaction.user!
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -45,14 +40,10 @@ export = {
if (!waitinglist) { if (!waitinglist) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: userMention(user.id) + " is not on the waiting list.",
description: color: embedColor
userMention(user.id) + }]
" is not on the waiting list.",
color: embedColor,
},
],
}) })
return return
} }
@@ -60,49 +51,40 @@ export = {
await waitinglistSchema.findOneAndDelete({ userID: user.id }) await waitinglistSchema.findOneAndDelete({ userID: user.id })
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: mod.username,
name: mod.username, icon_url: mod.avatarURL() || undefined
icon_url: mod.avatarURL() || undefined, },
}, title: "Waiting List - Remove User",
title: "Waiting List - Remove User", description: `
description: `
**User:** ${userMention(user.id)} **User:** ${userMention(user.id)}
**Reason:** ${reason} **Reason:** ${reason}
**Mod:** ${userMention(mod.id)} **Mod:** ${userMention(mod.id)}
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: mod.avatarURL() || "", url: mod.avatarURL() || ""
},
footer: {
icon_url: user.avatarURL() || undefined,
text: "ID: " + user.id,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
icon_url: user.avatarURL() || undefined,
text: "ID: " + user.id
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "Waiting List - Remove User",
title: "Waiting List - Remove User", description: "**User:** " + userMention(user.id) + "\n" +
description: "**Reason:** `" + reason + "`",
"**User:** " + color: embedColor,
userMention(user.id) + footer: {
"\n" + text: interaction.guild!.name + " | " + devMessage,
"**Reason:** `" + icon_url: interaction.guild!.iconURL() || undefined
reason + }
"`", }]
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
},
],
}) })
}, }
} as Command } as Command

View File

@@ -1,14 +1,6 @@
import { SlashCommandBuilder } from "discord.js" import { SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { import { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "config/reqs.json"
bwfkdr,
bwstars,
bwwins,
swstars,
swkdr,
duelswins,
duelswlr,
} from "config/reqs.json"
import { Command } from "interfaces" import { Command } from "interfaces"
export = { export = {
@@ -26,52 +18,36 @@ export = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ title: "Requirements",
title: "Requirements", description: "**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**",
description: color: embedColor,
"**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**", thumbnail: {
color: embedColor, url: interaction.guild!.iconURL() || ""
thumbnail: {
url: interaction.guild!.iconURL() || "",
},
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: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || 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: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
}, }
} as Command } as Command

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, TextChannel } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
ChannelType,
TextChannel,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
@@ -20,16 +15,13 @@ export = {
option option
.setName("message") .setName("message")
.setDescription("The message to send.") .setDescription("The message to send.")
.setRequired(true), .setRequired(true)
) )
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription("The channel to send the message to.") .setDescription("The channel to send the message to.")
.addChannelTypes( .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
),
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -38,38 +30,33 @@ export = {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
const message = interaction.options.getString("message")! const message = interaction.options.getString("message")!
const channel = (interaction.options.getChannel("channel") || const channel = (interaction.options.getChannel("channel") || interaction.channel) as TextChannel
interaction.channel) as TextChannel
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
channel.send({ channel.send({
embeds: [ embeds: [{
{ title: interaction.guild!.name,
title: interaction.guild!.name, description: message,
description: message, color: embedColor,
color: embedColor, thumbnail: {
thumbnail: { url: interaction.guild!.iconURL() || ""
url: interaction.guild!.iconURL() || "",
},
footer: {
text: interaction.guild!.id + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.id + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Message sent.",
description: "Message sent.", color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
}, }
} as Command } as Command

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
import logToChannel from "utils/functions/logtochannel" import logToChannel from "utils/functions/logtochannel"
@@ -21,13 +16,13 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to set the nickname for") .setDescription("The user to set the nickname for")
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option option
.setName("nickname") .setName("nickname")
.setDescription("The nickname to set") .setDescription("The nickname to set")
.setRequired(true), .setRequired(true)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames) .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames)
.setDMPermission(false), .setDMPermission(false),
@@ -40,7 +35,7 @@ export = {
if (!member.manageable) { if (!member.manageable) {
interaction.reply({ interaction.reply({
content: "I cannot set the nickname for this user!", content: "I cannot set the nickname for this user!",
ephemeral: true, ephemeral: true
}) })
return return
} }
@@ -48,43 +43,39 @@ export = {
await member.setNickname(nickname, `Set by ${interaction.user.tag}`) await member.setNickname(nickname, `Set by ${interaction.user.tag}`)
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: interaction.user.username,
name: interaction.user.username, icon_url: interaction.user.avatarURL() || undefined
icon_url: interaction.user.avatarURL() || undefined, },
}, title: "Nickname",
title: "Nickname", description: `
description: `
**User:** ${userMention(member.id)} **User:** ${userMention(member.id)}
**Nickname:** ${nickname} **Nickname:** ${nickname}
**Moderator:** ${userMention(interaction.user.id)} **Moderator:** ${userMention(interaction.user.id)}
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: interaction.user.avatarURL() || "", url: interaction.user.avatarURL() || ""
},
footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: `Successfully set the nickname of ${userMention(member.id)} to ${nickname}`,
description: `Successfully set the nickname of ${userMention(member.id)} to ${nickname}`, color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }],
}, ephemeral: true
],
ephemeral: true,
}) })
}, }
} as Command } as Command

View File

@@ -1,12 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, ChannelType, TextChannel } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
ChannelType,
TextChannel,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
@@ -27,15 +19,10 @@ export = {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription( .setDescription("The channel to send the application to.")
"The channel to send the application to.", .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
) .setRequired(true)
.addChannelTypes( )
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
)
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -44,15 +31,10 @@ export = {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription( .setDescription("The channel to send the application to.")
"The channel to send the application to.", .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
) .setRequired(true)
.addChannelTypes( )
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
)
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -61,15 +43,10 @@ export = {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription( .setDescription("The channel to send the verfiy message to.")
"The channel to send the verfiy message to.", .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
) .setRequired(true)
.addChannelTypes( )
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
)
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -78,15 +55,10 @@ export = {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription( .setDescription("The channel to send the waiting list message to.")
"The channel to send the waiting list message to.", .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
) .setRequired(true)
.addChannelTypes( )
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
)
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -95,15 +67,10 @@ export = {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription( .setDescription("The channel to send the application to.")
"The channel to send the application to.", .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
) .setRequired(true)
.addChannelTypes( )
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
)
.setRequired(true),
),
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -112,16 +79,15 @@ export = {
const subcommand = interaction.options.getSubcommand() const subcommand = interaction.options.getSubcommand()
const channel = interaction.options.getChannel("channel") as TextChannel const channel = interaction.options.getChannel("channel") as TextChannel
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
let title: string = "" let title = ""
let description: string = "" let description = ""
let customId: string = "" let customId = ""
let label: string = "" let label = ""
let emoji: string = "" let emoji = ""
if (subcommand === "sendguildapplication") { if (subcommand === "sendguildapplication") {
title = "Guild Application" title = "Guild Application"
description = description = "You can apply for the guild by clicking the button below."
"You can apply for the guild by clicking the button below."
customId = "guildapply" customId = "guildapply"
label = "Apply" label = "Apply"
emoji = "✅" emoji = "✅"
@@ -129,8 +95,7 @@ export = {
if (subcommand === "sendstaffapplication") { if (subcommand === "sendstaffapplication") {
title = "Staff Application" title = "Staff Application"
description = description = "You can apply for the staff team by clicking the button below."
"You can apply for the staff team by clicking the button below."
customId = "staffapply" customId = "staffapply"
label = "Apply" label = "Apply"
emoji = "✅" emoji = "✅"
@@ -138,8 +103,7 @@ export = {
if (subcommand === "sendinactivityapplication") { if (subcommand === "sendinactivityapplication") {
title = "Inactivity Log" title = "Inactivity Log"
description = description = "You can send an inactivity log by clicking the button below."
"You can send an inactivity log by clicking the button below."
customId = "guildinactivitylog" customId = "guildinactivitylog"
label = "Submit" label = "Submit"
emoji = "✅" emoji = "✅"
@@ -162,34 +126,32 @@ export = {
} }
await channel.send({ await channel.send({
embeds: [ embeds: [{
{ title: title,
title: title, description: description,
description: description, color: embedColor,
color: embedColor, thumbnail: {
thumbnail: { url: interaction.guild!.iconURL() || ""
url: interaction.guild!.iconURL() || "",
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}],
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(customId) .setCustomId(customId)
.setLabel(label) .setLabel(label)
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setEmoji({ name: emoji }), .setEmoji({ name: emoji })
), )
], ]
}) })
await interaction.reply({ await interaction.reply({
content: "Message sent", content: "Message sent",
ephemeral: true, ephemeral: true
}) })
}, }
} as Command } as Command

View File

@@ -1,11 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, TextChannel, channelMention, userMention } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
ChannelType,
TextChannel,
channelMention,
userMention,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
import logToChannel from "utils/functions/logtochannel" import logToChannel from "utils/functions/logtochannel"
@@ -22,18 +15,13 @@ export = {
.addIntegerOption(option => .addIntegerOption(option =>
option option
.setName("seconds") .setName("seconds")
.setDescription( .setDescription("The amount of seconds to set the slowmode to.")
"The amount of seconds to set the slowmode to.",
),
) )
.addChannelOption(option => .addChannelOption(option =>
option option
.setName("channel") .setName("channel")
.setDescription("The channel to set the slowmode of.") .setDescription("The channel to set the slowmode of.")
.addChannelTypes( .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
ChannelType.GuildText,
ChannelType.GuildAnnouncement,
),
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -42,65 +30,58 @@ export = {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
const seconds = interaction.options.getInteger("seconds") ?? 5 const seconds = interaction.options.getInteger("seconds") ?? 5
const channel = (interaction.options.getChannel("channel") || const channel = (interaction.options.getChannel("channel") || interaction.channel) as TextChannel
interaction.channel) as TextChannel
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (seconds > 21600) { if (seconds > 21600) {
await channel.setRateLimitPerUser(21600) await channel.setRateLimitPerUser(21600)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: `Set the slowmode of ${channel} to 21600 seconds.`,
description: `Set the slowmode of ${channel} to 21600 seconds.`, color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
return return
} }
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: interaction.user.username,
name: interaction.user.username, icon_url: interaction.user.avatarURL() || undefined
icon_url: interaction.user.avatarURL() || undefined, },
}, title: "Slowmode Update",
title: "Slowmode Update", description: `
description: `
**Channel:** ${channelMention(channel.id)} **Channel:** ${channelMention(channel.id)}
**Slowmode:** ${seconds} seconds **Slowmode:** ${seconds} seconds
**Mod:** ${userMention(interaction.user.id)} **Mod:** ${userMention(interaction.user.id)}
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: interaction.user.avatarURL() || "", url: interaction.user.avatarURL() || ""
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: " ID: " + channel.id,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: " ID: " + channel.id
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: `Set the slowmode of ${channel} to ${seconds} seconds.`,
description: `Set the slowmode of ${channel} to ${seconds} seconds.`, color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
await channel.setRateLimitPerUser(seconds) await channel.setRateLimitPerUser(seconds)
}, }
} as Command } as Command

View File

@@ -8,7 +8,7 @@ export = {
name: "snipe", name: "snipe",
description: "Snipes the last deleted message of a user", description: "Snipes the last deleted message of a user",
public: true, public: true,
dev: true, dev: false,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("snipe") .setName("snipe")
@@ -17,7 +17,7 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to snipe") .setDescription("The user to snipe")
.setRequired(true), .setRequired(true)
) )
.setDMPermission(false), .setDMPermission(false),
@@ -26,19 +26,17 @@ export = {
const member = interaction.options.getMember("user") as GuildMember const member = interaction.options.getMember("user") as GuildMember
const snipeCache = await snipeCacheSchema.find({ const snipeCache = await snipeCacheSchema.find({
userid: member.user.id, userid: member.user.id,
channelid: interaction.channel!.id, channelid: interaction.channel!.id
}) })
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const messages: string[] = [] const messages: string[] = []
if (!snipeCache.length) { if (!snipeCache.length) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "No messages to snipe",
description: "No messages to snipe", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -50,32 +48,28 @@ export = {
messages.push(`**Message #${i}:** ${data.content}\n`) messages.push(`**Message #${i}:** ${data.content}\n`)
} else { } else {
messages.push(`**Message #${i}:** ${data.content}`) messages.push(`**Message #${i}:** ${data.content}`)
messages.push( messages.push(`**Attachments:** ${data.attachments.join(", ")}\n`)
`**Attachments:** ${data.attachments.join(", ")}\n`,
)
} }
i++ i++
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ author: {
author: { name: member.user.username,
name: member.user.username, icon_url: member.user.avatarURL() || undefined
icon_url: member.user.avatarURL() || undefined,
},
description: messages.join("\n"),
thumbnail: {
url: member.user.avatarURL() || "",
},
color: embedColor,
footer: {
text: "ID: " + member.user.id,
icon_url: interaction.guild!.iconURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], description: messages.join("\n"),
thumbnail: {
url: member.user.avatarURL() || ""
},
color: embedColor,
footer: {
text: "ID: " + member.user.id,
icon_url: interaction.guild!.iconURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
}, }
} as Command } as Command

View File

@@ -18,7 +18,7 @@ export = {
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName("help") .setName("help")
.setDescription("Get help with staff commands"), .setDescription("Get help with staff commands")
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
@@ -28,15 +28,13 @@ export = {
option option
.setName("ign") .setName("ign")
.setDescription("The IGN of the player.") .setDescription("The IGN of the player.")
.setRequired(true), .setRequired(true)
), )
) )
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName("updatediscordroles") .setName("updatediscordroles")
.setDescription( .setDescription("Update the discord roles of all guild members")
"Update the discord roles of all guild members",
),
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -61,16 +59,14 @@ export = {
} }
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "This command is currently under development",
description: "This command is currently under development", color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
}, }
} as Command } as Command

View File

@@ -1,27 +1,9 @@
import { import { bwwins, beastbwfkdr, beastbwstars, beastswkdr, beastswstars, beastduelswins, duelswlr } from "config/reqs.json"
bwwins,
beastbwfkdr,
beastbwstars,
beastswkdr,
beastswstars,
beastduelswins,
duelswlr,
} from "config/reqs.json"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { import { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
hypixelLevel,
bedwarsLevel,
skywarsLevel,
getUUID,
getPlayer,
getGuild,
getHeadURL,
} from "utils/Hypixel"
import { ChatInputCommandInteraction } from "discord.js" import { ChatInputCommandInteraction } from "discord.js"
export default async function beast( export default async function beast(interaction: ChatInputCommandInteraction): Promise<void> {
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply() await interaction.deferReply()
const ign = interaction.options.getString("ign")! const ign = interaction.options.getString("ign")!
@@ -33,46 +15,38 @@ export default async function beast(
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your uuid...",
description: "Fetching your uuid...", color: embedColor
color: embedColor, }]
},
],
}) })
const uuid = await getUUID(ign) const uuid = await getUUID(ign)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player doesn't exist.",
description: "That player doesn't exist.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your player data...",
description: "Fetching your player data...", color: embedColor
color: embedColor, }]
},
],
}) })
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player hasn't played Hypixel before.",
description: "That player hasn't played Hypixel before.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -94,12 +68,10 @@ export default async function beast(
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = await getGuild(uuid) const guild = await getGuild(uuid)
@@ -124,164 +96,119 @@ export default async function beast(
if (!player.stats) { if (!player.stats) {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played any games.", name: "<a:_warning:1178350183457751100> This player never played any games.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} else { } else {
if (player.stats.Bedwars) { if (player.stats.Bedwars) {
const hsbwexp = player.stats.Bedwars.Experience || 0 const hsbwexp = player.stats.Bedwars?.Experience || 0
const hsbwfk = player.stats.Bedwars?.final_kills_bedwars || 0
const hsbwfd = player.stats.Bedwars?.final_deaths_bedwars || 0
const hsbwwins = player.stats.Bedwars?.wins_bedwars || 0
const hsbwstars = bedwarsLevel(hsbwexp) const hsbwstars = bedwarsLevel(hsbwexp)
const hsbwfk = player.stats?.Bedwars?.final_kills_bedwars || 0
const hsbwfd = player.stats?.Bedwars?.final_deaths_bedwars || 0
const hsbwfkdr = hsbwfk / hsbwfd || 0 const hsbwfkdr = hsbwfk / hsbwfd || 0
const hsbwwins = player.stats.Bedwars.wins_bedwars || 0
let bwtitle = "" let bwtitle = ""
if ( if (hsbwstars < beastbwstars || hsbwfkdr < beastbwfkdr || hsbwwins < bwwins) {
hsbwstars < beastbwstars || bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
hsbwfkdr < beastbwfkdr ||
hsbwwins < bwwins
) {
bwtitle =
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
} else { } else {
bwtitle = bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements."
"<a:check_a:1087808632172847134> This player meets the BedWars requirements."
} }
statsFields.push({ statsFields.push({
name: bwtitle, name: bwtitle,
value: value: "**➺ Stars:** `" + hsbwstars.toFixed(2).toString() +
"**➺ Stars:** `" + " / " + beastbwstars.toString() + "`\n" +
hsbwstars.toFixed(2).toString() + "**➺ FKDR:** `" + hsbwfkdr.toFixed(2).toString() +
" / " + " / " + beastbwfkdr.toString() + "`\n" +
beastbwstars.toString() + "**➺ Wins:** `" + hsbwwins.toString() +
"`\n" + " / " + bwwins.toString() + "`"
"**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() +
" / " +
beastbwfkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsbwwins.toString() +
" / " +
bwwins.toString() +
"`",
}) })
} else { } else {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played BedWars.", name: "<a:_warning:1178350183457751100> This player never played BedWars.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} }
if (player.stats.SkyWars) { if (player.stats.SkyWars) {
const hsswexp = player.stats?.SkyWars?.skywars_experience || 0 const hsswexp = player.stats.SkyWars?.skywars_experience || 0
const hsswkills = player.stats.SkyWars?.kills || 0
const hsswdeaths = player.stats.SkyWars?.deaths || 0
const hsswwins = player.stats.SkyWars?.wins || 0
const hsswstars = skywarsLevel(hsswexp) const hsswstars = skywarsLevel(hsswexp)
const hsswkills = player.stats?.SkyWars?.kills || 0
const hsswdeaths = player.stats?.SkyWars?.deaths || 0
const hsswkd = hsswkills / hsswdeaths || 0 const hsswkd = hsswkills / hsswdeaths || 0
const hsswwins = player.stats?.SkyWars?.wins || 0
let swtitle = "" let swtitle = ""
if (hsswstars < beastswstars || hsswkd < beastswkdr) { if (hsswstars < beastswstars || hsswkd < beastswkdr) {
swtitle = swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
} else { } else {
swtitle = swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
"<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
} }
statsFields.push({ statsFields.push({
name: swtitle, name: swtitle,
value: value: "**➺ Stars:** `" + hsswstars.toFixed(2).toString() +
"**➺ Stars:** `" + " / " + beastswstars.toString() + "`\n" +
hsswstars.toFixed(2).toString() + "**➺ KDR:** `" + hsswkd.toFixed(2).toString() +
" / " + " / " + beastswkdr.toString() + "`\n" +
beastswstars.toString() + "**➺ Wins:** `" + hsswwins.toString() + "`"
"`\n" +
"**➺ KDR:** `" +
hsswkd.toFixed(2).toString() +
" / " +
beastswkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsswwins.toString() +
"`",
}) })
} else { } else {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played SkyWars.", name: "<a:_warning:1178350183457751100> This player never played SkyWars.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} }
if (player.stats.Duels) { if (player.stats.Duels) {
const hsduelskills = player.stats?.Duels?.kills || 0 const hsduelskills = player.stats.Duels?.kills || 0
const hsduelsdeaths = player.stats?.Duels?.deaths || 0 const hsduelsdeaths = player.stats.Duels?.deaths || 0
const hsduelskd = hsduelskills / hsduelsdeaths || 0 const hsduelswins = player.stats.Duels?.wins || 0
const hsduelswins = player.stats?.Duels?.wins || 0 const hsduelslosses = player.stats.Duels?.losses || 0
const hsduelslosses = player.stats?.Duels?.losses || 0 const hsduelskd = hsduelskills / hsduelsdeaths
const hsduelswlr = hsduelswins / hsduelslosses || 0 const hsduelswlr = hsduelswins / hsduelslosses
let duelstitle = "" let duelstitle = ""
if (hsduelswins < beastduelswins || hsduelswlr < duelswlr) { if (hsduelswins < beastduelswins || hsduelswlr < duelswlr) {
duelstitle = duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
} else { } else {
duelstitle = duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
"<a:check_a:1087808632172847134> This player meets the Duels requirements."
} }
statsFields.push({ statsFields.push({
name: duelstitle, name: duelstitle,
value: value: "**➺ Wins:** `" + hsduelswins.toString() +
"**➺ Wins:** `" + " / " + beastduelswins.toString() + "`\n" +
hsduelswins.toString() + "**➺ WLR:** `" + hsduelswlr.toFixed(2).toString() +
" / " + " / " + duelswlr.toString() + "`\n" +
beastduelswins.toString() + "**➺ KDR:** `" + hsduelskd.toFixed(2).toString() + "`"
"`\n" +
"**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() +
" / " +
duelswlr.toString() +
"`\n" +
"**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() +
"`\n",
}) })
} else { } else {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played Duels.", name: "<a:_warning:1178350183457751100> This player never played Duels.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} }
} }
// network level // network level
const hypixelExp = player.networkExp || 0 const hypixelExp = player?.networkExp || 0
const level = hypixelLevel(hypixelExp) const level = hypixelLevel(hypixelExp)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: rank + player.displayname + guildTag,
title: rank + player.displayname + guildTag, description: "**Network Level:** `" + level.toFixed(2).toString() + "`\n" +
description: "**Current Guild:** `" + guildName + "`",
"**Network Level:** `" + color: embedColor,
level.toFixed(2).toString() + thumbnail: {
"`\n" + url: head!
"**Current Guild:** `" +
guildName +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
fields: statsFields,
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
},
fields: statsFields
}]
}) })
} }

View File

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

View File

@@ -6,43 +6,36 @@ import env from "utils/Env"
import { getGuild } from "utils/Hypixel" import { getGuild } from "utils/Hypixel"
import { GuildData } from "interfaces" import { GuildData } from "interfaces"
export default async function updateDiscordRoles( export default async function updateDiscordRoles(interaction: ChatInputCommandInteraction): Promise<void> {
interaction: ChatInputCommandInteraction,
): Promise<void> {
const discordMember = interaction.member as GuildMember const discordMember = interaction.member as GuildMember
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
await interaction.deferReply() await interaction.deferReply()
if (discordMember.user.id !== env.prod.dev) { if (discordMember.user.id !== env.prod.dev) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "You do not have permission to use this command.",
description: color: embedColor
"You do not have permission to use this command.", }]
color: embedColor,
},
],
}) })
return return
} }
const guildMembers = await interaction const guildMembers = await interaction.guild!.members.fetch().then(
.guild!.members.fetch() members => members.map(member => {
.then(members => return {
members.map(member => { id: member.id,
return { member: member
id: member.id, }
member: member, })
} )
}),
)
const guildData = (await getGuild(hypixelGuildID, "id")) as GuildData const guildData = (await getGuild(hypixelGuildID, "id")) as GuildData
const hypixelGuildMembers = guildData.members.map(gmember => { const hypixelGuildMembers = guildData.members.map(gmember => {
return { return {
uuid: gmember.uuid, uuid: gmember.uuid,
rank: gmember.rank, rank: gmember.rank
} }
}) })
const guildMemberIDs = hypixelGuildMembers.map(gmember => gmember.uuid) const guildMemberIDs = hypixelGuildMembers.map(gmember => gmember.uuid)
@@ -54,138 +47,63 @@ export default async function updateDiscordRoles(
const verifiedUsers = allVerifiedUsers.map(user => { const verifiedUsers = allVerifiedUsers.map(user => {
return { return {
userID: user.userID, userID: user.userID,
uuid: user.uuid, uuid: user.uuid
} }
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: `Updating roles for ${guildMembers.length} members...`,
description: `Updating roles for ${guildMembers.length} members...`, color: embedColor
color: embedColor, }]
},
],
}) })
for (const gmember of guildMembers) { for (const gmember of guildMembers) {
const memberData = verifiedUsers.find( const memberData = verifiedUsers.find(user => user.userID === gmember.id)
user => user.userID === gmember.id,
)
if (!memberData) { if (!memberData) {
const rolesToremove = roleManage("default").rolesToRemove const rolesToremove = roleManage("default").rolesToRemove
await gmember.member.roles.remove( await gmember.member.roles.remove(rolesToremove, "Updating all discord members")
rolesToremove,
"Updating all discord members",
)
continue continue
} }
if (!guildMemberIDs.includes(memberData?.uuid || "none")) { if (!guildMemberIDs.includes(memberData?.uuid || "none")) {
const rolesToremove = roleManage("default").rolesToRemove const rolesToremove = roleManage("default").rolesToRemove
await gmember.member.roles.remove( await gmember.member.roles.remove(rolesToremove, "Updating all discord members")
rolesToremove,
"Updating all discord members",
)
continue continue
} else if (guildMemberIDs.includes(memberData!.uuid)) { } else if (guildMemberIDs.includes(memberData!.uuid)) {
const guildMemberRank = hypixelGuildMembers.find( const guildMemberRank = hypixelGuildMembers.find(gmember => gmember.uuid === memberData!.uuid)!.rank
gmember => gmember.uuid === memberData!.uuid,
)!.rank
console.log("Updating roles for " + gmember.member.user.username) console.log("Updating roles for " + gmember.member.user.username)
if (guildMemberRank === "Guild Master") { if (guildMemberRank === "Guild Master") {
// const rolesToRemove = removeThese.filter(role => role !== gm && role !== guildStaff && role !== guildRole)
// await gmember.member.roles.remove(rolesToRemove, "Updating all discord members")
// await gmember.member.roles.add( gm, "Updating all discord members",)
// await gmember.member.roles.add( guildStaff, "Updating all discord members",)
// await gmember.member.roles.add( guildRole, "Updating all discord members",)
const rolesmanage = roleManage("gm") const rolesmanage = roleManage("gm")
gmember.member.roles.remove( gmember.member.roles.remove(rolesmanage.rolesToRemove, "Updating all discord members")
rolesmanage.rolesToRemove, gmember.member.roles.add(rolesmanage.rolesToAdd, "Updating all discord members")
"Updating all discord members",
)
gmember.member.roles.add(
rolesmanage.rolesToAdd,
"Updating all discord members",
)
continue continue
} else if (guildMemberRank === "Manager") { } else if (guildMemberRank === "Manager") {
// const rolesToRemove = removeThese.filter(role => role !== manager && role !== guildStaff && role !== guildRole)
// await gmember.member.roles.remove( rolesToRemove, "Updating all discord members",)
// await gmember.member.roles.add( manager, "Updating all discord members",)
// await gmember.member.roles.add( guildStaff, "Updating all discord members",)
// await gmember.member.roles.add( guildRole, "Updating all discord members",)
const rolesmanage = roleManage("manager") const rolesmanage = roleManage("manager")
gmember.member.roles.remove( gmember.member.roles.remove(rolesmanage.rolesToRemove, "Updating all discord members")
rolesmanage.rolesToRemove, gmember.member.roles.add(rolesmanage.rolesToAdd, "Updating all discord members")
"Updating all discord members",
)
gmember.member.roles.add(
rolesmanage.rolesToAdd,
"Updating all discord members",
)
continue continue
} else if (guildMemberRank === "Moderator") { } else if (guildMemberRank === "Moderator") {
// const rolesToRemove = removeThese.filter(role => role !== moderator && role !== guildStaff && role !== guildRole)
// await gmember.member.roles.remove( rolesToRemove, "Updating all discord members",)
// await gmember.member.roles.add( moderator, "Updating all discord members",)
// await gmember.member.roles.add( guildStaff, "Updating all discord members",)
// await gmember.member.roles.add( guildRole, "Updating all discord members",)
const rolesmanage = roleManage("moderator") const rolesmanage = roleManage("moderator")
gmember.member.roles.remove( gmember.member.roles.remove(rolesmanage.rolesToRemove, "Updating all discord members")
rolesmanage.rolesToRemove, gmember.member.roles.add(rolesmanage.rolesToAdd, "Updating all discord members")
"Updating all discord members",
)
gmember.member.roles.add(
rolesmanage.rolesToAdd,
"Updating all discord members",
)
continue continue
} else if (guildMemberRank === "Beast") { } else if (guildMemberRank === "Beast") {
// const rolesToRemove = removeThese.filter(role => role !== beast && role !== guildRole)
// await gmember.member.roles.remove( rolesToRemove, "Updating all discord members",)
// await gmember.member.roles.add( beast, "Updating all discord members",)
// await gmember.member.roles.add( guildRole, "Updating all discord members",)
const rolesmanage = roleManage("beast") const rolesmanage = roleManage("beast")
gmember.member.roles.remove( gmember.member.roles.remove(rolesmanage.rolesToRemove, "Updating all discord members")
rolesmanage.rolesToRemove, gmember.member.roles.add(rolesmanage.rolesToAdd, "Updating all discord members")
"Updating all discord members",
)
gmember.member.roles.add(
rolesmanage.rolesToAdd,
"Updating all discord members",
)
continue continue
} else if (guildMemberRank === "Elite") { } else if (guildMemberRank === "Elite") {
// const rolesToRemove = removeThese.filter(role => role !== elite && role !== guildRole)
// await gmember.member.roles.remove( rolesToRemove, "Updating all discord members",)
// await gmember.member.roles.add( elite, "Updating all discord members",)
// await gmember.member.roles.add( guildRole, "Updating all discord members",)
const rolesmanage = roleManage("elite") const rolesmanage = roleManage("elite")
gmember.member.roles.remove( gmember.member.roles.remove(rolesmanage.rolesToRemove, "Updating all discord members")
rolesmanage.rolesToRemove, gmember.member.roles.add(rolesmanage.rolesToAdd, "Updating all discord members")
"Updating all discord members",
)
gmember.member.roles.add(
rolesmanage.rolesToAdd,
"Updating all discord members",
)
continue continue
} else if (guildMemberRank === "Member") { } else if (guildMemberRank === "Member") {
// const rolesToRemove = removeThese.filter(role => role !== member && role !== guildRole)
// await gmember.member.roles.remove( rolesToRemove, "Updating all discord members",)
// await gmember.member.roles.add( member, "Updating all discord members",)
// await gmember.member.roles.add( guildRole, "Updating all discord members",)
const rolesmanage = roleManage("member") const rolesmanage = roleManage("member")
gmember.member.roles.remove( gmember.member.roles.remove(rolesmanage.rolesToRemove, "Updating all discord members")
rolesmanage.rolesToRemove, gmember.member.roles.add(rolesmanage.rolesToAdd, "Updating all discord members")
"Updating all discord members",
)
gmember.member.roles.add(
rolesmanage.rolesToAdd,
"Updating all discord members",
)
continue continue
} }
continue continue
@@ -195,11 +113,9 @@ export default async function updateDiscordRoles(
console.log("Successfully updated all roles.") console.log("Successfully updated all roles.")
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Successfully updated all roles.",
description: "Successfully updated all roles.", color: embedColor
color: embedColor, }]
},
],
}) })
} }

View File

@@ -1,10 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention, ChatInputCommandInteraction, GuildMember } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
ChatInputCommandInteraction,
GuildMember,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
import ms from "ms" import ms from "ms"
@@ -23,18 +17,18 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to timeout") .setDescription("The user to timeout")
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option option
.setName("time") .setName("time")
.setDescription("The time to timeout the user for") .setDescription("The time to timeout the user for")
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option option
.setName("reason") .setName("reason")
.setDescription("The reason for the timeout"), .setDescription("The reason for the timeout")
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -44,8 +38,7 @@ export = {
const target = interaction.options.getMember("user")! as GuildMember const target = interaction.options.getMember("user")! as GuildMember
const timeString = interaction.options.getString("time")! const timeString = interaction.options.getString("time")!
const reason = const reason = interaction.options.getString("reason") || "No reason provided"
interaction.options.getString("reason") || "No reason provided"
const mod = interaction.member! as GuildMember const mod = interaction.member! as GuildMember
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const time = ms(timeString) const time = ms(timeString)
@@ -54,65 +47,50 @@ export = {
if (target.user.bot) { if (target.user.bot) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "You cannot timeout a bot.",
description: "You cannot timeout a bot.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
if (target.id == interaction.guild!.ownerId) { if (target.id == interaction.guild!.ownerId) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "You cannot timeout the server owner.",
description: "You cannot timeout the server owner.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
if ( if (interaction.guild!.members.me!.roles.highest.position <= target.roles.highest.position) {
interaction.guild!.members.me!.roles.highest.position <=
target.roles.highest.position
) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "I cannot timeout this user because their role is higher than mine.",
description: color: embedColor
"I cannot timeout this user because their role is higher than mine.", }]
color: embedColor,
},
],
}) })
return return
} }
if (mod.roles.highest.position <= target.roles.highest.position) { if (mod.roles.highest.position <= target.roles.highest.position) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "You cannot timeout this user because their role is higher than yours.",
description: color: embedColor
"You cannot timeout this user because their role is higher than yours.", }]
color: embedColor,
},
],
}) })
return return
} }
if (target.id == interaction.user.id) { if (target.id == interaction.user.id) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "You cannot timeout yourself.",
description: "You cannot timeout yourself.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -123,75 +101,55 @@ export = {
if (target.isCommunicationDisabled()) { if (target.isCommunicationDisabled()) {
if (time === 0) { if (time === 0) {
title = "Timeout Removed" title = "Timeout Removed"
;(description = description = "Removed timeout of " + userMention(target.id) + " for " + reason
"Removed timeout of " + timeouttime = null
userMention(target.id) +
" for " +
reason),
(timeouttime = null)
} else { } else {
title = "Timeout Updated" title = "Timeout Updated"
;(description = description = "Updated timeout of " + userMention(target.id) + " to " + prettyTime + " for " + reason
"Updated timeout of " + timeouttime = time
userMention(target.id) +
" to " +
prettyTime +
" for " +
reason),
(timeouttime = time)
} }
} else { } else {
title = "Member Timed Out" title = "Member Timed Out"
;(description = description = "Timed out " + userMention(target.id) + " for " + prettyTime + " for " + reason
"Timed out " + timeouttime = time
userMention(target.id) +
" for " +
prettyTime +
" for " +
reason),
(timeouttime = time)
} }
await target.timeout(timeouttime, reason) await target.timeout(timeouttime, reason)
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: mod.user.username,
name: mod.user.username, icon_url: mod.user.avatarURL() || undefined
icon_url: mod.user.avatarURL() || undefined, },
}, title: title,
title: title, description: `
description: `
**User:** ${userMention(target.id)} **User:** ${userMention(target.id)}
${timeouttime === null ? "**Time:** `None`" : "**Time:** `" + prettyTime + "`"} ${timeouttime === null ? "**Time:** `None`" : "**Time:** `" + prettyTime + "`"}
**Reason:** \`${reason}\` **Reason:** \`${reason}\`
**Mod:** ${userMention(mod.id)} **Mod:** ${userMention(mod.id)}
`, `,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: mod.user.avatarURL() || "", url: mod.user.avatarURL() || ""
},
footer: {
text: "ID: " + target.id,
icon_url: target.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
text: "ID: " + target.id,
icon_url: target.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: description,
description: description, color: embedColor,
color: embedColor, footer: {
footer: { text: interaction.guild!.name + " | " + devMessage,
text: interaction.guild!.name + " | " + devMessage, icon_url: interaction.guild!.iconURL() || undefined
icon_url: interaction.guild!.iconURL() || undefined, }
}, }]
},
],
}) })
}, }
} as Command } as Command

View File

@@ -1,9 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention, User } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
User,
} from "discord.js"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import { Command } from "interfaces" import { Command } from "interfaces"
import logToChannel from "utils/functions/logtochannel" import logToChannel from "utils/functions/logtochannel"
@@ -22,13 +17,13 @@ export = {
.setName("user") .setName("user")
.setDescription("The user to unban") .setDescription("The user to unban")
.setAutocomplete(true) .setAutocomplete(true)
.setRequired(true), .setRequired(true)
) )
.addStringOption(option => .addStringOption(option =>
option option
.setName("reason") .setName("reason")
.setDescription("The reason for unbanning the user") .setDescription("The reason for unbanning the user")
.setRequired(false), .setRequired(false)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers) .setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.setDMPermission(false), .setDMPermission(false),
@@ -37,20 +32,17 @@ export = {
await interaction.deferReply() await interaction.deferReply()
const userid = interaction.options.getString("user")! const userid = interaction.options.getString("user")!
const reason = const reason = interaction.options.getString("reason") || "No reason provided"
interaction.options.getString("reason") || "No reason provided"
const mod = interaction.user const mod = interaction.user
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
let user: User let user: User
if (userid === "none") { if (userid === "none") {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "You haven't specified a user to unban",
description: "You haven't specified a user to unban", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -59,12 +51,10 @@ export = {
user = await interaction.client.users.fetch(userid) user = await interaction.client.users.fetch(userid)
} catch (error) { } catch (error) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "The user you specified is not valid",
description: "The user you specified is not valid", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -72,54 +62,44 @@ export = {
await interaction.guild!.members.unban(user.id, reason) await interaction.guild!.members.unban(user.id, reason)
await logToChannel("mod", { await logToChannel("mod", {
embeds: [ embeds: [{
{ author: {
author: { name: mod.username,
name: mod.username, icon_url: mod.avatarURL() || undefined
icon_url: mod.avatarURL() || undefined,
},
title: "Member Unbanned",
description: `
**User:** ${userMention(user!.id)}
**Mod:** ${userMention(mod.id)}
**Reason:** ${reason}
`,
color: embedColor,
thumbnail: {
url: mod.avatarURL() || "",
},
footer: {
text: "ID: " + user!.id,
icon_url: user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], title: "Member Unbanned",
description: `
**User:** ${userMention(user!.id)}
**Mod:** ${userMention(mod.id)}
**Reason:** ${reason}
`,
color: embedColor,
thumbnail: {
url: mod.avatarURL() || ""
},
footer: {
text: "ID: " + user!.id,
icon_url: user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "User unbanned",
title: "User unbanned", description: "The user " + user!.username + " has been unbanned.\n" +
description: "**Reason:** `" + reason + "`\n" +
"The user " + "**Moderator:** " + userMention(mod.id),
user!.username + color: embedColor,
" has been unbanned.\n" + thumbnail: {
"**Reason:** `" + url: user!.avatarURL() || ""
reason +
"`\n" +
"**Moderator:** " +
userMention(mod.id),
color: embedColor,
thumbnail: {
url: user!.avatarURL() || "",
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
}) })
}, }
} as Command } as Command

View File

@@ -25,28 +25,23 @@ export = {
if (!verifyData) { if (!verifyData) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "You are not verified. Please run `/verify` to verify yourself",
description: color: embedColor,
"You are not verified. Please run `/verify` to verify yourself", footer: {
color: embedColor, text: interaction.guild!.name + " | " + devMessage,
footer: { icon_url: interaction.guild!.iconURL() || undefined
text: interaction.guild!.name + " | " + devMessage, }
icon_url: interaction.guild!.iconURL() || undefined, }]
},
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = await getGuild(verifyData.uuid) const guild = await getGuild(verifyData.uuid)
@@ -61,139 +56,87 @@ export = {
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
if (guildID !== hypixelGuildID) { if (guildID !== hypixelGuildID) {
const roles = roleManage("default") const roles = roleManage("default")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User used the update command")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User used the update command")
"User used the update command",
)
await user.roles.add(
roles.rolesToAdd,
"User used the update command",
)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Updated your roles to `Default Member`",
description: "Updated your roles to `Default Member`", color: embedColor,
color: embedColor, thumbnail: {
thumbnail: { url: head!
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
return return
} }
if (guildID === hypixelGuildID) { if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find( const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid)!.rank
member => member.uuid === verifyData.uuid,
)!.rank
let replyRank: string | null = null let replyRank: string | null = null
await user.roles.add( await user.roles.add(roleManage("default").rolesToAdd, "User used the update command")
roleManage("default").rolesToAdd,
"User used the update command",
)
if (guildRank === "Guild Master") { if (guildRank === "Guild Master") {
const roles = roleManage("gm") const roles = roleManage("gm")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User used the update command")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User used the update command")
"User used the update command",
)
await user.roles.add(
roles.rolesToAdd,
"User used the update command",
)
replyRank = "Guild Master" replyRank = "Guild Master"
} }
if (guildRank === "Manager") { if (guildRank === "Manager") {
const roles = roleManage("manager") const roles = roleManage("manager")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User used the update command")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User used the update command")
"User used the update command",
)
await user.roles.add(
roles.rolesToAdd,
"User used the update command",
)
replyRank = "Manager" replyRank = "Manager"
} }
if (guildRank === "Moderator") { if (guildRank === "Moderator") {
const roles = roleManage("moderator") const roles = roleManage("moderator")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User used the update command")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User used the update command")
"User used the update command",
)
await user.roles.add(
roles.rolesToAdd,
"User used the update command",
)
replyRank = "Moderator" replyRank = "Moderator"
} }
if (guildRank === "Beast") { if (guildRank === "Beast") {
const roles = roleManage("beast") const roles = roleManage("beast")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User used the update command")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User used the update command")
"User used the update command",
)
await user.roles.add(
roles.rolesToAdd,
"User used the update command",
)
replyRank = "Beast" replyRank = "Beast"
} }
if (guildRank === "Elite") { if (guildRank === "Elite") {
const roles = roleManage("elite") const roles = roleManage("elite")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User used the update command")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User used the update command")
"User used the update command",
)
await user.roles.add(
roles.rolesToAdd,
"User used the update command",
)
replyRank = "Elite" replyRank = "Elite"
} }
if (guildRank === "Member") { if (guildRank === "Member") {
const roles = roleManage("member") const roles = roleManage("member")
await user.roles.remove( await user.roles.remove(roles.rolesToRemove, "User used the update command")
roles.rolesToRemove, await user.roles.add(roles.rolesToAdd, "User used the update command")
"User used the update command",
)
await user.roles.add(
roles.rolesToAdd,
"User used the update command",
)
replyRank = "Member" replyRank = "Member"
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Updated your roles to `" + replyRank + "`",
description: color: embedColor,
"Updated your roles to `" + replyRank + "`", thumbnail: {
color: embedColor, url: head!
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
} }
}, }
} as Command } as Command

View File

@@ -16,7 +16,7 @@ export = {
option option
.setName("ign") .setName("ign")
.setDescription("Player's name") .setDescription("Player's name")
.setRequired(true), .setRequired(true)
) )
.setDMPermission(false), .setDMPermission(false),
@@ -32,37 +32,28 @@ export = {
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player doesn't exist!",
description: "That player doesn't exist!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: newIgn,
title: newIgn, description: "**UUID:** `" + uuid + "`\n" +
description: "**Formatted UUID:** `" + formattedUuid + "`",
"**UUID:** `" + color: embedColor,
uuid + thumbnail: {
"`\n" + url: head!
"**Formatted UUID:** `" +
formattedUuid +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
}, }
} as Command } as Command

View File

@@ -21,7 +21,7 @@ export = {
option option
.setName("ign") .setName("ign")
.setDescription("Your in-game name.") .setDescription("Your in-game name.")
.setRequired(true), .setRequired(true)
) )
.setDMPermission(false), .setDMPermission(false),
@@ -34,69 +34,53 @@ export = {
const verifyData = await verify.findOne({ userID: user.id }) const verifyData = await verify.findOne({ userID: user.id })
if (verifyData) { if (verifyData) {
interaction.editReply( interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
"You are already verified.\n" +
"Try running /update to update your roles.",
)
return return
} }
if (!ign) { if (!ign) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:cross_a:1087808606897983539> Please provide your in-game name.",
description: color: embedColor
"<a:cross_a:1087808606897983539> Please provide your in-game name.", }]
color: embedColor,
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your uuid...",
description: "Fetching your uuid...", color: embedColor
color: embedColor, }]
},
],
}) })
const uuid = await getUUID(ign) const uuid = await getUUID(ign)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player does not exist.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player does not exist.", }]
color: embedColor,
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your player data...",
description: "Fetching your player data...", color: embedColor
color: embedColor, }]
},
],
}) })
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
const player = (await getPlayer(uuid)) as PlayerData const player = (await getPlayer(uuid)) as PlayerData
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.", }]
color: embedColor,
},
],
}) })
return return
} }
@@ -109,60 +93,40 @@ export = {
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Checking your Discord tag...",
description: "Checking your Discord tag...", color: embedColor
color: embedColor, }]
},
],
}) })
const linkedDiscord = player?.socialMedia?.links?.DISCORD || null const linkedDiscord = player?.socialMedia?.links?.DISCORD || null
if (!linkedDiscord) { if (!linkedDiscord) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + player.displayname + "`.\n\n" +
description: "**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
"<a:cross_a:1087808606897983539> There is no Discord account linked to `" + color: embedColor
player.displayname + }]
"`.\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
}) })
return return
} }
if (linkedDiscord !== username) { if (linkedDiscord !== username) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:cross_a:1087808606897983539> The Discord account linked to `" + player.displayname + "` is currently `" + linkedDiscord + "`\n\n" +
description: "**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
"<a:cross_a:1087808606897983539> The Discord account linked to `" + color: embedColor
player.displayname + }]
"` is currently `" +
linkedDiscord +
"`\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
}) })
return return
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "Fetching your guild data...",
description: "Fetching your guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = (await getGuild(uuid)) as GuildData | null const guild = (await getGuild(uuid)) as GuildData | null
@@ -175,9 +139,7 @@ export = {
if (guildID === hypixelGuildID) { if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find( const guildRank = GuildMembers.find(member => member.uuid === player.uuid)!.rank
member => member.uuid === player.uuid,
)!.rank
if (guildRank === "Guild Master") { if (guildRank === "Guild Master") {
const roles = roleManage("gm") const roles = roleManage("gm")
@@ -215,31 +177,24 @@ export = {
const newVerify = new verify({ const newVerify = new verify({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.id, userID: user.id,
uuid: uuid, uuid: uuid
}) })
await newVerify.save() await newVerify.save()
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: interaction.guild!.name,
title: interaction.guild!.name, description: "You have successfully verified `" + username + "` with the account `" + player.displayname + "`.",
description: color: embedColor,
"You have successfully verified `" + thumbnail: {
username + url: head!
"` with the account `" +
player.displayname +
"`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
}) })
}, }
} as Command } as Command

View File

@@ -24,12 +24,10 @@ export = {
if (!verifyData) { if (!verifyData) {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "You are not verified!",
description: "You are not verified!", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -38,25 +36,19 @@ export = {
const head = await getHeadURL(ign!) const head = await getHeadURL(ign!)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "User Info",
title: "User Info", description: "**User:** " + userMention(user.id) +
description: "\n**IGN:** `" + ign + "`",
"**User:** " + color: embedColor,
userMention(user.id) + thumbnail: {
"\n**IGN:** `" + url: head!
ign +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
}, }
} as Command } as Command

View File

@@ -1,8 +1,4 @@
import { import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { getIGN, getHeadURL } from "utils/Hypixel" import { getIGN, getHeadURL } from "utils/Hypixel"
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import verify from "schemas/verifySchema" import verify from "schemas/verifySchema"
@@ -21,7 +17,7 @@ export = {
option option
.setName("user") .setName("user")
.setDescription("The user to get the ign of.") .setDescription("The user to get the ign of.")
.setRequired(true), .setRequired(true)
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
@@ -34,9 +30,7 @@ export = {
const verifiedUser = await verify.findOne({ userID: user.id }) const verifiedUser = await verify.findOne({ userID: user.id })
if (!verifiedUser) { if (!verifiedUser) {
interaction.editReply({ interaction.editReply("You are not verified!")
content: "This user has not verified their account.",
})
return return
} }
@@ -44,24 +38,19 @@ export = {
const head = await getHeadURL(ign) const head = await getHeadURL(ign)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: interaction.guild!.name,
title: interaction.guild!.name, description: "**User:** " + userMention(user.id) +
description: "\n**IGN:** " + ign,
"**User:** " + color: embedColor,
userMention(user.id) + thumbnail: {
"\n**IGN:** " + url: head!
ign,
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
}
}]
}) })
}, }
} as Command } as Command

View File

@@ -9,29 +9,23 @@ export = {
if (focusedOption.name !== "user") return if (focusedOption.name !== "user") return
if (focusedOption.value === "") { if (focusedOption.value === "") {
await interaction.respond([ await interaction.respond([{
{ name: "Please start typing a username to unban",
name: "Please start typing a username to unban", value: "none"
value: "none", }])
},
])
return return
} }
const bannedUsers = await interaction.guild!.bans.fetch() const bannedUsers = await interaction.guild!.bans.fetch()
const filteredUsers = bannedUsers.filter(user => const filteredUsers = bannedUsers.filter(user => user.user.username.toLowerCase().includes(focusedOption.value.toLowerCase()))
user.user.username
.toLowerCase()
.includes(focusedOption.value.toLowerCase()),
)
const results = filteredUsers.map(user => ({ const results = filteredUsers.map(user => ({
name: user.user.username, name: user.user.username,
value: user.user.id, value: user.user.id
})) }))
await interaction.respond(results.slice(0, 25)).catch(err => { await interaction.respond(results.slice(0, 25)).catch(err => {
console.log(err) console.log(err)
}) })
}, }
} as Autocomplete } as Autocomplete

View File

@@ -1,22 +1,7 @@
import { color, devMessage } from "config/options.json" import { color, devMessage } from "config/options.json"
import guildapp from "schemas/guildAppSchema" import guildapp from "schemas/guildAppSchema"
import { import { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "config/reqs.json"
bwfkdr, import { hypixelLevel, bedwarsLevel, skywarsLevel, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
bwstars,
bwwins,
swstars,
swkdr,
duelswins,
duelswlr,
} from "config/reqs.json"
import {
hypixelLevel,
bedwarsLevel,
skywarsLevel,
getPlayer,
getGuild,
getHeadURL,
} from "utils/Hypixel"
import { Button } from "interfaces" import { Button } from "interfaces"
export = { export = {
@@ -36,13 +21,10 @@ export = {
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "That player hasn't played Hypixel before.",
description: color: embedColor
"That player hasn't played Hypixel before.", }]
color: embedColor,
},
],
}) })
return return
} }
@@ -93,153 +75,106 @@ export = {
if (!player.stats) { if (!player.stats) {
statsFields.push({ statsFields.push({
name: "<a:_warning:1178350183457751100> This player never played any games.", name: "<a:_warning:1178350183457751100> This player never played any games.",
value: "**➺ Stats:** `None`", value: "**➺ Stats:** `None`"
}) })
} else { } else {
if (player.stats.Bedwars) { if (player.stats.Bedwars) {
const hsbwexp = player.stats?.Bedwars?.Experience || 0 const hsbwexp = player.stats.Bedwars?.Experience || 0
const hsbwfk = player.stats.Bedwars?.final_kills_bedwars || 0
const hsbwfd = player.stats.Bedwars?.final_deaths_bedwars || 0
const hsbwwins = player.stats.Bedwars?.wins_bedwars || 0
const hsbwstars = bedwarsLevel(hsbwexp) const hsbwstars = bedwarsLevel(hsbwexp)
const hsbwfk = player.stats?.Bedwars?.final_kills_bedwars || 0
const hsbwfd = player.stats?.Bedwars?.final_deaths_bedwars || 0
const hsbwfkdr = hsbwfk / hsbwfd || 0 const hsbwfkdr = hsbwfk / hsbwfd || 0
const hsbwwins = player.stats?.Bedwars?.wins_bedwars || 0
let bwtitle = "" let bwtitle = ""
if ( if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
hsbwstars < bwstars || bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
hsbwfkdr < bwfkdr ||
hsbwwins < bwwins
) {
bwtitle =
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
} else { } else {
bwtitle = bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements."
"<a:check_a:1087808632172847134> This player meets the BedWars requirements."
} }
statsFields.push({ statsFields.push({
name: bwtitle, name: bwtitle,
value: value: "**➺ Stars:** `" + hsbwstars.toFixed(2).toString() +
"**➺ Stars:** `" + " / " + bwstars.toString() + "`\n" +
hsbwstars.toFixed(2).toString() + "**➺ FKDR:** `" + hsbwfkdr.toFixed(2).toString() +
" / " + " / " + bwfkdr.toString() + "`\n" +
bwstars.toString() + "**➺ Wins:** `" + hsbwwins.toString() +
"`\n" + " / " + bwwins.toString() + "`"
"**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() +
" / " +
bwfkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsbwwins.toString() +
" / " +
bwwins.toString() +
"`",
}) })
} }
if (player.stats.SkyWars) { if (player.stats.SkyWars) {
const hsswexp = player.stats?.SkyWars?.skywars_experience || 0 const hsswexp = player.stats.SkyWars?.skywars_experience || 0
const hsswkills = player.stats.SkyWars?.kills || 0
const hsswdeaths = player.stats.SkyWars?.deaths || 0
const hsswwins = player.stats.SkyWars?.wins || 0
const hsswstars = skywarsLevel(hsswexp) const hsswstars = skywarsLevel(hsswexp)
const hsswkills = player.stats?.SkyWars?.kills || 0
const hsswdeaths = player.stats?.SkyWars?.deaths || 0
const hsswkd = hsswkills / hsswdeaths const hsswkd = hsswkills / hsswdeaths
const hsswwins = player.stats?.SkyWars?.wins || 0
let swtitle = "" let swtitle = ""
if (hsswstars < swstars || hsswkd < swkdr) { if (hsswstars < swstars || hsswkd < swkdr) {
swtitle = swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
} else { } else {
swtitle = swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
"<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
} }
statsFields.push({ statsFields.push({
name: swtitle, name: swtitle,
value: value: "**➺ Stars:** `" + hsswstars.toFixed(2).toString() +
"**➺ Stars:** `" + " / " + swstars.toString() + "`\n" +
hsswstars.toFixed(2).toString() + "**➺ KDR:** `" + hsswkd.toFixed(2).toString() +
" / " + " / " + swkdr.toString() + "`\n" +
swstars.toString() + "**➺ Wins:** `" + hsswwins.toString() + "`"
"`\n" +
"**➺ KDR:** `" +
hsswkd.toFixed(2).toString() +
" / " +
swkdr.toString() +
"`\n" +
"**➺ Wins:** `" +
hsswwins.toString() +
"`",
}) })
} }
if (player.stats.Duels) { if (player.stats.Duels) {
const hsduelskills = player.stats?.Duels?.kills || 0 const hsduelskills = player.stats.Duels?.kills || 0
const hsduelsdeaths = player.stats?.Duels?.deaths || 0 const hsduelsdeaths = player.stats.Duels?.deaths || 0
const hsduelswins = player.stats.Duels?.wins || 0
const hsduelslosses = player.stats.Duels?.losses || 0
const hsduelskd = hsduelskills / hsduelsdeaths const hsduelskd = hsduelskills / hsduelsdeaths
const hsduelswins = player.stats?.Duels?.wins || 0
const hsduelslosses = player.stats?.Duels?.losses || 0
const hsduelswlr = hsduelswins / hsduelslosses const hsduelswlr = hsduelswins / hsduelslosses
let duelstitle = "" let duelstitle = ""
if (hsduelswins < duelswins || hsduelswlr < duelswlr) { if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
duelstitle = duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
} else { } else {
duelstitle = duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
"<a:check_a:1087808632172847134> This player meets the Duels requirements."
} }
statsFields.push({ statsFields.push({
name: duelstitle, name: duelstitle,
value: value: "**➺ Wins:** `" + hsduelswins.toString() +
"**➺ Wins:** `" + " / " + duelswins.toString() + "`\n" +
hsduelswins.toString() + "**➺ WLR:** `" + hsduelswlr.toFixed(2).toString() +
" / " + " / " + duelswlr.toString() + "`\n" +
duelswins.toString() + "**➺ KDR:** `" + hsduelskd.toFixed(2).toString() + "`"
"`\n" +
"**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() +
" / " +
duelswlr.toString() +
"`\n" +
"**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() +
"`",
}) })
} }
} }
// network level // network level
const hypixelExp = player.networkExp || 0 const hypixelExp = player?.networkExp || 0
const level = hypixelLevel(hypixelExp) const level = hypixelLevel(hypixelExp)
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: rank + player.displayname + guildTag,
title: rank + player.displayname + guildTag, description: "**Network Level:** `" + level.toFixed(2).toString() + "`\n" +
description: "**Current Guild:** `" + guildName + "`\n" +
"**Network Level:** `" + "**Guild Rank:** `" + guildRank + "`",
level.toFixed(2).toString() + color: embedColor,
"`\n" + thumbnail: {
"**Current Guild:** `" + url: head!
guildName +
"`\n" +
"**Guild Rank:** `" +
guildRank +
"`",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined,
},
fields: statsFields,
}, },
], footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL() || undefined
},
fields: statsFields
}]
}) })
}, }
} as Button } as Button

View File

@@ -1,15 +1,5 @@
import { import { ActionRowBuilder, ButtonStyle, ButtonBuilder, TextChannel } from "discord.js"
ActionRowBuilder, import { color, waitingListChannel, waitingListMessage, hypixelGuildID } from "config/options.json"
ButtonStyle,
ButtonBuilder,
TextChannel,
} from "discord.js"
import {
color,
waitingListChannel,
waitingListMessage,
hypixelGuildID,
} from "config/options.json"
import colorLog from "utils/functions/colors" import colorLog from "utils/functions/colors"
import mongoose from "mongoose" import mongoose from "mongoose"
import guildapp from "schemas/guildAppSchema" import guildapp from "schemas/guildAppSchema"
@@ -35,8 +25,7 @@ export = {
const applicantIGN = embed.fields[0].value.replaceAll("`", "") const applicantIGN = embed.fields[0].value.replaceAll("`", "")
const applicant = await guild.members.fetch(applicantId) const applicant = await guild.members.fetch(applicantId)
const applicantUsername = const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator
applicant.user.username + "#" + applicant.user.discriminator
await message.edit({ await message.edit({
components: [ components: [
@@ -55,20 +44,17 @@ export = {
.setCustomId("checkstats") .setCustomId("checkstats")
.setLabel("Check Stats") .setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary) .setStyle(ButtonStyle.Secondary)
.setDisabled(true), .setDisabled(true)
), )
], ]
}) })
await applicant.send({ await applicant.send({
embeds: [ embeds: [{
{ description: "Your application for the Illegitimate guild has been accepted.\n\n" +
description: "Make sure to leave your current guild so that we can invite you.",
"Your application for the Illegitimate guild has been accepted.\n\n" + color: embedColor
"Make sure to leave your current guild so that we can invite you.", }]
color: embedColor,
},
],
}) })
const applicantEntry = await guildapp.findOne({ userID: applicantId }) const applicantEntry = await guildapp.findOne({ userID: applicantId })
@@ -80,7 +66,7 @@ export = {
userID: applicantId, userID: applicantId,
uuid: applicantUUID, uuid: applicantUUID,
IGN: applicantIGN, IGN: applicantIGN,
timestamp: time, timestamp: time
}) })
await waitingListAdd.save() await waitingListAdd.save()
@@ -89,28 +75,23 @@ export = {
await guildapp.findOneAndDelete({ userID: applicantId }) await guildapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: applicantUsername + " - Guild Application",
title: applicantUsername + " - Guild Application", description: "Application has been accepted by <@" + user.id + ">.",
description: color: embedColor,
"Application has been accepted by <@" + user.id + ">.", thumbnail: {
color: embedColor, url: applicant.avatarURL() || ""
thumbnail: {
url: applicant.avatarURL() || "",
},
footer: {
icon_url: guild.iconURL() || undefined,
text: "ID: " + applicant.id,
},
}, },
], footer: {
icon_url: guild.iconURL() || undefined,
text: "ID: " + applicant.id
}
}]
}) })
if (process.env.NODE_ENV === "dev") return if (process.env.NODE_ENV === "dev") return
try { try {
const channel = guild.channels.cache.get( const channel = guild.channels.cache.get(waitingListChannel) as TextChannel
waitingListChannel,
) as TextChannel
const wlmessage = await channel!.messages.fetch(waitingListMessage) const wlmessage = await channel!.messages.fetch(waitingListMessage)
const wlembed = wlmessage.embeds[0] const wlembed = wlmessage.embeds[0]
@@ -133,30 +114,28 @@ export = {
fields.push({ fields.push({
name: `${i + 1}. ${accepted[i].IGN}`, name: `${i + 1}. ${accepted[i].IGN}`,
value: `TS: <t:${timestamp}:R>`, value: `TS: <t:${timestamp}:R>`
}) })
} }
await wlmessage.edit({ await wlmessage.edit({
embeds: [ embeds: [{
{ title: wlembed.title!,
title: wlembed.title!, description: wlembed.description!,
description: wlembed.description!, color: wlembed.color!,
color: wlembed.color!, footer: {
footer: { text: "Last updated by " + user.username,
text: "Last updated by " + user.username, icon_url: user.avatarURL() || undefined
icon_url: user.avatarURL() || undefined,
},
thumbnail: wlembed.thumbnail!,
fields: fields,
timestamp: new Date().toISOString(),
}, },
], thumbnail: wlembed.thumbnail!,
fields: fields,
timestamp: new Date().toISOString()
}]
}) })
} catch (err) { } catch (err) {
console.log( console.log(
colorLog("Error while trying to update waiting list.", "red"), colorLog("Error while trying to update waiting list.", "red")
) )
} }
}, }
} as Button } as Button

View File

@@ -1,9 +1,4 @@
import { import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js"
ModalBuilder,
ActionRowBuilder,
TextInputBuilder,
TextInputStyle,
} from "discord.js"
import { Button } from "interfaces" import { Button } from "interfaces"
export = { export = {
@@ -20,12 +15,10 @@ export = {
.setLabel("Deny Reason") .setLabel("Deny Reason")
.setCustomId("denyreason") .setCustomId("denyreason")
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setPlaceholder( .setPlaceholder("Enter a reason for denying the application")
"Enter a reason for denying the application", .setRequired(false)
) )
.setRequired(false),
),
) )
await interaction.showModal(modal) await interaction.showModal(modal)
}, }
} as Button } as Button

File diff suppressed because it is too large Load Diff

View File

@@ -1,35 +1,13 @@
import { import { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder, GuildMember, TextChannel } from "discord.js"
ButtonBuilder, import { gm, manager, moderator, beast, member, guildStaff, guildRole } from "config/roles.json"
ActionRowBuilder,
ButtonStyle,
EmbedBuilder,
GuildMember,
TextChannel,
} from "discord.js"
import {
gm,
manager,
moderator,
beast,
member,
guildStaff,
guildRole,
} from "config/roles.json"
import { ignM, smallM, largeM } from "config/limitmessages.json" import { ignM, smallM, largeM } from "config/limitmessages.json"
import { inactivity } from "config/questions.json" import { inactivity } from "config/questions.json"
import { color, inactivityLogChannel } from "config/options.json" import { color, inactivityLogChannel } from "config/options.json"
import { Button } from "interfaces" import { Button } from "interfaces"
const guildRoles = [ import { getIGN } from "utils/Hypixel"
gm, const guildRoles = [gm, manager, moderator, beast, member, guildStaff, guildRole]
manager,
moderator,
beast,
member,
guildStaff,
guildRole,
]
module.exports = { export = {
name: "guildinactivitylog", name: "guildinactivitylog",
description: "Configure the bot.", description: "Configure the bot.",
@@ -38,12 +16,11 @@ module.exports = {
const user = interaction.member as GuildMember const user = interaction.member as GuildMember
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const userRoles = user.roles.cache const userRoles = user.roles.cache
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"
if (!userRoles.some(role => guildRoles.includes(role.id))) { if (!userRoles.some(role => guildRoles.includes(role.id))) {
return await interaction.reply({ return await interaction.reply({
content: "Only guild members can use this button.", content: "Only guild members can use this button.",
ephemeral: true, ephemeral: true
}) })
} }
@@ -62,42 +39,37 @@ module.exports = {
.setDescription("You have cancelled your application.") .setDescription("You have cancelled your application.")
.setColor(embedColor) .setColor(embedColor)
const attachments = new EmbedBuilder() const attachments = new EmbedBuilder()
.setDescription( .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
"You have uploaded an attachment. Please do not upload images, videos, or GIFS.",
)
.setColor(embedColor) .setColor(embedColor)
try { try {
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "Guild Inactivity Log",
title: "Guild Inactivity Log", description: "Please answer the following questions to submit an inactivity log for the guild.\n" +
description: "If you wish to cancel your form, please press type `cancel` at any time.\n" +
"Please answer the following questions to submit an inactivity log for the guild.\n" + "If you wish to proceed with your form, please type `yes`.\n\n" +
"If you wish to cancel your form, please press type `cancel` at any time.\n" + "**Do not upload images, videos, or GIFS.**\n" +
"If you wish to proceed with your form, please type `yes`.\n\n" + "You have a minute to respond to this message.",
"**Do not upload images, videos, or GIFS.**\n" + color: embedColor
"You have a minute to respond to this message.", }]
color: embedColor,
},
],
}) })
} catch (error) { } catch (error) {
return await interaction.reply({ return await interaction.reply({
content: "Please enable your DMs.", content: "Please enable your DMs.",
ephemeral: true, ephemeral: true
}) })
} }
await interaction.reply({ await interaction.reply({
content: "Please check your DMs.", content: "Please check your DMs.",
ephemeral: true, ephemeral: true
}) })
const input = await user.dmChannel!.awaitMessages({ const input = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60, time: 1000 * 60
}) })
if (input.first()!.attachments.size > 0) { if (input.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] }) await user.send({ embeds: [attachments] })
@@ -113,26 +85,20 @@ module.exports = {
} }
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 1**",
title: "**Question 1**", description: sq(1) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`",
description: color: embedColor,
sq(1) + footer: {
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + text: "You have 5 minutes to respond to this message."
ignM + }
"`", }]
color: embedColor,
footer: {
text: "You have 5 minutes to respond to this message.",
},
},
],
}) })
const answer1 = await user.dmChannel!.awaitMessages({ const answer1 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5, time: 1000 * 60 * 5
}) })
if (answer1.first()!.attachments.size > 0) { if (answer1.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] }) await user.send({ embeds: [attachments] })
@@ -140,27 +106,10 @@ module.exports = {
} }
if (answer1.first()!.content.length > 16) { if (answer1.first()!.content.length > 16) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 16.",
description: "Max character limit is 16.", color: embedColor
color: embedColor, }]
},
],
})
return
}
try {
await fetch(mojangAPI + answer1.first()!.content)
} catch (error) {
await user.send({
embeds: [
{
description:
"That is not a valid Minecraft username.\n" +
"Application cancelled.",
color: embedColor,
},
],
}) })
return return
} }
@@ -172,28 +121,32 @@ module.exports = {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] })
return return
} }
if (await getIGN(answer1.first()!.content)) {
await user.send({
embeds: [{
description: "That is not a valid Minecraft username.\n" +
"Application cancelled.",
color: embedColor
}]
})
return
}
const answer1_1 = answer1.first()!.content const answer1_1 = answer1.first()!.content
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 2**",
title: "**Question 2**", description: sq(2) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`",
description: color: embedColor,
sq(2) + footer: {
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + text: "You have 5 minutes to respond to this message."
smallM + }
"`", }]
color: embedColor,
footer: {
text: "You have 5 minutes to respond to this message.",
},
},
],
}) })
const answer2 = await user.dmChannel!.awaitMessages({ const answer2 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5, time: 1000 * 60 * 5
}) })
if (answer2.first()!.attachments.size > 0) { if (answer2.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] }) await user.send({ embeds: [attachments] })
@@ -201,12 +154,10 @@ module.exports = {
} }
if (answer2.first()!.content.length > 128) { if (answer2.first()!.content.length > 128) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 128.",
description: "Max character limit is 128.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -221,25 +172,19 @@ module.exports = {
const answer2_1 = answer1.first()!.content const answer2_1 = answer1.first()!.content
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 3**",
title: "**Question 3**", description: sq(3) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
description: color: embedColor,
sq(3) + footer: {
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + text: "You have 15 minutes to respond to this message."
largeM + }
"`", }]
color: embedColor,
footer: {
text: "You have 15 minutes to respond to this message.",
},
},
],
}) })
const answer3 = await user.dmChannel!.awaitMessages({ const answer3 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15, time: 1000 * 60 * 15
}) })
if (answer3.first()!.attachments.size > 0) { if (answer3.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] }) await user.send({ embeds: [attachments] })
@@ -247,12 +192,10 @@ module.exports = {
} }
if (answer3.first()!.content.length > 256) { if (answer3.first()!.content.length > 256) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 256",
description: "Max character limit is 256", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -267,18 +210,15 @@ module.exports = {
const answer3_1 = answer1.first()!.content const answer3_1 = answer1.first()!.content
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "If you want to submit your application, type `yes` if not, type `no`",
description: color: embedColor
"If you want to submit your application, type `yes` if not, type `no`", }]
color: embedColor,
},
],
}) })
const final = await user.dmChannel!.awaitMessages({ const final = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5, time: 1000 * 60 * 5
}) })
if (final.first()!.attachments.size > 0) { if (final.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] }) await user.send({ embeds: [attachments] })
@@ -294,50 +234,40 @@ module.exports = {
} }
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Your application has been submitted!",
description: "Your application has been submitted!", color: embedColor
color: embedColor, }]
},
],
}) })
const appChannel = guild.channels.cache.get( const appChannel = guild.channels.cache.get(inactivityLogChannel) as TextChannel
inactivityLogChannel,
) as TextChannel
await appChannel.send({ await appChannel.send({
embeds: [ embeds: [{
{ title: user.user.username + "#" + user.user.discriminator + " - Inactivity Application",
title: color: embedColor,
user.user.username + thumbnail: {
"#" + url: user.avatarURL() || ""
user.user.discriminator +
" - Inactivity Application",
color: embedColor,
thumbnail: {
url: user.avatarURL() || "",
},
fields: [
{
name: rq(1),
value: "`" + answer1_1 + "`",
},
{
name: rq(2),
value: "`" + answer2_1 + "`",
},
{
name: rq(3),
value: "`" + answer3_1 + "`",
},
],
footer: {
icon_url: user.avatarURL() || undefined,
text: "ID: " + user.user.id,
},
}, },
], fields: [
{
name: rq(1),
value: "`" + answer1_1 + "`"
},
{
name: rq(2),
value: "`" + answer2_1 + "`"
},
{
name: rq(3),
value: "`" + answer3_1 + "`"
}
],
footer: {
icon_url: user.avatarURL() || undefined,
text: "ID: " + user.user.id
}
}],
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -347,9 +277,9 @@ module.exports = {
new ButtonBuilder() new ButtonBuilder()
.setCustomId("inactiveapplicationdeny") .setCustomId("inactiveapplicationdeny")
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger)
), )
], ]
}) })
}, }
} as Button } as Button

View File

@@ -7,7 +7,7 @@ export = {
async execute(interaction) { async execute(interaction) {
await interaction.reply({ await interaction.reply({
content: "This button is currently disabled.", content: "This button is currently disabled.",
ephemeral: true, ephemeral: true
}) })
}, }
} as Button } as Button

View File

@@ -7,7 +7,7 @@ export = {
async execute(interaction) { async execute(interaction) {
await interaction.reply({ await interaction.reply({
content: "This button is currently disabled.", content: "This button is currently disabled.",
ephemeral: true, ephemeral: true
}) })
}, }
} as Button } as Button

View File

@@ -19,17 +19,13 @@ export = {
const applicantId = embed.footer!.text.split(" ")[1] const applicantId = embed.footer!.text.split(" ")[1]
const applicant = await guild.members.fetch(applicantId) const applicant = await guild.members.fetch(applicantId)
const applicantUsername = const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator
applicant.user.username + "#" + applicant.user.discriminator
await applicant.send({ await applicant.send({
embeds: [ embeds: [{
{ description: "Your application for the Illegitimate staff team has been accepted.",
description: color: embedColor
"Your application for the Illegitimate staff team has been accepted.", }]
color: embedColor,
},
],
}) })
await message.edit({ await message.edit({
@@ -44,28 +40,26 @@ export = {
.setCustomId("staffapplicationdeny") .setCustomId("staffapplicationdeny")
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger) .setStyle(ButtonStyle.Danger)
.setDisabled(true), .setDisabled(true)
), )
], ]
}) })
await staffapp.findOneAndDelete({ userID: applicantId }) await staffapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: applicantUsername + " - Staff Application.",
title: applicantUsername + " - Staff Application.", description: "Application accepted by <@" + user.id + ">.",
description: "Application accepted by <@" + user.id + ">.", color: embedColor,
color: embedColor, thumbnail: {
thumbnail: { url: applicant.avatarURL() || ""
url: applicant.avatarURL() || "",
},
footer: {
icon_url: guild.iconURL() || undefined,
text: "ID: " + applicantId,
},
}, },
], footer: {
icon_url: guild.iconURL() || undefined,
text: "ID: " + applicantId
}
}]
}) })
}, }
} as Button } as Button

View File

@@ -1,9 +1,4 @@
import { import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js"
ModalBuilder,
ActionRowBuilder,
TextInputBuilder,
TextInputStyle,
} from "discord.js"
import { Button } from "interfaces" import { Button } from "interfaces"
export = { export = {
@@ -20,12 +15,10 @@ export = {
.setLabel("Deny Reason") .setLabel("Deny Reason")
.setCustomId("staffdenyreason") .setCustomId("staffdenyreason")
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setPlaceholder( .setPlaceholder( "Enter a reason for denying the application")
"Enter a reason for denying the application", .setRequired(false)
) )
.setRequired(false),
),
) )
await interaction.showModal(modal) await interaction.showModal(modal)
}, }
} as Button } as Button

View File

@@ -1,11 +1,4 @@
import { import { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder, GuildMember, TextChannel } from "discord.js"
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
EmbedBuilder,
GuildMember,
TextChannel,
} from "discord.js"
import { color, staffApplicationsChannel } from "config/options.json" import { color, staffApplicationsChannel } from "config/options.json"
import { largeM, ignM } from "config/limitmessages.json" import { largeM, ignM } from "config/limitmessages.json"
import questions from "config/questions.json" import questions from "config/questions.json"
@@ -43,17 +36,13 @@ export = {
if (user.user.id !== env.prod.dev) { if (user.user.id !== env.prod.dev) {
if (status === "0") { if (status === "0") {
await interaction.editReply( await interaction.editReply("Staff applications are currently closed.")
"Staff applications are currently closed.",
)
return return
} }
} }
if (!userRoles.has(guildRole)) { if (!userRoles.has(guildRole)) {
await interaction.editReply( await interaction.editReply("You must be a member of the guild to apply for staff.")
"You must be a member of the guild to apply for staff.",
)
return return
} }
@@ -65,9 +54,7 @@ export = {
const application = await staffapp.findOne({ userID: user.user.id }) const application = await staffapp.findOne({ userID: user.user.id })
if (application) { if (application) {
await interaction.editReply( await interaction.editReply("You already have an application in progress.")
"You already have an application in progress.",
)
return return
} }
@@ -78,23 +65,18 @@ export = {
.setDescription("You have cancelled your application.") .setDescription("You have cancelled your application.")
.setColor(embedColor) .setColor(embedColor)
const attachments = new EmbedBuilder() const attachments = new EmbedBuilder()
.setDescription( .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
"You have uploaded an attachment. Please do not upload images, videos, or GIFS.",
)
.setColor(embedColor) .setColor(embedColor)
try { try {
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "Staff Application",
title: "Staff Application", description: "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" +
description: "**Do not upload images, videos, or GIFS.**\n" +
"If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" + "You have a minute to respond to this message.",
"**Do not upload images, videos, or GIFS.**\n" + color: embedColor
"You have a minute to respond to this message.", }]
color: embedColor,
},
],
}) })
} catch (error) { } catch (error) {
await interaction.editReply("Please enable your DMs.") await interaction.editReply("Please enable your DMs.")
@@ -106,7 +88,7 @@ export = {
const input = await user.dmChannel!.awaitMessages({ const input = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60, time: 1000 * 60
}) })
if (input.size === 0) { if (input.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -123,25 +105,19 @@ export = {
// first question // first question
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 1**",
title: "**Question 1**", description: sq(1) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`",
description: color: embedColor,
sq(1) + footer: {
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + text: "You have 5 minutes to respond to this message."
ignM + }
"`", }]
color: embedColor,
footer: {
text: "You have 5 minutes to respond to this message.",
},
},
],
}) })
const answer1 = await user.dmChannel!.awaitMessages({ const answer1 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5, time: 1000 * 60 * 5
}) })
if (answer1.size === 0) { if (answer1.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -157,26 +133,21 @@ export = {
} }
if (answer1.first()!.content.length > 16) { if (answer1.first()!.content.length > 16) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 16.",
description: "Max character limit is 16.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
const uuid = await getUUID(answer1.first()!.content) const uuid = await getUUID(answer1.first()!.content)
if (!uuid) { if (!uuid) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "That is not a valid Minecraft username.\n" +
description: "Application cancelled.",
"That is not a valid Minecraft username.\n" + color: embedColor
"Application cancelled.", }]
color: embedColor,
},
],
}) })
return return
} }
@@ -184,24 +155,20 @@ export = {
// second question // second question
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 2**",
title: "**Question 2**", description: sq(2) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" +
description: "`(64 characters max)`",
sq(2) + color: embedColor,
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + footer: {
"`(64 characters max)`", text: "You have 15 minutes to respond to this message."
color: embedColor, }
footer: { }]
text: "You have 15 minutes to respond to this message.",
},
},
],
}) })
const answer2 = await user.dmChannel!.awaitMessages({ const answer2 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15, time: 1000 * 60 * 15
}) })
if (answer2.size === 0) { if (answer2.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -217,12 +184,10 @@ export = {
} }
if (answer2.first()!.content.length > 64) { if (answer2.first()!.content.length > 64) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 64.",
description: "Max character limit is 64.", color: embedColor
color: embedColor, }]
},
],
}) })
return return
} }
@@ -230,25 +195,19 @@ export = {
// third question // third question
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 3**",
title: "**Question 3**", description: sq(3) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
description: color: embedColor,
sq(3) + footer: {
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + text: "You have 15 minutes to respond to this message."
largeM + }
"`", }]
color: embedColor,
footer: {
text: "You have 15 minutes to respond to this message.",
},
},
],
}) })
const answer3 = await user.dmChannel!.awaitMessages({ const answer3 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15, time: 1000 * 60 * 15
}) })
if (answer3.size === 0) { if (answer3.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -264,37 +223,29 @@ export = {
} }
if (answer3.first()!.content.length > 256) { if (answer3.first()!.content.length > 256) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 256.",
description: "Max character limit is 256.", color: embedColor
color: embedColor, }]
},
],
}) })
} }
const answer3_1 = answer3.first()!.content const answer3_1 = answer3.first()!.content
// fourth question // fourth question
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 4**",
title: "**Question 4**", description: sq(4) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
description: color: embedColor,
sq(4) + footer: {
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + text: "You have 15 minutes to respond to this message."
largeM + }
"`", }]
color: embedColor,
footer: {
text: "You have 15 minutes to respond to this message.",
},
},
],
}) })
const answer4 = await user.dmChannel!.awaitMessages({ const answer4 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15, time: 1000 * 60 * 15
}) })
if (answer4.size === 0) { if (answer4.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -310,37 +261,29 @@ export = {
} }
if (answer4.first()!.content.length > 256) { if (answer4.first()!.content.length > 256) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 256.",
description: "Max character limit is 256.", color: embedColor
color: embedColor, }]
},
],
}) })
} }
const answer4_1 = answer4.first()!.content const answer4_1 = answer4.first()!.content
// fifth question // fifth question
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 5**",
title: "**Question 5**", description: sq(5) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
description: color: embedColor,
sq(5) + footer: {
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + text: "You have 15 minutes to respond to this message."
largeM + }
"`", }]
color: embedColor,
footer: {
text: "You have 15 minutes to respond to this message.",
},
},
],
}) })
const answer5 = await user.dmChannel!.awaitMessages({ const answer5 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15, time: 1000 * 60 * 15
}) })
if (answer5.size === 0) { if (answer5.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -356,38 +299,30 @@ export = {
} }
if (answer5.first()!.content.length > 256) { if (answer5.first()!.content.length > 256) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 256.",
description: "Max character limit is 256.", color: embedColor
color: embedColor, }]
},
],
}) })
} }
const answer5_1 = answer5.first()!.content const answer5_1 = answer5.first()!.content
// sixth question // sixth question
await user.send({ await user.send({
embeds: [ embeds: [{
{ title: "**Question 6**",
title: "**Question 6**", description: sq(6) + "\n\nPlease type your answer below or type `cancel` to cancel your application." +
description: "`(We expect a longer answer here)`\n`" + largeM + "`",
sq(6) + color: embedColor,
"\n\nPlease type your answer below or type `cancel` to cancel your application." + footer: {
"`(We expect a longer answer here)`\n`" + text: "You have 15 minutes to respond to this message."
largeM + }
"`", }]
color: embedColor,
footer: {
text: "You have 15 minutes to respond to this message.",
},
},
],
}) })
const answer6 = await user.dmChannel!.awaitMessages({ const answer6 = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 15, time: 1000 * 60 * 15
}) })
if (answer6.size === 0) { if (answer6.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -403,30 +338,25 @@ export = {
} }
if (answer6.first()!.content.length > 256) { if (answer6.first()!.content.length > 256) {
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Max character limit is 256.",
description: "Max character limit is 256.", color: embedColor
color: embedColor, }]
},
],
}) })
} }
const answer6_1 = answer6.first()!.content const answer6_1 = answer6.first()!.content
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "If you want to submit your application, type `yes` if not, type `no`",
description: color: embedColor
"If you want to submit your application, type `yes` if not, type `no`", }]
color: embedColor,
},
],
}) })
const final = await user.dmChannel!.awaitMessages({ const final = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id, filter: m => m.author.id === user.user.id,
max: 1, max: 1,
time: 1000 * 60 * 5, time: 1000 * 60 * 5
}) })
if (final.size === 0) { if (final.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -442,71 +372,61 @@ export = {
} }
await user.send({ await user.send({
embeds: [ embeds: [{
{ description: "Your application has been submitted!",
description: "Your application has been submitted!", color: embedColor
color: embedColor, }]
},
],
}) })
const newStaffApp = new staffapp({ const newStaffApp = new staffapp({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.user.id, userID: user.user.id,
uuid: uuid, uuid: uuid
}) })
await newStaffApp.save() await newStaffApp.save()
await user.deleteDM() await user.deleteDM()
const channel = guild.channels.cache.get( const channel = guild.channels.cache.get(staffApplicationsChannel) as TextChannel
staffApplicationsChannel,
) as TextChannel
await channel.send({ await channel.send({
embeds: [ embeds: [{
{ title: user.user.username + "#" + user.user.discriminator + " - Staff Application",
title: color: embedColor,
user.user.username + thumbnail: {
"#" + url: user.avatarURL() || ""
user.user.discriminator +
" - Staff Application",
color: embedColor,
thumbnail: {
url: user.avatarURL() || "",
},
fields: [
{
name: rq(1),
value: "```" + answer1_1 + "```",
},
{
name: rq(2),
value: "```" + answer2_1 + "```",
},
{
name: rq(3),
value: "```" + answer3_1 + "```",
},
{
name: rq(4),
value: "```" + answer4_1 + "```",
},
{
name: rq(5),
value: "```" + answer5_1 + "```",
},
{
name: rq(6),
value: "```" + answer6_1 + "```",
},
],
footer: {
icon_url: guild.iconURL() || undefined,
text: "ID: " + user.user.id,
},
}, },
], fields: [
{
name: rq(1),
value: "```" + answer1_1 + "```"
},
{
name: rq(2),
value: "```" + answer2_1 + "```"
},
{
name: rq(3),
value: "```" + answer3_1 + "```"
},
{
name: rq(4),
value: "```" + answer4_1 + "```"
},
{
name: rq(5),
value: "```" + answer5_1 + "```"
},
{
name: rq(6),
value: "```" + answer6_1 + "```"
}
],
footer: {
icon_url: guild.iconURL() || undefined,
text: "ID: " + user.user.id
}
}],
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -516,10 +436,10 @@ export = {
new ButtonBuilder() new ButtonBuilder()
.setCustomId("staffapplicationdeny") .setCustomId("staffapplicationdeny")
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger)
), )
], ]
}) })
} }
}, }
} as Button } as Button

View File

@@ -1,9 +1,4 @@
import { import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js"
ModalBuilder,
ActionRowBuilder,
TextInputBuilder,
TextInputStyle,
} from "discord.js"
import { Button } from "interfaces" import { Button } from "interfaces"
export = { export = {
@@ -23,9 +18,9 @@ export = {
.setPlaceholder("Enter your ign.") .setPlaceholder("Enter your ign.")
.setRequired(true) .setRequired(true)
.setMinLength(3) .setMinLength(3)
.setMaxLength(16), .setMaxLength(16)
), )
) )
await interaction.showModal(modal) await interaction.showModal(modal)
}, }
} as Button } as Button

View File

@@ -32,27 +32,25 @@ export = {
fields.push({ fields.push({
name: `${i + 1}. ${accepted[i].IGN}`, name: `${i + 1}. ${accepted[i].IGN}`,
value: `TS: <t:${timestamp}:R>`, value: `TS: <t:${timestamp}:R>`
}) })
} }
await message.edit({ await message.edit({
embeds: [ embeds: [{
{ title: embed.title!,
title: embed.title!, description: embed.description!,
description: embed.description!, color: embed.color!,
color: embed.color!, footer: {
footer: { text: "Last updated by " + user.username,
text: "Last updated by " + user.username, icon_url: user.avatarURL() || undefined
icon_url: user.avatarURL() || undefined,
},
thumbnail: embed.thumbnail!,
fields: fields,
timestamp: new Date().toISOString(),
}, },
], thumbnail: embed.thumbnail!,
fields: fields,
timestamp: new Date().toISOString()
}]
}) })
await interaction.editReply("Updated the waiting list") await interaction.editReply("Updated the waiting list")
}, }
} as Button } as Button

View File

@@ -1,11 +1,4 @@
import { import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Message, GuildMember } from "discord.js"
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Message,
GuildMember,
} from "discord.js"
import { color } from "config/options.json" import { color } from "config/options.json"
import guildapp from "schemas/guildAppSchema" import guildapp from "schemas/guildAppSchema"
import { Modal } from "interfaces" import { Modal } from "interfaces"
@@ -22,9 +15,7 @@ export = {
const embed = message.embeds[0] const embed = message.embeds[0]
const applicantId = embed.footer!.text.split(" ")[1] const applicantId = embed.footer!.text.split(" ")[1]
const reason = const reason = interaction.fields.fields.get("denyreason")!.value || "No reason provided"
interaction.fields.fields.get("denyreason")!.value ||
"No reason provided"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
await message.edit({ await message.edit({
@@ -44,9 +35,9 @@ export = {
.setCustomId("checkstats") .setCustomId("checkstats")
.setLabel("Check Stats") .setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary) .setStyle(ButtonStyle.Secondary)
.setDisabled(true), .setDisabled(true)
), )
], ]
}) })
let applicant: GuildMember | null let applicant: GuildMember | null
@@ -57,35 +48,25 @@ export = {
} }
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription( .setDescription("Your application for the Illegitimate guild has been denied\n" +
"Your application for the Illegitimate guild has been denied\n" + "**Reason:** `" + reason + "`"
"**Reason:** `" +
reason +
"`",
) )
.setColor(embedColor) .setColor(embedColor)
const missingUser = new EmbedBuilder() const missingUser = new EmbedBuilder()
.setDescription( .setDescription("[WARN] User has left the server and cannot be notified.")
"[WARN] User has left the server and cannot be notified.",
)
.setColor(embedColor) .setColor(embedColor)
const responseEmbed = new EmbedBuilder() const responseEmbed = new EmbedBuilder()
.setTitle("Application Denied") .setTitle("Application Denied")
.setDescription( .setDescription("The application has been denied by <@" + interaction.user.id + ">.\n" +
"The application has been denied by <@" + "**Reason:** `" + reason + "`"
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`",
) )
.setColor(embedColor) .setColor(embedColor)
.setThumbnail(guild.iconURL() || "") .setThumbnail(guild.iconURL() || "")
.setFooter({ .setFooter({
iconURL: guild.iconURL() || undefined, iconURL: guild.iconURL() || undefined,
text: "ID: " + applicantId, text: "ID: " + applicantId
}) })
if (applicant !== null) { if (applicant !== null) {
@@ -102,7 +83,7 @@ export = {
await guildapp.findOneAndDelete({ userID: applicantId }) await guildapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({ await interaction.editReply({
embeds: responseEmbeds, embeds: responseEmbeds
}) })
}, }
} as Modal } as Modal

View File

@@ -1,9 +1,4 @@
import { import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js"
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
} from "discord.js"
import { color } from "config/options.json" import { color } from "config/options.json"
import staffapp from "schemas/staffAppSchema" import staffapp from "schemas/staffAppSchema"
import { Modal } from "interfaces" import { Modal } from "interfaces"
@@ -16,9 +11,7 @@ export = {
await interaction.deferReply() await interaction.deferReply()
const guild = interaction.guild const guild = interaction.guild
const reason = const reason = interaction.fields.fields.get("staffdenyreason")!.value || "No reason provided"
interaction.fields.fields.get("staffdenyreason")!.value ||
"No reason provided"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const message = interaction.message! const message = interaction.message!
@@ -38,17 +31,14 @@ export = {
.setCustomId("staffapplicationdeny") .setCustomId("staffapplicationdeny")
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger) .setStyle(ButtonStyle.Danger)
.setDisabled(true), .setDisabled(true)
), )
], ]
}) })
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription( .setDescription("Your application for the Illegitimate guild staff has been denied\n" +
"Your application for the Illegitimate guild staff has been denied\n" + "**Reason:** `" + reason + "`"
"**Reason:** `" +
reason +
"`",
) )
.setColor(embedColor) .setColor(embedColor)
@@ -57,26 +47,19 @@ export = {
await staffapp.findOneAndDelete({ userID: applicantId }) await staffapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: "Application Denied",
title: "Application Denied", description: "The application has been denied by <@" + interaction.user.id + ">.\n" +
description: "**Reason:** `" + reason + "`",
"The application has been denied by <@" + color: embedColor,
interaction.user.id + thumbnail: {
">.\n" + url: applicant.avatarURL() || ""
"**Reason:** `" +
reason +
"`",
color: embedColor,
thumbnail: {
url: applicant.avatarURL() || "",
},
footer: {
icon_url: guild!.iconURL() || undefined,
text: "ID: " + applicant.id,
},
}, },
], footer: {
icon_url: guild!.iconURL() || undefined,
text: "ID: " + applicant.id
}
}]
}) })
}, }
} as Modal } as Modal

View File

@@ -2,17 +2,7 @@ import { getUUID, getPlayer, getGuild, getHeadURL } from "utils/Hypixel"
import { color, hypixelGuildID, devMessage } from "config/options.json" import { color, hypixelGuildID, devMessage } from "config/options.json"
import verify from "schemas/verifySchema" import verify from "schemas/verifySchema"
import mongoose from "mongoose" import mongoose from "mongoose"
import { import { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "config/roles.json"
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "config/roles.json"
import { Modal } from "interfaces" import { Modal } from "interfaces"
import { GuildMember } from "discord.js" import { GuildMember } from "discord.js"
@@ -29,23 +19,17 @@ export = {
const verifyData = await verify.findOne({ userID: user.user.id }) const verifyData = await verify.findOne({ userID: user.user.id })
if (verifyData) { if (verifyData) {
interaction.editReply( interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
"You are already verified.\n" +
"Try running /update to update your roles.",
)
return return
} }
const uuid = await getUUID(ign) const uuid = await getUUID(ign)
if (!uuid) { if (!uuid) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player does not exist.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player does not exist.", }]
color: embedColor,
},
],
}) })
return return
} }
@@ -54,13 +38,10 @@ export = {
const player = await getPlayer(uuid) const player = await getPlayer(uuid)
if (!player) { if (!player) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
description: color: embedColor
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.", }]
color: embedColor,
},
],
}) })
return return
} }
@@ -75,38 +56,22 @@ export = {
const linkedDiscord = player?.socialMedia?.links?.DISCORD const linkedDiscord = player?.socialMedia?.links?.DISCORD
if (!linkedDiscord) { if (!linkedDiscord) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + player.displayname + "`.\n\n" +
description: "**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
"<a:cross_a:1087808606897983539> There is no Discord account linked to `" + color: embedColor
player.displayname + }]
"`.\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
}) })
return return
} }
if (linkedDiscord !== username) { if (linkedDiscord !== username) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [{
{ description: "<a:cross_a:1087808606897983539> The Discord account linked to `" + player.displayname + "` is currently `" + linkedDiscord + "`\n\n" +
description: "**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
"<a:cross_a:1087808606897983539> The Discord account linked to `" + color: embedColor
player.displayname + }]
"` is currently `" +
linkedDiscord +
"`\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
}) })
return return
} }
@@ -121,9 +86,7 @@ export = {
if (guildID === hypixelGuildID) { if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find( const guildRank = GuildMembers.find(member => member.uuid === player.uuid)!.rank
member => member.uuid === player.uuid,
)!.rank
if (guildRank === "Guild Master" && guildID === hypixelGuildID) { if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
await user.roles.add(gm, "Verification") await user.roles.add(gm, "Verification")
@@ -163,32 +126,25 @@ export = {
const newVerify = new verify({ const newVerify = new verify({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.id, userID: user.id,
uuid: uuid, uuid: uuid
}) })
await newVerify.save() await newVerify.save()
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ title: interaction.guild!.name,
title: interaction.guild!.name, description: "You have successfully verified `" + username + "` with the account `" + player.displayname + "`.",
description: color: embedColor,
"You have successfully verified `" + thumbnail: {
username + url: head!
"` with the account `" +
player.displayname +
"`.",
color: embedColor,
thumbnail: {
url: head!,
},
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage,
},
}, },
], footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
}) })
} }
}, }
} as Modal } as Modal

View File

@@ -1,9 +1,4 @@
import { import { hypixelGuildID, guildLogChannel, color, devMessage } from "config/options.json"
hypixelGuildID,
guildLogChannel,
color,
devMessage,
} from "config/options.json"
import colorLog from "utils/functions/colors" import colorLog from "utils/functions/colors"
import { getGuild, getIGN } from "utils/Hypixel" import { getGuild, getIGN } from "utils/Hypixel"
import { Cron, GuildData } from "interfaces" import { Cron, GuildData } from "interfaces"
@@ -22,18 +17,15 @@ async function guildWeekly() {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const message = await channel.send({ const message = await channel.send({
embeds: [ embeds: [{
{ description: "Starting to fetch guild data...",
description: "Starting to fetch guild data...", color: embedColor
color: embedColor, }]
},
],
}) })
const guild = (await getGuild(hypixelGuildID, "id")) as GuildData const guild = (await getGuild(hypixelGuildID, "id")) as GuildData
const guildMembersList: string[] = [] const guildMembersList: string[] = []
const topWeeklyMembers: { name: string; value: string; inline: boolean }[] = const topWeeklyMembers: { name: string; value: string; inline: boolean }[] = []
[]
const guildName = guild.name const guildName = guild.name
const guildMembers = guild.members const guildMembers = guild.members
@@ -41,31 +33,22 @@ async function guildWeekly() {
const sliceSize = guildMembers.length / 4 const sliceSize = guildMembers.length / 4
// top weekly members // top weekly members
const allMembersGexpSorted = guildMembers const allMembersGexpSorted = guildMembers.map(member => {
.map(member => { return {
return { uuid: member.uuid,
uuid: member.uuid, exp: Object.values(member.expHistory).reduce((a, b) => a + b, 0)
exp: Object.values(member.expHistory).reduce( }
(a, b) => a + b, }).sort((a, b) => b.exp - a.exp)
0,
),
}
})
.sort((a, b) => b.exp - a.exp)
for (let i = 0; i < allMembersGexpSorted.length; i++) { for (let i = 0; i < allMembersGexpSorted.length; i++) {
const ign = await getIGN(allMembersGexpSorted[i].uuid) const ign = await getIGN(allMembersGexpSorted[i].uuid)
const gexp = new Intl.NumberFormat("en-US").format( const gexp = new Intl.NumberFormat("en-US").format(allMembersGexpSorted[i].exp)
allMembersGexpSorted[i].exp,
)
const position = i + 1 const position = i + 1
guildMembersList.push( guildMembersList.push("**#" + position + " " + ign + ":** `" + gexp + "`")
"**#" + position + " " + ign + ":** `" + gexp + "`",
)
} }
const list = Array.from({ length: sliceSize }, (_, i) => const list = Array.from({ length: sliceSize }, (_, i) =>
guildMembersList.slice(i * sliceSize, (i + 1) * sliceSize), guildMembersList.slice(i * sliceSize, (i + 1) * sliceSize)
) )
list.forEach((item, index) => { list.forEach((item, index) => {
@@ -74,51 +57,35 @@ async function guildWeekly() {
topWeeklyMembers[index] = { topWeeklyMembers[index] = {
name: "", name: "",
value: item.join("\n"), value: item.join("\n"),
inline: false, inline: false
} }
}) })
// combined weekly gexp // combined weekly gexp
const allGuildMembersWeeklyXP = guildMembers.map( const allGuildMembersWeeklyXP = guildMembers.map(member => member.expHistory)
member => member.expHistory,
)
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map(member => { const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map(member => {
return Object.values(member).reduce((a, b) => a + b, 0) return Object.values(member).reduce((a, b) => a + b, 0)
}) })
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce( const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce((a, b) => a + b, 0)
(a, b) => a + b, const averageGuildMembersDailyXPUnformatted = totalGuildMembersWeeklyXPUnformatted / 7
0,
)
const averageGuildMembersDailyXPUnformatted =
totalGuildMembersWeeklyXPUnformatted / 7
// final values // final values
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format( const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(totalGuildMembersWeeklyXPUnformatted)
totalGuildMembersWeeklyXPUnformatted, const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(averageGuildMembersDailyXPUnformatted)
)
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
averageGuildMembersDailyXPUnformatted,
)
await message.edit({ await message.edit({
embeds: [ embeds: [{
{ title: "**Weekly Guild XP for " + guildName + "**",
title: "**Weekly Guild XP for " + guildName + "**", description: "**Total weekly guild XP:** `" + totalGuildMembersWeeklyXP +
description: "`\n**Average daily guild XP:** `" + averageGuildMembersWeeklyXP + "`",
"**Total weekly guild XP:** `" + color: embedColor,
totalGuildMembersWeeklyXP + fields: topWeeklyMembers,
"`\n**Average daily guild XP:** `" + timestamp: new Date().toISOString(),
averageGuildMembersWeeklyXP + footer: {
"`", text: channel.guild.name + " | " + devMessage,
color: embedColor, icon_url: channel.guild.iconURL() || undefined
fields: topWeeklyMembers, }
timestamp: new Date().toISOString(), }]
footer: {
text: channel.guild.name + " | " + devMessage,
icon_url: channel.guild.iconURL() || undefined,
},
},
],
}) })
} }
@@ -129,10 +96,10 @@ export = {
hours: 21, hours: 21,
dayOfWeek: 7, dayOfWeek: 7,
dayOfMonth: "*", dayOfMonth: "*",
month: "*", month: "*"
}, },
execute: guildWeekly, execute: guildWeekly,
onComplete: null, onComplete: null,
start: true, start: true,
timeZone: "Europe/Zagreb", timeZone: "Europe/Zagreb"
} as Cron } as Cron

View File

@@ -13,25 +13,20 @@ export = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
logToChannel("bot", { logToChannel("bot", {
embeds: [ embeds: [{
{ title: "New Member",
title: "New Member", description: userMention(member.id) + " has joined the server.\n" +
description: "Account created: " + member.user.createdAt.toLocaleString(),
userMention(member.id) + color: embedColor,
" has joined the server.\n" + thumbnail: {
"Account created: " + url: member.user.avatarURL() || ""
member.user.createdAt.toLocaleString(),
color: embedColor,
thumbnail: {
url: member.user.avatarURL() || "",
},
footer: {
text: "ID: " + member.id,
icon_url: member.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], footer: {
text: "ID: " + member.id,
icon_url: member.user.avatarURL() || undefined
},
timestamp: new Date().toISOString()
}]
}) })
}, }
} as Event } as Event

View File

@@ -12,22 +12,19 @@ export = {
try { try {
console.log( console.log(
color( color(
interaction.user.username + interaction.user.username + " ran " +
" ran " + interaction.commandName + " " +
interaction.commandName + interaction.options.getSubcommand(),
" " + "pink"
interaction.options.getSubcommand(), )
"pink",
),
) )
} catch { } catch {
console.log( console.log(
color( color(
interaction.user.username + interaction.user.username + " ran " +
" ran " + interaction.commandName,
interaction.commandName, "pink"
"pink", )
),
) )
} }
} }
@@ -35,15 +32,13 @@ export = {
if (interaction.isButton()) { if (interaction.isButton()) {
console.log( console.log(
color( color(
interaction.user.username + interaction.user.username + "#" +
"#" + interaction.user.discriminator + " clicked " +
interaction.user.discriminator + interaction.customId,
" clicked " + "pink"
interaction.customId, )
"pink",
),
) )
return return
} }
}, }
} as Event } as Event

View File

@@ -19,20 +19,16 @@ export = {
const output = eval(code) const output = eval(code)
const outputString = String(output) const outputString = String(output)
await message.channel.send({ await message.channel.send({
embeds: [ embeds: [{
{ description: `\`\`\`js\n${outputString}\`\`\``
description: `\`\`\`js\n${outputString}\`\`\``, }]
},
],
}) })
} catch (error) { } catch (error) {
await message.channel.send({ await message.channel.send({
embeds: [ embeds: [{
{ description: `\`\`\`js\n${error}\`\`\``
description: `\`\`\`js\n${error}\`\`\``, }]
},
],
}) })
} }
}, }
} as Event } as Event

View File

@@ -7,11 +7,8 @@ export = {
event: "messageCreate", event: "messageCreate",
async execute(message: Message) { async execute(message: Message) {
if ( if (message.content.toLowerCase().includes("ur mom") && message.author.username === "taken.lua") {
message.content.toLowerCase().includes("ur mom") &&
message.author.username === "taken.lua"
) {
message.react("Woot:734345936347725885") message.react("Woot:734345936347725885")
} }
}, }
} as Event } as Event

View File

@@ -20,16 +20,16 @@ export = {
channel: message.channel.id, channel: message.channel.id,
createdAt: message.createdTimestamp, createdAt: message.createdTimestamp,
deletedAt: Date.now(), deletedAt: Date.now(),
attachments: message.attachments.map(a => a.url) || [], attachments: message.attachments.map(a => a.url) || []
} }
const snipeCache = new snipeCacheSchema({ const snipeCache = new snipeCacheSchema({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userid: message.author.id, userid: message.author.id,
channelid: message.channel.id, channelid: message.channel.id,
data: msg, data: msg
}) })
await snipeCache.save() await snipeCache.save()
}, }
} as Event } as Event

View File

@@ -9,5 +9,5 @@ export = {
execute(client: Client) { execute(client: Client) {
console.log(color("Logged in as " + client.user!.tag + "!", "green")) console.log(color("Logged in as " + client.user!.tag + "!", "green"))
}, }
} as Event } as Event

View File

@@ -13,12 +13,10 @@ export = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
logToChannel("online", { logToChannel("online", {
embeds: [ embeds: [{
{ description: "Bot is online!",
description: "Bot is online!", color: embedColor
color: embedColor, }]
},
],
}) })
}, }
} as Event } as Event

View File

@@ -22,9 +22,9 @@ export = {
let i = 1 let i = 1
setInterval( setInterval(
() => user.setActivity(statuses[i++ % statuses.length]), () => user.setActivity(statuses[i++ % statuses.length]),
1000 * 60 * 10, 1000 * 60 * 10
) )
user.setStatus("dnd") user.setStatus("dnd")
}, }
} as Event } as Event

View File

@@ -17,65 +17,46 @@ export = {
if (oldChannel === null && newChannel !== null) { if (oldChannel === null && newChannel !== null) {
logToChannel("bot", { logToChannel("bot", {
embeds: [ embeds: [{
{ title: "Voice Channel Join",
title: "Voice Channel Join", description: userMention(newState.member!.id) + " joined " + channelMention(newChannel.id),
description: color: embedColor,
userMention(newState.member!.id) + footer: {
" joined " + text: "ID: " + newState.member!.id,
channelMention(newChannel.id), icon_url: newState.member!.user.avatarURL() || undefined
color: embedColor,
footer: {
text: "ID: " + newState.member!.id,
icon_url:
newState.member!.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], timestamp: new Date().toISOString()
}]
}) })
} else if (oldChannel !== null && newChannel === null) { } else if (oldChannel !== null && newChannel === null) {
logToChannel("bot", { logToChannel("bot", {
embeds: [ embeds: [{
{ title: "Voice Channel Leave",
title: "Voice Channel Leave", description: userMention(oldState.member!.id) + " left " + channelMention(oldChannel.id),
description: color: embedColor,
userMention(oldState.member!.id) + footer: {
" left " + text: "ID: " + oldState.member!.id,
channelMention(oldChannel.id), icon_url: oldState.member!.user.avatarURL() || undefined
color: embedColor,
footer: {
text: "ID: " + oldState.member!.id,
icon_url:
oldState.member!.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], timestamp: new Date().toISOString()
}]
}) })
} else if (oldChannel !== null && newChannel !== null) { } else if (oldChannel !== null && newChannel !== null) {
if (oldChannel.id === newChannel.id) return if (oldChannel.id === newChannel.id) return
logToChannel("bot", { logToChannel("bot", {
embeds: [ embeds: [{
{ title: "Voice Channel Switch",
title: "Voice Channel Switch", description: userMention(oldState.member!.id) + " switched from " +
description: channelMention(oldChannel.id) + " to " + channelMention(newChannel.id),
userMention(oldState.member!.id) + color: embedColor,
" switched from " + footer: {
channelMention(oldChannel.id) + text: "ID: " + oldState.member!.id,
" to " + icon_url: oldState.member!.user.avatarURL() || undefined
channelMention(newChannel.id),
color: embedColor,
footer: {
text: "ID: " + oldState.member!.id,
icon_url:
oldState.member!.user.avatarURL() || undefined,
},
timestamp: new Date().toISOString(),
}, },
], timestamp: new Date().toISOString()
}]
}) })
} }
}, }
} as Event } as Event

View File

@@ -10,8 +10,5 @@ export default interface Command {
disabled?: boolean disabled?: boolean
subcommands?: boolean subcommands?: boolean
data: SlashCommandBuilder data: SlashCommandBuilder
execute: ( execute: (interaction: ChatInputCommandInteraction, client: Client) => Promise<void>
interaction: ChatInputCommandInteraction,
client: Client,
) => Promise<void>
} }

View File

@@ -1,7 +1,7 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import { import {
ContextMenuCommandInteraction, ContextMenuCommandInteraction,
ContextMenuCommandBuilder, ContextMenuCommandBuilder
} from "discord.js" } from "discord.js"
export default interface ContextMenu { export default interface ContextMenu {

View File

@@ -25,5 +25,5 @@ export {
Guild, Guild,
GuildData, GuildData,
Player, Player,
PlayerData, PlayerData
} }

View File

@@ -3,7 +3,7 @@ import { Schema, model } from "mongoose"
const guildAppSchema = new Schema({ const guildAppSchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
userID: { type: String, required: true }, userID: { type: String, required: true },
uuid: { type: String, required: true }, uuid: { type: String, required: true }
}) })
export = model("guildapp", guildAppSchema, "guildapp") export = model("guildapp", guildAppSchema, "guildapp")

View File

@@ -3,7 +3,7 @@ import { Schema, model } from "mongoose"
const settingsSchema = new Schema({ const settingsSchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
name: { type: String, required: true }, name: { type: String, required: true },
value: { type: String, required: true }, value: { type: String, required: true }
}) })
export = model("settings", settingsSchema, "settings") export = model("settings", settingsSchema, "settings")

View File

@@ -5,7 +5,7 @@ const snipeCacheSchema = new Schema({
userid: { type: String, required: true }, userid: { type: String, required: true },
channelid: { type: String, required: true }, channelid: { type: String, required: true },
data: { type: Object, required: true }, data: { type: Object, required: true },
date: { type: Date, default: Date.now(), expires: 600 }, date: { type: Date, default: Date.now(), expires: 600 }
}) })
export default model("snipeCache", snipeCacheSchema, "snipeCache") export default model("snipeCache", snipeCacheSchema, "snipeCache")

View File

@@ -3,7 +3,7 @@ import { Schema, model } from "mongoose"
const staffAppSchema = new Schema({ const staffAppSchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
userID: { type: String, required: true }, userID: { type: String, required: true },
uuid: { type: String, required: true }, uuid: { type: String, required: true }
}) })
export = model("staffapp", staffAppSchema, "staffapp") export = model("staffapp", staffAppSchema, "staffapp")

View File

@@ -3,7 +3,7 @@ import { Schema, model } from "mongoose"
const verifySchema = new Schema({ const verifySchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
userID: { type: String, required: true }, userID: { type: String, required: true },
uuid: { type: String, required: true }, uuid: { type: String, required: true }
}) })
export = model("verify", verifySchema, "verify") export = model("verify", verifySchema, "verify")

View File

@@ -5,7 +5,7 @@ const waitinglistSchema = new Schema({
userID: { type: String, required: true }, userID: { type: String, required: true },
uuid: { type: String, required: true }, uuid: { type: String, required: true },
IGN: { type: String, required: true }, IGN: { type: String, required: true },
timestamp: { type: Number, required: true }, timestamp: { type: Number, required: true }
}) })
export = model("waitinglist", waitinglistSchema, "waitinglist") export = model("waitinglist", waitinglistSchema, "waitinglist")

View File

@@ -1,12 +1,7 @@
import { Command } from "interfaces" import { Command } from "interfaces"
import color from "./functions/colors" import color from "./functions/colors"
import env from "./Env" import env from "./Env"
import { import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationGuildCommandsJSONBody, Routes } from "discord.js"
REST,
RESTGetAPIApplicationGuildCommandResult,
RESTPutAPIApplicationGuildCommandsJSONBody,
Routes,
} from "discord.js"
import fs from "fs" import fs from "fs"
type FileType = "js" | "ts" type FileType = "js" | "ts"
@@ -16,19 +11,11 @@ export default async function autoDeployCommands(fileType: FileType) {
let contentMenuCommands: string[] = [] let contentMenuCommands: string[] = []
if (fileType === "js") { if (fileType === "js") {
commandFiles = fs commandFiles = fs.readdirSync("./dist/commands/").filter(file => file.endsWith(fileType))
.readdirSync("./dist/commands/") contentMenuCommands = fs.readdirSync("./dist/commands-contextmenu/").filter(file => file.endsWith(fileType))
.filter(file => file.endsWith(fileType))
contentMenuCommands = fs
.readdirSync("./dist/commands-contextmenu/")
.filter(file => file.endsWith(fileType))
} else if (fileType === "ts") { } else if (fileType === "ts") {
commandFiles = fs commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsWith(fileType))
.readdirSync("./src/commands/") contentMenuCommands = fs.readdirSync("./src/commands-contextmenu/").filter(file => file.endsWith(fileType))
.filter(file => file.endsWith(fileType))
contentMenuCommands = fs
.readdirSync("./src/commands-contextmenu/")
.filter(file => file.endsWith(fileType))
} }
for (const file of commandFiles) { for (const file of commandFiles) {
@@ -47,47 +34,38 @@ export default async function autoDeployCommands(fileType: FileType) {
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!) const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
const currentCommands = (await rest.get( const currentCommands = (await rest.get(
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!), Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!)
)) as RESTGetAPIApplicationGuildCommandResult[] )) as RESTGetAPIApplicationGuildCommandResult[]
const currentCommandsInfo = currentCommands.map(command => { const currentCommandsInfo = currentCommands.map(command => {
return { return {
name: command.name, name: command.name,
description: command.description, description: command.description
} }
}) })
const newCommandsInfo = commands.map(command => { const newCommandsInfo = commands.map(command => {
return { return {
name: command.name, name: command.name,
description: command.description, description: command.description
} }
}) })
const sortedCurrentCommandsInfo = currentCommandsInfo.sort((a, b) => const sortedCurrentCommandsInfo = currentCommandsInfo.sort((a, b) =>
a.name.localeCompare(b.name), a.name.localeCompare(b.name)
) )
const sortedNewCommandsInfo = newCommandsInfo.sort((a, b) => const sortedNewCommandsInfo = newCommandsInfo.sort((a, b) =>
a.name.localeCompare(b.name), a.name.localeCompare(b.name)
) )
const newCmds = sortedNewCommandsInfo const newCmds = sortedNewCommandsInfo.map(cmd => {
.map(cmd => { return " " + cmd.name + " was registered."
return " " + cmd.name + " was registered." }).join("\n")
}) const currentCmds = sortedCurrentCommandsInfo.map(cmd => {
.join("\n") return " " + cmd.name + " was unregistered."
const currentCmds = sortedCurrentCommandsInfo }).join("\n")
.map(cmd => {
return " " + cmd.name + " was unregistered."
})
.join("\n")
if ( if (JSON.stringify(sortedNewCommandsInfo) === JSON.stringify(sortedCurrentCommandsInfo)) {
JSON.stringify(sortedNewCommandsInfo) === console.log(color("Commands are the same, skipping deploy.", "lavender"))
JSON.stringify(sortedCurrentCommandsInfo)
) {
console.log(
color("Commands are the same, skipping deploy.", "lavender"),
)
console.log(color(newCmds, "lavender")) console.log(color(newCmds, "lavender"))
return return
} }
@@ -95,20 +73,16 @@ export default async function autoDeployCommands(fileType: FileType) {
try { try {
console.log(color("Commands are different, starting deploy.", "red")) console.log(color("Commands are different, starting deploy.", "red"))
console.log(color(currentCmds, "red")) console.log(color(currentCmds, "red"))
console.log( console.log(`Started refreshing ${commands.length} application (/) commands.`)
`Started refreshing ${commands.length} application (/) commands.`,
)
const data = (await rest.put( const data = (await rest.put(
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!), Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
{ body: commands }, { body: commands }
)) as RESTPutAPIApplicationGuildCommandsJSONBody[] )) as RESTPutAPIApplicationGuildCommandsJSONBody[]
console.log(color("New commands deployed.", "lavender")) console.log(color("New commands deployed.", "lavender"))
console.log(color(newCmds, "lavender")) console.log(color(newCmds, "lavender"))
console.log( console.log(`Successfully reloaded ${data.length} application (/) commands.`)
`Successfully reloaded ${data.length} application (/) commands.`,
)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }

View File

@@ -3,7 +3,6 @@ import color from "./functions/colors"
import { Command, ContextMenu, Button, Modal, Autocomplete } from "interfaces" import { Command, ContextMenu, Button, Modal, Autocomplete } from "interfaces"
import env from "./Env" import env from "./Env"
import autoDeployCommands from "./Autodeploy" import autoDeployCommands from "./Autodeploy"
import { loadAllEvents } from "./Events"
export class ExtendedClient extends Client { export class ExtendedClient extends Client {
commands: Collection<string, Command> = new Collection() commands: Collection<string, Command> = new Collection()
@@ -20,34 +19,29 @@ export class ExtendedClient extends Client {
GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent, GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildVoiceStates
], ],
partials: [ partials: [
Partials.GuildMember, Partials.GuildMember,
Partials.User, Partials.User,
Partials.Message, Partials.Message,
Partials.Channel, Partials.Channel
], ]
}) })
} }
async start() { async start() {
let token: string let token: string
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) { if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
console.log( console.log(color("Running in development mode. [ts-node]", "lavender"))
color("Running in development mode. [ts-node]", "lavender"),
)
loadAllEvents(this, "ts")
token = env.dev.devtoken! token = env.dev.devtoken!
autoDeployCommands("ts") autoDeployCommands("ts")
} else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) { } else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) {
console.log(color("Running in development mode.", "lavender")) console.log(color("Running in development mode.", "lavender"))
loadAllEvents(this, "js")
token = env.dev.devtoken! token = env.dev.devtoken!
autoDeployCommands("js") autoDeployCommands("js")
} else { } else {
console.log(color("Running in production mode.", "green")) console.log(color("Running in production mode.", "green"))
loadAllEvents(this, "js")
token = env.prod.token! token = env.prod.token!
} }

View File

@@ -7,14 +7,14 @@ const env: Env = {
mongoURI: process.env.MONGOURI, mongoURI: process.env.MONGOURI,
dev: process.env.DEV, dev: process.env.DEV,
hypixelapikey: process.env.HYPIXELAPIKEY, hypixelapikey: process.env.HYPIXELAPIKEY,
redisURI: process.env.REDISURI, redisURI: process.env.REDISURI
}, },
dev: { dev: {
devtoken: process.env.DEVTOKEN, devtoken: process.env.DEVTOKEN,
clientid: process.env.CLIENTID, clientid: process.env.CLIENTID,
devid: process.env.DEVID, devid: process.env.DEVID,
guildid: process.env.GUILDID, guildid: process.env.GUILDID
}, }
} }
export default env export default env

View File

@@ -10,16 +10,8 @@ type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
export default function loadAutocompleteEvents(client: Client, ft: FileType) { export default function loadAutocompleteEvents(client: Client, ft: FileType) {
const autocompletePath = path.join( const autocompletePath = path.join(__dirname, "..", "..", "components", "autocomplete")
__dirname, const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(ft))
"..",
"..",
"components",
"autocomplete",
)
const autocompleteFiles = fs
.readdirSync(autocompletePath)
.filter(file => file.endsWith(ft))
for (const file of autocompleteFiles) { for (const file of autocompleteFiles) {
const filePath = path.join(autocompletePath, file) const filePath = path.join(autocompletePath, file)
@@ -31,8 +23,8 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
console.log( console.log(
colorLog( colorLog(
`[WARNING] The autocomplete at ${filePath} is missing a required "name", "execute" or "type" property.`, `[WARNING] The autocomplete at ${filePath} is missing a required "name", "execute" or "type" property.`,
"red", "red"
), )
) )
} }
} }
@@ -43,9 +35,7 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
const autocomplete = client.autocomplete.get(interaction.commandName) const autocomplete = client.autocomplete.get(interaction.commandName)
if (!autocomplete) { if (!autocomplete) {
console.error( console.error(`No autocomplete matching ${interaction.commandName} was found.`)
`No autocomplete matching ${interaction.commandName} was found.`,
)
return return
} }
@@ -54,21 +44,15 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", { await logToChannel("error", {
embeds: [ embeds: [{
{ title: "Autocomplete error occured",
title: "Autocomplete error occured", description: "```" + error + "```",
description: String(error), color: embedColor,
color: embedColor, footer: {
footer: { icon_url: interaction.guild!.iconURL() || undefined,
icon_url: text: interaction.user.username + " | " + interaction.commandName
interaction.guild!.iconURL() || undefined, }
text: }]
interaction.user.username +
" | " +
interaction.commandName,
},
},
],
}) })
} }
console.error(error) console.error(error)

View File

@@ -23,8 +23,8 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
console.log( console.log(
colorLog( colorLog(
`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`, `[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`,
"red", "red"
), )
) )
} }
} }
@@ -35,9 +35,7 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
const button = client.buttons.get(interaction.customId) const button = client.buttons.get(interaction.customId)
if (!button) { if (!button) {
console.error( console.error(`No event matching ${interaction.customId} was found.`)
`No event matching ${interaction.customId} was found.`,
)
return return
} }
@@ -46,45 +44,33 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", { await logToChannel("error", {
embeds: [ embeds: [{
{ title: "Button error occured",
title: "Button error occured", description: "```" + error + "```",
description: "```" + error + "```", color: embedColor,
color: embedColor, footer: {
footer: { icon_url: interaction.guild!.iconURL() || undefined,
icon_url: text: interaction.user.username + " | " + interaction.customId
interaction.guild!.iconURL() || undefined, }
text: }]
interaction.user.username +
" | " +
interaction.customId,
},
},
],
}) })
} }
console.error(error) console.error(error)
if (!interaction.deferred) { if (!interaction.deferred) {
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "There was an error while executing this button!",
description: color: embedColor
"There was an error while executing this button!", }],
color: embedColor, ephemeral: true
},
],
ephemeral: true,
}) })
} else { } else {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "There was an error while executing this button! 2",
description: color: embedColor
"There was an error while executing this button! 2", }]
color: embedColor,
},
],
}) })
} }
} }

View File

@@ -23,8 +23,8 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
console.log( console.log(
colorLog( colorLog(
`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`, `[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`,
"red", "red"
), )
) )
} }
} }
@@ -37,7 +37,7 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
if (!command) { if (!command) {
console.error( console.error(
`No command matching ${interaction.commandName} was found.`, `No command matching ${interaction.commandName} was found.`
) )
return return
} }
@@ -47,45 +47,33 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", { await logToChannel("error", {
embeds: [ embeds: [{
{ title: "Command error occured",
title: "Command error occured", description: "```" + error + "```",
description: "```" + error + "```", color: embedColor,
color: embedColor, footer: {
footer: { icon_url: interaction.guild!.iconURL() || undefined,
icon_url: text: interaction.user.username + " | " + interaction.commandName
interaction.guild!.iconURL() || undefined, }
text: }]
interaction.user.username +
" | " +
interaction.commandName,
},
},
],
}) })
} }
console.error(error) console.error(error)
if (!interaction.deferred) { if (!interaction.deferred) {
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "There was an error while executing this command!",
description: color: embedColor
"There was an error while executing this command!", }],
color: embedColor, ephemeral: true
},
],
ephemeral: true,
}) })
} else { } else {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "There was an error while executing this command!",
description: color: embedColor
"There was an error while executing this command!", }]
color: embedColor,
},
],
}) })
} }
} }

View File

@@ -10,15 +10,8 @@ type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
export default function loadContextMenuEvents(client: Client, ft: FileType) { export default function loadContextMenuEvents(client: Client, ft: FileType) {
const contextMenuPath = path.join( const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu")
__dirname, const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(ft))
"..",
"..",
"commands-contextmenu",
)
const contextMenuFiles = fs
.readdirSync(contextMenuPath)
.filter(file => file.endsWith(ft))
for (const file of contextMenuFiles) { for (const file of contextMenuFiles) {
const filePath = path.join(contextMenuPath, file) const filePath = path.join(contextMenuPath, file)
@@ -30,8 +23,8 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
console.log( console.log(
colorLog( colorLog(
`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`, `[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`,
"red", "red"
), )
) )
} }
} }
@@ -43,9 +36,7 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
const command = client.contextmenus.get(interaction.commandName) const command = client.contextmenus.get(interaction.commandName)
if (!command) { if (!command) {
console.error( console.error(`No command matching ${interaction.commandName} was found.`)
`No command matching ${interaction.commandName} was found.`,
)
return return
} }
@@ -54,45 +45,33 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", { await logToChannel("error", {
embeds: [ embeds: [{
{ title: "Contextmenu error occured",
title: "Contextmenu error occured", description: "```" + error + "```",
description: "```" + error + "```", color: embedColor,
color: embedColor, footer: {
footer: { icon_url: interaction.guild!.iconURL() || undefined,
icon_url: text: interaction.user.username + " | " + interaction.commandName
interaction.guild!.iconURL() || undefined, }
text: }]
interaction.user.username +
" | " +
interaction.commandName,
},
},
],
}) })
} }
console.error(error) console.error(error)
if (!interaction.deferred) { if (!interaction.deferred) {
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "There was an error while executing this contextmenu command!",
description: color: embedColor
"There was an error while executing this contextmenu command!", }],
color: embedColor, ephemeral: true
},
],
ephemeral: true,
}) })
} else { } else {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "There was an error while executing this contextmenu command!",
description: color: embedColor
"There was an error while executing this contextmenu command!", }]
color: embedColor,
},
],
}) })
} }
} }

View File

@@ -5,33 +5,20 @@ import { Cron } from "interfaces"
export default function loadCronEvents() { export default function loadCronEvents() {
const cronPath = path.join(__dirname, "..", "..", "events", "cron") const cronPath = path.join(__dirname, "..", "..", "events", "cron")
const cronFiles = fs const cronFiles = fs.readdirSync(cronPath).filter(file => file.endsWith(".js"))
.readdirSync(cronPath)
.filter(file => file.endsWith(".js"))
for (const file of cronFiles) { for (const file of cronFiles) {
const filePath = path.join(cronPath, file) const filePath = path.join(cronPath, file)
const cron: Cron = require(filePath) const cron: Cron = require(filePath)
const time = const time =
cron.time.seconds + cron.time.seconds + " " +
" " + cron.time.minutes + " " +
cron.time.minutes + cron.time.hours + " " +
" " + cron.time.dayOfMonth + " " +
cron.time.hours + cron.time.month + " " +
" " +
cron.time.dayOfMonth +
" " +
cron.time.month +
" " +
cron.time.dayOfWeek cron.time.dayOfWeek
new CronJob( new CronJob(time, cron.execute, cron.onComplete, cron.start, cron.timeZone).start()
time,
cron.execute,
cron.onComplete,
cron.start,
cron.timeZone,
).start()
} }
} }

View File

@@ -6,9 +6,8 @@ import loadContextMenuEvents from "./contextmenu"
import loadCronEvents from "./cron" import loadCronEvents from "./cron"
import loadEvents from "./events" import loadEvents from "./events"
import loadModalEvents from "./modal" import loadModalEvents from "./modal"
type FileType = "js" | "ts"
export function loadAllEvents(client: Client, ft: FileType) { export default function loadAllEvents(client: Client, ft: "js" | "ts") {
loadEvents(client) loadEvents(client)
loadButtonEvents(client, ft) loadButtonEvents(client, ft)
loadSlashCommandsEvents(client, ft) loadSlashCommandsEvents(client, ft)

View File

@@ -11,9 +11,7 @@ const embedColor = Number(color.replace("#", "0x"))
export default function loadModalEvents(client: Client, ft: FileType) { export default function loadModalEvents(client: Client, ft: FileType) {
const modalPath = path.join(__dirname, "..", "..", "components", "modals") const modalPath = path.join(__dirname, "..", "..", "components", "modals")
const modalFiles = fs const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(ft))
.readdirSync(modalPath)
.filter(file => file.endsWith(ft))
for (const file of modalFiles) { for (const file of modalFiles) {
const filePath = path.join(modalPath, file) const filePath = path.join(modalPath, file)
@@ -25,8 +23,8 @@ export default function loadModalEvents(client: Client, ft: FileType) {
console.log( console.log(
colorLog( colorLog(
`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`, `[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`,
"red", "red"
), )
) )
} }
} }
@@ -37,9 +35,7 @@ export default function loadModalEvents(client: Client, ft: FileType) {
const modal = client.modals.get(interaction.customId) const modal = client.modals.get(interaction.customId)
if (!modal) { if (!modal) {
console.error( console.error(`No modal matching ${interaction.customId} was found.`)
`No modal matching ${interaction.customId} was found.`,
)
return return
} }
@@ -48,44 +44,32 @@ export default function loadModalEvents(client: Client, ft: FileType) {
} catch (error) { } catch (error) {
if (process.env.NODE_ENV !== "dev") { if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", { await logToChannel("error", {
embeds: [ embeds: [{
{ title: "Button error occured",
title: "Button error occured", description: "```" + error + "```",
description: "```" + error + "```", color: embedColor,
color: embedColor, footer: {
footer: { icon_url: interaction.guild!.iconURL() || undefined,
icon_url: text: interaction.user.username + " | " + interaction.customId
interaction.guild!.iconURL() || undefined, }
text: }]
interaction.user.username +
" | " +
interaction.customId,
},
},
],
}) })
} }
console.error(error) console.error(error)
if (!interaction.deferred) { if (!interaction.deferred) {
await interaction.reply({ await interaction.reply({
embeds: [ embeds: [{
{ description: "There was an error while executing this modal!",
description: color: embedColor
"There was an error while executing this modal!", }]
color: embedColor,
},
],
}) })
} else { } else {
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [{
{ description: "There was an error while executing this modal!",
description: color: embedColor
"There was an error while executing this modal!", }]
color: embedColor,
},
],
}) })
} }
} }

View File

@@ -8,7 +8,7 @@ const mojanguuid = "https://sessionserver.mojang.com/session/minecraft/profile/"
const hypixel = "https://api.hypixel.net/player" const hypixel = "https://api.hypixel.net/player"
const guild = "https://api.hypixel.net/guild" const guild = "https://api.hypixel.net/guild"
const minotar = "https://minotar.net/helm/" const minotar = "https://minotar.net/helm/"
type GuildQuerqType = "player" | "name" | "id" type GuildQueryType = "player" | "name" | "id"
type Profile = { type Profile = {
data: { data: {
@@ -47,9 +47,11 @@ async function getIGN(uuid: string): Promise<string | null> {
async function getPlayer(uuid: string): Promise<PlayerData | null> { async function getPlayer(uuid: string): Promise<PlayerData | null> {
const playerReq: Player = await fetch(hypixel, { const playerReq: Player = await fetch(hypixel, {
params: { params: {
key: apikey, uuid: uuid
uuid: uuid,
}, },
headers: {
"API-Key": apikey
}
}) })
if (!playerReq.data.player) { if (!playerReq.data.player) {
@@ -59,17 +61,16 @@ async function getPlayer(uuid: string): Promise<PlayerData | null> {
return playerReq.data.player return playerReq.data.player
} }
async function getGuild( async function getGuild(query: string, type?: GuildQueryType): Promise<GuildData | null> {
query: string,
type?: GuildQuerqType,
): Promise<GuildData | null> {
const reqType = type ? type : "player" const reqType = type ? type : "player"
const guildReq: Guild = await fetch(guild, { const guildReq: Guild = await fetch(guild, {
params: { params: {
key: apikey, [reqType]: query
[reqType]: query,
}, },
headers: {
"API-Key": apikey
}
}) })
if (!guildReq.data.guild) { if (!guildReq.data.guild) {

View File

@@ -10,14 +10,14 @@ function getExpForLevel(level: number): number {
} }
switch (respectedLevel) { switch (respectedLevel) {
case 1: case 1:
return 500 return 500
case 2: case 2:
return 1000 return 1000
case 3: case 3:
return 2000 return 2000
case 4: case 4:
return 3500 return 3500
} }
return 5000 return 5000
} }
@@ -31,7 +31,7 @@ function getLevelRespectingPrestige(level: number): number {
} }
const EASY_LEVELS = 4 const EASY_LEVELS = 4
const EASY_LEVELS_XP = 7000 const EASY_LEVELS_XP = 7004
const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP
const LEVELS_PER_PRESTIGE = 100 const LEVELS_PER_PRESTIGE = 100
const HIGHEST_PRESTIGE = 50 const HIGHEST_PRESTIGE = 50

View File

@@ -4,7 +4,7 @@
function guildLevel(exp: number): number { function guildLevel(exp: number): number {
const EXP_NEEDED = [ const EXP_NEEDED = [
100000, 150000, 250000, 500000, 750000, 1000000, 1250000, 1500000, 100000, 150000, 250000, 500000, 750000, 1000000, 1250000, 1500000,
2000000, 2500000, 2500000, 2500000, 2500000, 2500000, 3000000, 2000000, 2500000, 2500000, 2500000, 2500000, 2500000, 3000000
] ]
let level = 0 let level = 0
@@ -38,10 +38,8 @@ function guildLevel(exp: number): number {
*/ */
function scaledGEXP(input: number): number { function scaledGEXP(input: number): number {
if (input <= 200000) return Number(input) if (input <= 200000) return Number(input)
if (input <= 700000) if (input <= 700000) return Number(Math.round((input - 200000) / 10 + 200000))
return Number(Math.round((input - 200000) / 10 + 200000)) if (input > 700000) return Number(Math.round((input - 700000) / 33 + 250000))
if (input > 700000)
return Number(Math.round((input - 700000) / 33 + 250000))
return 0 return 0
} }

View File

@@ -6,16 +6,14 @@ const GROWTH = 2500
const HALF_GROWTH = 0.5 * GROWTH const HALF_GROWTH = 0.5 * GROWTH
const REVERSE_PQ_PREFIX = -(BASE - 0.5 * GROWTH) / GROWTH const REVERSE_PQ_PREFIX = -(BASE - 0.5 * GROWTH) / GROWTH
const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX
const GROWTH_DIVIDES_2 = 2 / GROWTH const GROWTHDIV2 = 2 / GROWTH
function getLevel(exp: number): number { function getLevel(exp: number): number {
return exp <= 1 if (exp <= 1) return 1
? 1
: Math.floor( return Math.floor(
1 + 1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTHDIV2 * exp)
REVERSE_PQ_PREFIX + )
Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp),
)
} }
function hypixelLevel(exp: number): number { function hypixelLevel(exp: number): number {

View File

@@ -3,13 +3,25 @@ import color from "utils/functions/colors"
import { Redis } from "ioredis" import { Redis } from "ioredis"
import env from "utils/Env" import env from "utils/Env"
import { connect } from "mongoose" import { connect } from "mongoose"
import loadAllEvents from "./Events"
const client = new Client() const client = new Client()
const redis = new Redis(env.prod.redisURI!) const redis = new Redis(env.prod.redisURI!)
let ft: "js" | "ts"
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") {
ft = "ts"
} else {
ft = "js"
}
class Bot { class Bot {
async start() { async start() {
this.init() this.init()
loadAllEvents(client, ft)
client.start() client.start()
this.databases()
}
private async databases() {
redis.on("ready", () => { redis.on("ready", () => {
console.log(color("Connected to Redis", "green")) console.log(color("Connected to Redis", "green"))
}) })

View File

@@ -4,7 +4,7 @@ const colors = {
red: "#f38ba8", red: "#f38ba8",
lavender: "#b4befe", lavender: "#b4befe",
green: "#a6e3a1", green: "#a6e3a1",
pink: "#f5c2e7", pink: "#f5c2e7"
} }
export default function color(text: string, type: keyof typeof colors) { export default function color(text: string, type: keyof typeof colors) {

View File

@@ -5,7 +5,7 @@ import {
guildLogChannel, guildLogChannel,
errorLogChannel, errorLogChannel,
moderationLogChannel, moderationLogChannel,
devLogChannel, devLogChannel
} from "config/options.json" } from "config/options.json"
import { Guild, MessageCreateOptions, TextChannel } from "discord.js" import { Guild, MessageCreateOptions, TextChannel } from "discord.js"
import Illegitimate from "utils/Illegitimate" import Illegitimate from "utils/Illegitimate"
@@ -16,15 +16,12 @@ const channels = {
guild: guildLogChannel, guild: guildLogChannel,
error: errorLogChannel, error: errorLogChannel,
mod: moderationLogChannel, mod: moderationLogChannel,
dev: devLogChannel, dev: devLogChannel
} }
type Channel = keyof typeof channels type Channel = keyof typeof channels
export default async function logToChannel( export default async function logToChannel(channel: Channel, message: MessageCreateOptions): Promise<void | null> {
channel: Channel,
message: MessageCreateOptions,
): Promise<void | null> {
const guild = Illegitimate.client.guilds.cache.get(guildid) as Guild const guild = Illegitimate.client.guilds.cache.get(guildid) as Guild
let logChannel: TextChannel let logChannel: TextChannel
@@ -35,9 +32,7 @@ export default async function logToChannel(
} }
if (!logChannel) { if (!logChannel) {
console.log( console.log(`[ERROR] Could not find channel used for ${channel} logging.`)
`[ERROR] Could not find channel used for ${channel} logging.`,
)
return return
} }

Some files were not shown because too many files have changed in this diff Show More