Replaced clang format with prettuier (sadly)

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

View File

@@ -1,225 +0,0 @@
---
Language: JavaScript
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: Never
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...

17
.prettierrc.js Normal file
View File

@@ -0,0 +1,17 @@
/** @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

@@ -10,6 +10,7 @@
"dev": "nodemon dist/src/index.js", "dev": "nodemon dist/src/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_d src", "lint": "eslint_d src",
"lint:fix": "eslint_d --fix src", "lint:fix": "eslint_d --fix src",
"prod:build": "ts-node scripts/deploy-commands.ts" "prod:build": "ts-node scripts/deploy-commands.ts"
@@ -28,6 +29,7 @@
"devDependencies": { "devDependencies": {
"@types/ms": "^0.7.34", "@types/ms": "^0.7.34",
"@types/node": "^20.10.5", "@types/node": "^20.10.5",
"prettier": "^3.1.1",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }

View File

@@ -1,4 +1,9 @@
import { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention } from "discord.js" import {
ContextMenuCommandBuilder,
ApplicationCommandType,
PermissionFlagsBits,
userMention,
} from "discord.js"
import { ContextMenu } from "../interfaces" import { ContextMenu } from "../interfaces"
export = { export = {
@@ -13,24 +18,31 @@ export = {
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
async execute(interaction) { async execute(interaction) {
const { targetId } = interaction const { targetId } = interaction
const message = await interaction.channel!.messages.fetch(targetId) const message = await interaction.channel!.messages.fetch(targetId)
if (!message) { if (!message) {
return interaction.reply({ content: "That user does not exist.", ephemeral: true }) return interaction.reply({
content: "That user does not exist.",
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({ content: "Sent a congrats message", ephemeral: true }) await interaction.reply({
} content: "Sent a congrats message",
ephemeral: true,
})
},
} as ContextMenu } as ContextMenu

View File

@@ -1,4 +1,8 @@
import { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } from "discord.js" import {
ContextMenuCommandBuilder,
ApplicationCommandType,
PermissionFlagsBits,
} from "discord.js"
import { ContextMenu } from "../interfaces" import { ContextMenu } from "../interfaces"
export = { export = {
@@ -13,26 +17,43 @@ export = {
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames), .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames),
async execute(interaction) { async execute(interaction) {
const { targetId } = interaction const { targetId } = interaction
const target = await interaction.guild!.members.fetch(targetId) const target = await interaction.guild!.members.fetch(targetId)
if (!target) { if (!target) {
interaction.reply({ content: "That user does not exist.", ephemeral: true }) interaction.reply({
content: "That user does not exist.",
ephemeral: true,
})
return return
} }
if (target.id === interaction.user.id) { if (target.id === interaction.user.id) {
interaction.reply({ content: "You can't reset your own nickname.", ephemeral: true }) interaction.reply({
content: "You can't reset your own nickname.",
ephemeral: true,
})
return return
} }
if (!target.manageable) { if (!target.manageable) {
interaction.reply({ content: "I cannot reset that user's nickname.", ephemeral: true }) interaction.reply({
content: "I cannot reset that user's nickname.",
ephemeral: true,
})
return return
} }
await target.setNickname(target.user.username, "Reset by " + interaction.user.username + "#" + interaction.user.discriminator) await target.setNickname(
interaction.reply({ content: `Reset ${target.user.username}'s nickname.`, ephemeral: true }) target.user.username,
} "Reset by " +
interaction.user.username +
"#" +
interaction.user.discriminator,
)
interaction.reply({
content: `Reset ${target.user.username}'s nickname.`,
ephemeral: true,
})
},
} as ContextMenu } as ContextMenu

View File

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

View File

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

View File

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

@@ -18,21 +18,22 @@ export = {
option option
.setName("setting") .setName("setting")
.setDescription("The setting to configure") .setDescription("The setting to configure")
.setChoices( .setChoices({
{ name: "Staff Application status", value: "staffAppStatus" } name: "Staff Application status",
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),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply() await interaction.deferReply()
const setting = interaction.options.getString("setting") const setting = interaction.options.getString("setting")
@@ -41,33 +42,42 @@ export = {
const settingsData = await settings.findOne({ name: setting }) const settingsData = await settings.findOne({ name: setting })
if (!settingsData) { if (!settingsData) {
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 + "`.", {
color: embedColor description:
}] "Successfully created `" +
setting +
"` with value `" +
value +
"`.",
color: embedColor,
},
],
}) })
} else { } else {
await settings.findOneAndUpdate({ name: setting }, { value: value })
await settings.findOneAndUpdate(
{ name: setting },
{ value: value }
)
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Successfully updated `" + setting + "` to value `" + value + "`.", {
}] description:
"Successfully updated `" +
setting +
"` to value `" +
value +
"`.",
},
],
}) })
} }
} },
} as Command } as Command

View File

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

View File

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

View File

@@ -1,9 +1,32 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js" import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { color, devMessage } from "../../config/options.json" import { color, devMessage } from "../../config/options.json"
import verify = require("../schemas/verifySchema") import verify = require("../schemas/verifySchema")
import { gm, manager, moderator, beast, member, guildRole, guildStaff, defaultMember } from "../../config/roles.json" import {
gm,
manager,
moderator,
beast,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../config/roles.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
const removeThese = [gm, manager, moderator, beast, member, guildRole, guildStaff, defaultMember] const removeThese = [
gm,
manager,
moderator,
beast,
member,
guildRole,
guildStaff,
defaultMember,
]
export = { export = {
name: "forceunverify", name: "forceunverify",
@@ -19,7 +42,8 @@ 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),
@@ -30,10 +54,12 @@ 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,
}] },
],
}) })
} }
@@ -42,14 +68,20 @@ export = {
await member.roles.remove(removeThese) await member.roles.remove(removeThese)
await interaction.reply({ await interaction.reply({
embeds: [{ embeds: [
description: "Successfully unverified " + userMention(member.user.id), {
description:
"Successfully unverified " +
userMention(member.user.id),
color: embedColor, color: embedColor,
footer: { footer: {
text: interaction.guild!.name + " | " + devMessage, text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })! icon_url: interaction.guild!.iconURL({
} forceStatic: false,
}] })!,
},
},
],
}) })
} },
} as Command } as Command

View File

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

View File

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

View File

@@ -24,8 +24,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
@@ -34,19 +34,21 @@ export = {
.addStringOption(option => .addStringOption(option =>
option option
.setName("query") .setName("query")
.setDescription("The query to search for. [Default: player]") .setDescription(
.setRequired(true) "The query to search for. [Default: player]",
). )
addStringOption(option => .setRequired(true),
)
.addStringOption(option =>
option option
.setName("type") .setName("type")
.setDescription("The type of query.") .setDescription("The type of query.")
.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
@@ -55,8 +57,11 @@ export = {
.addStringOption(option => .addStringOption(option =>
option option
.setName("query") .setName("query")
.setDescription("The query to search for. [Default: player]") .setDescription(
.setRequired(true)) "The query to search for. [Default: player]",
)
.setRequired(true),
)
.addStringOption(option => .addStringOption(option =>
option option
.setName("type") .setName("type")
@@ -64,17 +69,19 @@ 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("The amount of guild members to show. [Default: 10]")) .setDescription(
"The amount of guild members to show. [Default: 10]",
),
),
), ),
async execute(interaction) { async execute(interaction) {
const subcommand = interaction.options.getSubcommand() const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -93,18 +100,24 @@ export = {
return return
} }
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: true }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: true })
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: footerText + " | " + devMessage, text: footerText + " | " + devMessage,
icon_url: footerIcon! icon_url: footerIcon!,
} },
}] },
],
}) })
} },
} as Command } as Command

View File

@@ -1,9 +1,17 @@
import { getUUID, getIGN, getPlayer, getGuild, guildLevel } from "../../utils/Hypixel" import {
getUUID,
getIGN,
getPlayer,
getGuild,
guildLevel,
} from "../../utils/Hypixel"
import { color, devMessage } from "../../../config/options.json" import { color, devMessage } from "../../../config/options.json"
import { ChatInputCommandInteraction } from "discord.js" import { ChatInputCommandInteraction } from "discord.js"
import { GuildData } from "../../interfaces/Guild" import { GuildData } from "../../interfaces/Guild"
async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void> { async function guildInfo(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply() await interaction.deferReply()
const query = interaction.options.getString("query")! const query = interaction.options.getString("query")!
@@ -13,91 +21,111 @@ async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void
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
} }
@@ -119,61 +147,104 @@ async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void
const guildCreatedMinute = guildCreated.getMinutes() const guildCreatedMinute = guildCreated.getMinutes()
const guildCreatedSecond = guildCreated.getSeconds() const guildCreatedSecond = guildCreated.getSeconds()
const guildCreatedTime = guildCreatedDate + "." + const guildCreatedTime =
guildCreatedMonth + "." + guildCreatedDate +
guildCreatedYear + " " + "." +
guildCreatedHour + ":" + guildCreatedMonth +
guildCreatedMinute + ":" + "." +
guildCreatedYear +
" " +
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((a, b) => b.priority - a.priority) const guildRanksUnsorted = guild!.ranks.sort(
const guildRanks = guildRanksUnsorted.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n") (a, b) => b.priority - a.priority,
)
const guildRanks = guildRanksUnsorted
.map(r => "**➺ " + r.name + "** `[" + r.tag + "]`")
.join("\n")
const allGuildMembersWeeklyXP = guildMembers.map(member => member.expHistory) const allGuildMembersWeeklyXP = guildMembers.map(
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map((member) => { member => member.expHistory,
)
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((a, b) => a + b, 0) const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce(
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(totalGuildMembersWeeklyXPUnformatted) (a, b) => a + b,
0,
)
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
totalGuildMembersWeeklyXPUnformatted,
)
const averageGuildMembersWeeklyXPUnformatted = Math.round(totalGuildMembersWeeklyXPUnformatted / 7) const averageGuildMembersWeeklyXPUnformatted = Math.round(
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(averageGuildMembersWeeklyXPUnformatted) totalGuildMembersWeeklyXPUnformatted / 7,
)
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
averageGuildMembersWeeklyXPUnformatted,
)
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
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" +
"**Guild Tag: **`" +
guildTag +
"`\n" +
"**Guild Level: **`" +
guildLvl +
"`\n" +
"**Guild Owner: **`" +
guildOwnerName +
"`",
fields: [ fields: [
{ {
name: "**Guild Ranks**", name: "**Guild Ranks**",
value: guildRanks value: guildRanks,
}, },
{ {
name: "**GEXP**", name: "**GEXP**",
value: "**➺ Total weekly GEXP:** `" + totalGuildMembersWeeklyXP + "`\n" + value:
"**➺ Daily avarage:** `" + averageGuildMembersWeeklyXP + "`\n" + "**➺ Total weekly GEXP:** `" +
"**➺ Total GEXP:** `" + guildExp + "`" totalGuildMembersWeeklyXP +
"`\n" +
"**➺ Daily avarage:** `" +
averageGuildMembersWeeklyXP +
"`\n" +
"**➺ Total GEXP:** `" +
guildExp +
"`",
}, },
{ {
name: "**Guild Created**", name: "**Guild Created**",
value: "**➺ **`" + guildCreatedTime + "`" value: "**➺ **`" + guildCreatedTime + "`",
} },
], ],
color: embedColor, color: embedColor,
footer: { footer: {
text: footerText + " | " + devMessage, text: footerText + " | " + devMessage,
icon_url: footerIcon! icon_url: footerIcon!,
} },
}] },
],
}) })
} }

View File

@@ -2,17 +2,21 @@ 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"
async function guildMember(interaction: ChatInputCommandInteraction): Promise<void> { async function guildMember(
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)
@@ -29,10 +33,12 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
} }
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)
@@ -48,7 +54,9 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
}, },
footer: { footer: {
text: interaction.guild!.name + " | " + devMessage, text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })! icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
}, },
}, },
], ],
@@ -74,16 +82,19 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
} }
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: {
@@ -91,9 +102,12 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
}, },
footer: { footer: {
text: interaction.guild!.name + " | " + devMessage, text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!, icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
}, },
}], },
],
}) })
return return
} }
@@ -102,17 +116,34 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
const guildTag = " [" + guild.tag + "]" ?? "" const guildTag = " [" + guild.tag + "]" ?? ""
const guildMembers = guild.members const guildMembers = guild.members
const guildMember = guildMembers.find((member) => member.uuid === uuid) const guildMember = guildMembers.find(member => member.uuid === uuid)
const guildRank = guildMember!.rank const 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 "**➺ " + key + ":** " + "`" + new Intl.NumberFormat("en-US").format(memberGexp[key]) + "`" + "\n" return (
"**➺ " +
key +
":** " +
"`" +
new Intl.NumberFormat("en-US").format(memberGexp[key]) +
"`" +
"\n"
)
}) })
const expValue = allDaysGexp.join("") const expValue = allDaysGexp.join("")
const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce((a, b) => a + b, 0) const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce(
const totalWeeklyGexp = new Intl.NumberFormat("en-US").format(totalWeeklyGexpUnformatted) (a, b) => a + b,
const averageWeeklyGexpUnformatted = Math.round(totalWeeklyGexpUnformatted / 7) 0,
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)
@@ -124,21 +155,36 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds() const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds()
const guildMemberJoin = const guildMemberJoin =
guildMemberJoinDate + "." + guildMemberJoinDate +
guildMemberJoinMonth + "." + "." +
guildMemberJoinYear + " " + guildMemberJoinMonth +
guildMemberJoinHours + ":" + "." +
guildMemberJoinMinutes + ":" + guildMemberJoinYear +
" " +
guildMemberJoinHours +
":" +
guildMemberJoinMinutes +
":" +
guildMemberJoinSeconds guildMemberJoinSeconds
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
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:** `" +
guildName +
"`\n" +
"**Guild Rank:** `" +
guildRank +
"`\n",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head!, url: head!,
@@ -150,8 +196,13 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
}, },
{ {
name: "**Weekly GEXP**", name: "**Weekly GEXP**",
value: "**➺ Total:** `" + totalWeeklyGexp + "`\n" + value:
"**➺ Daily avarage:** `" + averageWeeklyGexp + "`", "**➺ Total:** `" +
totalWeeklyGexp +
"`\n" +
"**➺ Daily avarage:** `" +
averageWeeklyGexp +
"`",
}, },
{ {
name: "**Join date**", name: "**Join date**",
@@ -160,9 +211,10 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
], ],
footer: { footer: {
text: footerText + " | " + devMessage, text: footerText + " | " + devMessage,
icon_url: footerIcon! icon_url: footerIcon!,
}, },
}], },
],
}) })
} }

View File

@@ -4,7 +4,9 @@ import { ChannelType, ChatInputCommandInteraction } from "discord.js"
import { redis } from "../../utils/Redis" import { redis } from "../../utils/Redis"
import { GuildData } from "../../interfaces/Guild" import { GuildData } from "../../interfaces/Guild"
async function guildTop(interaction: ChatInputCommandInteraction): Promise<void> { async function guildTop(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply() await interaction.deferReply()
const query = interaction.options.getString("query")! const query = interaction.options.getString("query")!
@@ -15,101 +17,123 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
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
} }
@@ -121,18 +145,26 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
const cachedData = await redis.get("guildTop+" + guildId) const cachedData = await redis.get("guildTop+" + guildId)
const gexpTodayUnformatted = guildMembers.map((member) => { const gexpTodayUnformatted = guildMembers
.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(gexpTodayUnformatted / guildMembers.length) const averageGuildMemberGEXPUnformatted = Math.floor(
const averageGuildMemberGEXP = new Intl.NumberFormat("en-US").format(averageGuildMemberGEXPUnformatted) gexpTodayUnformatted / guildMembers.length,
)
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]],
} }
}) })
@@ -144,8 +176,8 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
amount = 1 amount = 1
} }
type GuildTopData = { ign: string, gexp: string }[] type GuildTopData = { ign: string; gexp: string }[]
type NewList = { name: string, value: string, inline: boolean }[] type NewList = { name: string; value: string; inline: boolean }[]
let cacheStatus: boolean let cacheStatus: boolean
let guildData: GuildTopData = [] let guildData: GuildTopData = []
@@ -155,14 +187,21 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
if (!cachedData) { if (!cachedData) {
cacheStatus = false cacheStatus = false
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Fetching the top " + amount + " members of " + guildName + "...", {
color: embedColor description:
}] "Fetching the top " +
amount +
" members of " +
guildName +
"...",
color: embedColor,
},
],
}) })
for (let i = 0; i < allMembersSorted.length; i++) { for (let i = 0; i < allMembersSorted.length; i++) {
const ign = await getIGN(allMembersSorted[i].uuid) as string const ign = (await getIGN(allMembersSorted[i].uuid)) as string
const gexpUnformatted = allMembersSorted[i].gexp const gexpUnformatted = allMembersSorted[i].gexp
const gexp = new Intl.NumberFormat("en-US").format(gexpUnformatted) const gexp = new Intl.NumberFormat("en-US").format(gexpUnformatted)
@@ -172,14 +211,26 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
}) })
} }
await redis.set("guildTop+" + guildId, JSON.stringify(guildData), "EX", 60 * 30) await redis.set(
"guildTop+" + guildId,
JSON.stringify(guildData),
"EX",
60 * 30,
)
} else { } else {
cacheStatus = true cacheStatus = true
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Fetching the top " + amount + " members of " + guildName + "using cache...", {
description:
"Fetching the top " +
amount +
" members of " +
guildName +
"using cache...",
color: embedColor, color: embedColor,
}] },
],
}) })
guildData = JSON.parse(cachedData) guildData = JSON.parse(cachedData)
} }
@@ -196,7 +247,9 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
fieldsValueRaw.push("**#" + position + " " + ign + ":** `" + gexp + "`") fieldsValueRaw.push("**#" + position + " " + ign + ":** `" + gexp + "`")
} }
const list = Array.from({ length: sliceSize }, (_, i) => fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize)) const list = Array.from({ length: sliceSize }, (_, i) =>
fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize),
)
const newList: NewList = [] const newList: NewList = []
list.forEach((item, index) => { list.forEach((item, index) => {
@@ -205,26 +258,37 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
newList[index] = { newList[index] = {
name: "", name: "",
value: item.join("\n"), value: item.join("\n"),
inline: true inline: true,
} }
}) })
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: 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:** `" +
gexpToday +
"`\n" +
"**Average guild memeber GEXP:** `" +
averageGuildMemberGEXP +
"`",
color: embedColor, color: embedColor,
fields: newList, fields: newList,
footer: { footer: {
text: footerText + " | " + devMessage + cacheStatusText, text: footerText + " | " + devMessage + cacheStatusText,
icon_url: footerIcon! icon_url: footerIcon!,
} },
}] },
],
}) })
} }

View File

@@ -18,14 +18,14 @@ export = {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
type CommandList = { type CommandList = {
name: string, name: string
value: string value: string
} }
const commandList: CommandList[] = [] const commandList: CommandList[] = []
const commandRawList = client.commands.map((command) => { const commandRawList = client.commands.map(command => {
return { return {
name: command.name, name: command.name,
command: command command: command,
} }
}) })
@@ -35,45 +35,53 @@ 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 + "`",
}) })
} }
} }
} }
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
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({ forceStatic: true })! url: interaction?.guild?.iconURL({
forceStatic: true,
})!,
}, },
footer: { footer: {
icon_url: footerIcon!, icon_url: footerIcon!,
text: footerText + " | " + devMessage text: footerText + " | " + devMessage,
} },
}] },
],
}) })
},
}
} as Command } as Command

View File

@@ -18,9 +18,11 @@ 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:
"1. Log onto hypixel.\n" +
"2. Right click with the head in your hotbar.\n" + "2. Right click with the head in your hotbar.\n" +
"3. Click on the social media icon.\n" + "3. Click on the social media icon.\n" +
"4. Click on the discord icon.\n" + "4. Click on the discord icon.\n" +
@@ -29,14 +31,16 @@ export = {
color: embedColor, color: embedColor,
footer: { footer: {
text: interaction.guild!.name + " | " + devMessage, text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })! icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
}, },
image: { image: {
url: instructionsgif, url: instructionsgif,
proxy_url: instructionsgif proxy_url: instructionsgif,
} },
}] },
],
}) })
},
}
} as Command } as Command

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, GuildMember } from "discord.js" import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
GuildMember,
} from "discord.js"
import { admin, helper } from "../../config/roles.json" import { admin, helper } from "../../config/roles.json"
import { color } from "../../config/options.json" import { color } from "../../config/options.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
@@ -17,20 +22,24 @@ 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),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply() await interaction.deferReply()
const member = interaction.options.getMember("member") as GuildMember | null const member = interaction.options.getMember(
const reason = interaction.options.getString("reason") ?? "No reason provided." "member",
) as GuildMember | null
const reason =
interaction.options.getString("reason") ?? "No reason provided."
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!member) { if (!member) {
@@ -43,7 +52,9 @@ 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("You do not have permission to use this command.") await interaction.editReply(
"You do not have permission to use this command.",
)
return return
} }
@@ -75,19 +86,28 @@ export = {
await member.kick(reason + ` - ${mod.user.username}`) await member.kick(reason + ` - ${mod.user.username}`)
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) +
"\n" +
"**Reason:** " +
reason +
"\n" +
"**Moderator:** " +
mod.user.username,
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + member.user.id, text: "ID: " + member.user.id,
icon_url: member.user.avatarURL({ forceStatic: false }) || undefined icon_url:
member.user.avatarURL({ forceStatic: false }) ||
undefined,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
},
}
} as Command } as Command

View File

@@ -18,19 +18,25 @@ export = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
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: footerText + " | " + devMessage, text: footerText + " | " + devMessage,
icon_url: footerIcon || undefined icon_url: footerIcon || undefined,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
} },
} as Command } as Command

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js" import { SlashCommandBuilder, PermissionFlagsBits } 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 { help} from "./staff/help" import { help } from "./staff/help"
import { beast } from "./staff/beast" import { beast } from "./staff/beast"
import { updateDiscordRoles } from "./staff/updatediscordroles" import { updateDiscordRoles } from "./staff/updatediscordroles"
@@ -19,7 +19,8 @@ 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
.setName("beast") .setName("beast")
@@ -28,19 +29,20 @@ 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("Update the discord roles of all guild members") .setDescription(
"Update the discord roles of all guild members",
),
) )
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction, client) { async execute(interaction, client) {
const subcommand = interaction.options.getSubcommand() const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -59,18 +61,24 @@ export = {
return return
} }
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
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: footerText + " | " + devMessage, text: footerText + " | " + devMessage,
icon_url: footerIcon! icon_url: footerIcon!,
} },
}] },
],
}) })
} },
} as Command } as Command

View File

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

View File

@@ -2,18 +2,21 @@ 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 async function help(interaction: ChatInputCommandInteraction, client: Client): Promise<void> { export async function help(
interaction: ChatInputCommandInteraction,
client: Client,
): Promise<void> {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
type CommandList = { type CommandList = {
name: string, name: string
value: string value: string
} }
const commandList: CommandList[] = [] const commandList: CommandList[] = []
const commandRawList = client.commands.map((command) => { const commandRawList = client.commands.map(command => {
return { return {
name: command.name, name: command.name,
command: command command: command,
} }
}) })
@@ -23,43 +26,48 @@ export async function help(interaction: ChatInputCommandInteraction, client: Cli
if (!command.command.subcommands && !command.command.public) { 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 + "`",
}) })
} }
} }
} }
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username const footerText = interaction.guild
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false }) ? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
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({ forceStatic: false })! url: interaction.guild!.iconURL({ forceStatic: false })!,
}, },
footer: { footer: {
icon_url: footerIcon!, icon_url: footerIcon!,
text: footerText + " | " + devMessage text: footerText + " | " + devMessage,
} },
}], },
],
}) })
} }

View File

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

View File

@@ -1,4 +1,10 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, ChatInputCommandInteraction, GuildMember } from "discord.js" import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
ChatInputCommandInteraction,
GuildMember,
} from "discord.js"
import { color } from "../../config/options.json" import { color } from "../../config/options.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
import ms from "ms" import ms from "ms"
@@ -17,26 +23,29 @@ const command: Command = {
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),
async execute(interaction: ChatInputCommandInteraction) { async execute(interaction: ChatInputCommandInteraction) {
await interaction.deferReply() await interaction.deferReply()
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 = interaction.options.getString("reason") || "No reason provided" const reason =
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)
@@ -45,50 +54,65 @@ const command: Command = {
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 (interaction.guild!.members.me!.roles.highest.position <= target.roles.highest.position) { if (
interaction.guild!.members.me!.roles.highest.position <=
target.roles.highest.position
) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds: [
description: "I cannot timeout this user because their role is higher than mine.", {
description:
"I cannot timeout this user because their role is higher than mine.",
color: embedColor, 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:
"You cannot timeout this user because their role is higher than yours.",
color: embedColor, 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
} }
@@ -97,47 +121,69 @@ const command: Command = {
if (time === 0) { if (time === 0) {
await target.timeout(null, reason) await target.timeout(null, reason)
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Removed timeout of " + userMention(target.id) + " for " + reason, {
description:
"Removed timeout of " +
userMention(target.id) +
" for " +
reason,
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + target.id, text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined icon_url: target.avatarURL() || undefined,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
return return
} }
await target.timeout(time, reason) await target.timeout(time, reason)
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Updated timeout of " + userMention(target.id) + " to " + prettyTime + " for " + reason, {
description:
"Updated timeout of " +
userMention(target.id) +
" to " +
prettyTime +
" for " +
reason,
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + target.id, text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined icon_url: target.avatarURL() || undefined,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
return return
} }
await target.timeout(time, reason) await target.timeout(time, reason)
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Timed out " + userMention(target.id) + " for " + prettyTime + " for " + reason, {
description:
"Timed out " +
userMention(target.id) +
" for " +
prettyTime +
" for " +
reason,
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + target.id, text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined icon_url: target.avatarURL() || undefined,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
} },
} }
export = command export = command

View File

@@ -1,4 +1,9 @@
import { SlashCommandBuilder, PermissionFlagsBits, userMention, User } from "discord.js" import {
SlashCommandBuilder,
PermissionFlagsBits,
userMention,
User,
} from "discord.js"
import { color } from "../../config/options.json" import { color } from "../../config/options.json"
import { Command } from "../interfaces" import { Command } from "../interfaces"
@@ -17,13 +22,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),
@@ -32,17 +37,20 @@ export = {
await interaction.deferReply() await interaction.deferReply()
const userid = interaction.options.getString("user")! const userid = interaction.options.getString("user")!
const reason = interaction.options.getString("reason") || "No reason provided" const reason =
interaction.options.getString("reason") || "No reason provided"
const mod = interaction.user const mod = interaction.user
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
let user: User | null let user: User | null
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
} }
@@ -51,31 +59,43 @@ 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,
}] },
],
}) })
} }
await interaction.guild!.members.unban(user!.id, reason) await interaction.guild!.members.unban(user!.id, reason)
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 +
" has been unbanned.\n" +
"**Reason:** `" +
reason +
"`\n" +
"**Moderator:** " +
userMention(mod.id),
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: user!.avatarURL({ forceStatic: false }) || "" url: user!.avatarURL({ forceStatic: false }) || "",
}, },
footer: { footer: {
text: "ID: " + user!.id, text: "ID: " + user!.id,
icon_url: interaction.guild!.iconURL({ forceStatic: false })! icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
} },
} as Command } as Command

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,23 +12,29 @@ export = {
} }
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) => { console.log(err) }) await interaction.respond(results.slice(0, 25)).catch(err => {
} console.log(err)
})
},
} as Autocomplete } as Autocomplete

View File

@@ -1,7 +1,22 @@
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 { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } from "../../../config/reqs.json" import {
import { hypixelLevel, bedwarsLevel, skywarsLevel, getPlayer, getGuild, getHeadURL } from "../../utils/Hypixel" bwfkdr,
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 = {
@@ -22,10 +37,13 @@ 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.", {
color: embedColor description:
}] "That player hasn't played Hypixel before.",
color: embedColor,
},
],
}) })
return return
} }
@@ -69,14 +87,14 @@ export = {
if (!guild) { if (!guild) {
guildRank = "N/A" guildRank = "N/A"
} else { } else {
guildRank = guild.members.find((m) => m.uuid === uuid)!.rank guildRank = guild.members.find(m => m.uuid === uuid)!.rank
} }
const statsFields = [] const statsFields = []
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) {
@@ -88,23 +106,36 @@ export = {
const hsbwwins = player.stats?.Bedwars?.wins_bedwars || 0 const hsbwwins = player.stats?.Bedwars?.wins_bedwars || 0
let bwtitle = "" let bwtitle = ""
if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) { if (
bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements." hsbwstars < bwstars ||
hsbwfkdr < bwfkdr ||
hsbwwins < bwwins
) {
bwtitle =
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
} else { } else {
bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements." bwtitle =
"<a:check_a:1087808632172847134> This player meets the BedWars requirements."
} }
statsFields.push({ statsFields.push({
name: bwtitle, name: bwtitle,
value: "**➺ Stars:** `" + value:
hsbwstars.toFixed(2).toString() + " / " + "**➺ Stars:** `" +
bwstars.toString() + "`\n" + hsbwstars.toFixed(2).toString() +
" / " +
bwstars.toString() +
"`\n" +
"**➺ FKDR:** `" + "**➺ FKDR:** `" +
hsbwfkdr.toFixed(2).toString() + hsbwfkdr.toFixed(2).toString() +
" / " + bwfkdr.toString() + "`\n" + " / " +
bwfkdr.toString() +
"`\n" +
"**➺ Wins:** `" + "**➺ Wins:** `" +
hsbwwins.toString() + " / " + hsbwwins.toString() +
bwwins.toString() + "`" " / " +
bwwins.toString() +
"`",
}) })
} }
@@ -118,9 +149,11 @@ export = {
let swtitle = "" let swtitle = ""
if (hsswstars < swstars || hsswkd < swkdr) { if (hsswstars < swstars || hsswkd < swkdr) {
swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements." swtitle =
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
} else { } else {
swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements." swtitle =
"<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
} }
statsFields.push({ statsFields.push({
@@ -128,12 +161,17 @@ export = {
value: value:
"**➺ Stars:** `" + "**➺ Stars:** `" +
hsswstars.toFixed(2).toString() + hsswstars.toFixed(2).toString() +
" / " + swstars.toString() + "`\n" + " / " +
swstars.toString() +
"`\n" +
"**➺ KDR:** `" + "**➺ KDR:** `" +
hsswkd.toFixed(2).toString() + " / " + hsswkd.toFixed(2).toString() +
swkdr.toString() + "`\n" + " / " +
swkdr.toString() +
"`\n" +
"**➺ Wins:** `" + "**➺ Wins:** `" +
hsswwins.toString() + "`" hsswwins.toString() +
"`",
}) })
} }
@@ -147,21 +185,29 @@ export = {
let duelstitle = "" let duelstitle = ""
if (hsduelswins < duelswins || hsduelswlr < duelswlr) { if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements." duelstitle =
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
} else { } else {
duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements." duelstitle =
"<a:check_a:1087808632172847134> This player meets the Duels requirements."
} }
statsFields.push({ statsFields.push({
name: duelstitle, name: duelstitle,
value: "**➺ Wins:** `" + value:
"**➺ Wins:** `" +
hsduelswins.toString() + hsduelswins.toString() +
" / " + duelswins.toString() + "`\n" + " / " +
duelswins.toString() +
"`\n" +
"**➺ WLR:** `" + "**➺ WLR:** `" +
hsduelswlr.toFixed(2).toString() + hsduelswlr.toFixed(2).toString() +
" / " + duelswlr.toString() + "`\n" + " / " +
duelswlr.toString() +
"`\n" +
"**➺ KDR:** `" + "**➺ KDR:** `" +
hsduelskd.toFixed(2).toString() + "`" hsduelskd.toFixed(2).toString() +
"`",
}) })
} }
} }
@@ -171,22 +217,30 @@ export = {
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:** `" + description:
level.toFixed(2).toString() + "`\n" + "**Network Level:** `" +
"**Current Guild:** `" + guildName + "`\n" + level.toFixed(2).toString() +
"**Guild Rank:** `" + guildRank + "`", "`\n" +
"**Current Guild:** `" +
guildName +
"`\n" +
"**Guild Rank:** `" +
guildRank +
"`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head! url: head!,
}, },
footer: { footer: {
text: interaction.guild!.name + " | " + devMessage, text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL()! icon_url: interaction.guild!.iconURL()!,
}, },
fields: statsFields fields: statsFields,
}] },
],
}) })
} },
} as Button } as Button

View File

@@ -12,7 +12,6 @@ export = {
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
await interaction.deferReply() await interaction.deferReply()
const user = interaction.user const user = interaction.user
@@ -25,7 +24,8 @@ 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 = applicant.user.username + "#" + applicant.user.discriminator const applicantUsername =
applicant.user.username + "#" + applicant.user.discriminator
await message.edit({ await message.edit({
components: [ components: [
@@ -44,16 +44,19 @@ 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.", {
color: embedColor description:
}] "Your application for the Illegitimate guild has been accepted.",
color: embedColor,
},
],
}) })
const applicantEntry = await guildapp.findOne({ userID: applicantId }) const applicantEntry = await guildapp.findOne({ userID: applicantId })
@@ -65,7 +68,7 @@ export = {
userID: applicantId, userID: applicantId,
uuid: applicantUUID, uuid: applicantUUID,
IGN: applicantIGN, IGN: applicantIGN,
timestamp: time timestamp: time,
}) })
await waitingListAdd.save() await waitingListAdd.save()
@@ -73,20 +76,22 @@ export = {
await applicant.roles.add(waitingListRole) await applicant.roles.add(waitingListRole)
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:
"Application has been accepted by <@" + user.id + ">.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: applicant.avatarURL() || guild.iconURL()! url: applicant.avatarURL() || guild.iconURL()!,
}, },
footer: { footer: {
icon_url: guild.iconURL()!, icon_url: guild.iconURL()!,
text: "ID: " + applicant.id text: "ID: " + applicant.id,
} },
}] },
],
}) })
} },
} as Button } as Button

View File

@@ -1,4 +1,9 @@
import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js" import {
ModalBuilder,
ActionRowBuilder,
TextInputBuilder,
TextInputStyle,
} from "discord.js"
import { Button } from "../../interfaces" import { Button } from "../../interfaces"
export = { export = {
@@ -7,7 +12,6 @@ export = {
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
const modal = new ModalBuilder() const modal = new ModalBuilder()
.setTitle("Deny Reason") .setTitle("Deny Reason")
.setCustomId("denyreasonbox") .setCustomId("denyreasonbox")
@@ -17,10 +21,12 @@ export = {
.setLabel("Deny Reason") .setLabel("Deny Reason")
.setCustomId("denyreason") .setCustomId("denyreason")
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setPlaceholder("Enter a reason for denying the application") .setPlaceholder(
.setRequired(false) "Enter a reason for denying the application",
) )
.setRequired(false),
),
) )
await interaction.showModal(modal) await interaction.showModal(modal)
} },
} as Button } as Button

View File

@@ -1,4 +1,11 @@
import { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder, GuildMember, GuildTextBasedChannel } from "discord.js" import {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
EmbedBuilder,
GuildMember,
GuildTextBasedChannel,
} from "discord.js"
import { color } from "../../../config/options.json" import { color } from "../../../config/options.json"
import { largeM, smallM, ignM } from "../../../config/limitmessages.json" import { largeM, smallM, ignM } from "../../../config/limitmessages.json"
import { applicationsChannel } from "../../../config/options.json" import { applicationsChannel } from "../../../config/options.json"
@@ -15,7 +22,6 @@ export = {
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
const user = interaction.member as GuildMember const user = interaction.member as GuildMember
const guild = interaction.guild! const guild = interaction.guild!
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -31,18 +37,21 @@ export = {
} }
if (interaction.customId === "guildapply") { if (interaction.customId === "guildapply") {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
if (userRoles.includes(guildRole)) { if (userRoles.includes(guildRole)) {
await interaction.editReply("You are already a member of the guild.") await interaction.editReply(
"You are already a member of the guild.",
)
return return
} }
const application = await guildapp.findOne({ userID: user.user.id }) const application = await guildapp.findOne({ userID: user.user.id })
if (application) { if (application) {
await interaction.editReply("You already have an application in progress.") await interaction.editReply(
"You already have an application in progress.",
)
return return
} }
@@ -53,20 +62,25 @@ 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("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") .setDescription(
"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 Application", title: "Guild Application",
description: "Please answer the following questions to apply for the guild.\n" + description:
"Please answer the following questions to apply for the guild.\n" +
"If you wish to cancel your application, please type `cancel` at any time.\n" + "If you wish to cancel your application, please type `cancel` at any time.\n" +
"If you wish to proceed with your application, please type `yes`.\n\n" + "If you wish to proceed with your application, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" + "**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.", "You have a minute to respond to this message.",
color: embedColor, color: embedColor,
}] },
],
}) })
} catch (error) { } catch (error) {
await interaction.editReply("Please enable your DMs.") await interaction.editReply("Please enable your DMs.")
@@ -78,7 +92,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] })
@@ -95,14 +109,20 @@ export = {
// first question // first question
await user.send({ await user.send({
embeds: [{ embeds: [
{
title: "**Question 1**", title: "**Question 1**",
description: qu(1) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`", description:
qu(1) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
ignM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 5 minutes to respond to this message." 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,
@@ -123,21 +143,26 @@ 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:
"That is not a valid Minecraft username.\n" +
"Application cancelled.", "Application cancelled.",
color: embedColor color: embedColor,
}] },
],
}) })
return return
} }
@@ -145,19 +170,24 @@ export = {
// second question // second question
await user.send({ await user.send({
embeds: [{ embeds: [
{
title: "**Question 2**", title: "**Question 2**",
description: qu(2) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(8 characters max)`", description:
qu(2) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n" +
"`(8 characters max)`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -173,10 +203,12 @@ export = {
} }
if (answer2.first()!.content.length > 8) { if (answer2.first()!.content.length > 8) {
await user.send({ await user.send({
embeds: [{ embeds: [
{
description: "Max character limit is 8.", description: "Max character limit is 8.",
color: embedColor color: embedColor,
}] },
],
}) })
return return
} }
@@ -184,19 +216,25 @@ export = {
// third question // third question
await user.send({ await user.send({
embeds: [{ embeds: [
{
title: "**Question 3**", title: "**Question 3**",
description: qu(3) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", description:
qu(3) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
smallM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -212,30 +250,38 @@ export = {
} }
if (answer3.first()!.content.length > 128) { if (answer3.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,
}] },
],
}) })
} }
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: qu(4) + "\n\nPlease type your answer below or type `cancel` to cancel your application." + description:
" `(We expect a longer answer.)`\n`" + largeM + "`", qu(4) +
"\n\nPlease type your answer below or type `cancel` to cancel your application." +
" `(We expect a longer answer.)`\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -251,29 +297,37 @@ 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: qu(5) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", description:
qu(5) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
smallM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -289,29 +343,37 @@ export = {
} }
if (answer5.first()!.content.length > 128) { if (answer5.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,
}] },
],
}) })
} }
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: qu(6) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", description:
qu(6) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -327,29 +389,37 @@ 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
// seventh question // seventh question
await user.send({ await user.send({
embeds: [{ embeds: [
{
title: "**Question 7**", title: "**Question 7**",
description: qu(7) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", description:
qu(7) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
smallM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." text: "You have 15 minutes to respond to this message.",
} },
}] },
],
}) })
const answer7 = await user.dmChannel!.awaitMessages({ const answer7 = 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 (answer7.size === 0) { if (answer7.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -365,29 +435,36 @@ export = {
} }
if (answer7.first()!.content.length > 128) { if (answer7.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,
}] },
],
}) })
} }
const answer7_1 = answer7!.first()!.content const answer7_1 = answer7!.first()!.content
// eighth question // eighth question
await user.send({ await user.send({
embeds: [{ embeds: [
{
title: "**Question 8**", title: "**Question 8**",
description: qu(8) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(64 characters max)`", description:
qu(8) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n" +
"`(64 characters max)`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." text: "You have 15 minutes to respond to this message.",
} },
}] },
],
}) })
const answer8 = await user.dmChannel!.awaitMessages({ const answer8 = 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 (answer8.size === 0) { if (answer8.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] })
@@ -403,25 +480,30 @@ export = {
} }
if (answer8.first()!.content.length > 64) { if (answer8.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,
}] },
],
}) })
} }
const answer8_1 = answer8.first()!.content const answer8_1 = answer8.first()!.content
await user.send({ await user.send({
embeds: [{ embeds: [
description: "If you want to submit your application, type `yes` if not, type `no`", {
color: embedColor description:
}] "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] })
@@ -437,10 +519,12 @@ 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 newGuildApp = new guildapp({ const newGuildApp = new guildapp({
@@ -451,53 +535,61 @@ export = {
await newGuildApp.save() await newGuildApp.save()
const channel = guild.channels.cache.get(applicationsChannel) as GuildTextBasedChannel const channel = guild.channels.cache.get(
applicationsChannel,
) as GuildTextBasedChannel
await channel.send({ await channel.send({
embeds: [{ embeds: [
title: user.user.username + "#" + user.user.discriminator + " - Guild Application", {
title:
user.user.username +
"#" +
user.user.discriminator +
" - Guild Application",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: user.avatarURL() || guild.iconURL()! url: user.avatarURL() || guild.iconURL()!,
}, },
fields: [ fields: [
{ {
name: rq(1), name: rq(1),
value: "```" + answer1_1 + "```" value: "```" + answer1_1 + "```",
}, },
{ {
name: rq(2), name: rq(2),
value: "```" + answer2_1 + "```" value: "```" + answer2_1 + "```",
}, },
{ {
name: rq(3), name: rq(3),
value: "```" + answer3_1 + "```" value: "```" + answer3_1 + "```",
}, },
{ {
name: rq(4), name: rq(4),
value: "```" + answer4_1 + "```" value: "```" + answer4_1 + "```",
}, },
{ {
name: rq(5), name: rq(5),
value: "```" + answer5_1 + "```" value: "```" + answer5_1 + "```",
}, },
{ {
name: rq(6), name: rq(6),
value: "```" + answer6_1 + "```" value: "```" + answer6_1 + "```",
}, },
{ {
name: rq(7), name: rq(7),
value: "```" + answer7_1 + "```" value: "```" + answer7_1 + "```",
}, },
{ {
name: rq(8), name: rq(8),
value: "```" + answer8_1 + "```" value: "```" + answer8_1 + "```",
} },
], ],
footer: { footer: {
icon_url: guild.iconURL()!, icon_url: guild.iconURL()!,
text: "ID: " + user.user.id text: "ID: " + user.user.id,
} },
}], },
],
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -511,11 +603,10 @@ export = {
new ButtonBuilder() new ButtonBuilder()
.setCustomId("checkstats") .setCustomId("checkstats")
.setLabel("Check Stats") .setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary) .setStyle(ButtonStyle.Secondary),
) ),
] ],
}) })
}
} }
},
} as Button } as Button

View File

@@ -1,10 +1,33 @@
import { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder, GuildMember, GuildTextBasedChannel } from "discord.js" import {
import { gm, manager, moderator, beast, member, guildStaff, guildRole } from "../../../config/roles.json" ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
EmbedBuilder,
GuildMember,
GuildTextBasedChannel,
} 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 = [gm, manager, moderator, beast, member, guildStaff, guildRole] const guildRoles = [
gm,
manager,
moderator,
beast,
member,
guildStaff,
guildRole,
]
module.exports = { module.exports = {
name: "guildinactivitylog", name: "guildinactivitylog",
@@ -18,10 +41,10 @@ module.exports = {
const userRoles = user.roles.cache const userRoles = user.roles.cache
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" 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,
}) })
} }
@@ -40,30 +63,42 @@ 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("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") .setDescription(
"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:
"Please answer the following questions to submit an inactivity log for the guild.\n" +
"If you wish to cancel your form, please press type `cancel` at any time.\n" + "If you wish to cancel your form, please press type `cancel` at any time.\n" +
"If you wish to proceed with your form, please type `yes`.\n\n" + "**Do not upload images, videos, or GIFS.**\n" + "If you wish to proceed with your form, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.", "You have a minute to respond to this message.",
color: embedColor color: embedColor,
}] },
],
}) })
} catch (error) { } catch (error) {
return await interaction.reply({ content: "Please enable your DMs.", ephemeral: true }) return await interaction.reply({
content: "Please enable your DMs.",
ephemeral: true,
})
} }
await interaction.reply({ content: "Please check your DMs.", ephemeral: true }) await interaction.reply({
content: "Please check your DMs.",
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] })
@@ -79,20 +114,26 @@ 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:
sq(1) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
ignM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 5 minutes to respond to this message." 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] })
@@ -100,10 +141,12 @@ 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 return
} }
@@ -111,10 +154,14 @@ module.exports = {
await fetch(mojangAPI + answer1.first()!.content) await fetch(mojangAPI + answer1.first()!.content)
} catch (error) { } catch (error) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "That is not a valid Minecraft username.\n" + "Application cancelled.", {
color: embedColor description:
}] "That is not a valid Minecraft username.\n" +
"Application cancelled.",
color: embedColor,
},
],
}) })
return return
} }
@@ -129,19 +176,25 @@ module.exports = {
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:
sq(2) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
smallM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 5 minutes to respond to this message." 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] })
@@ -149,10 +202,12 @@ 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
} }
@@ -167,19 +222,25 @@ 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:
sq(3) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -187,10 +248,12 @@ 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
} }
@@ -205,15 +268,18 @@ 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`", {
color: embedColor description:
}] "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] })
@@ -229,40 +295,50 @@ 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(inactivityLogChannel) as GuildTextBasedChannel const appChannel = guild.channels.cache.get(
inactivityLogChannel,
) as GuildTextBasedChannel
await appChannel.send({ await appChannel.send({
embeds: [{ embeds: [
title: user.user.username + "#" + user.user.discriminator + " - Inactivity Application", {
title:
user.user.username +
"#" +
user.user.discriminator +
" - Inactivity Application",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: user.displayAvatarURL({ forceStatic: false }) url: user.displayAvatarURL({ forceStatic: false }),
}, },
fields: [ fields: [
{ {
name: rq(1), name: rq(1),
value: "`" + answer1_1 + "`" value: "`" + answer1_1 + "`",
}, },
{ {
name: rq(2), name: rq(2),
value: "`" + answer2_1 + "`" value: "`" + answer2_1 + "`",
}, },
{ {
name: rq(3), name: rq(3),
value: "`" + answer3_1 + "`" value: "`" + answer3_1 + "`",
} },
], ],
footer: { footer: {
icon_url: user.displayAvatarURL({ forceStatic: false }), icon_url: user.displayAvatarURL({ forceStatic: false }),
text: "ID: " + user.user.id text: "ID: " + user.user.id,
} },
}], },
],
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -273,8 +349,8 @@ module.exports = {
.setCustomId("inactiveapplicationdeny") .setCustomId("inactiveapplicationdeny")
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
) ),
] ],
}) })
} },
} as Button } as Button

View File

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

View File

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

View File

@@ -20,13 +20,17 @@ 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 = applicant.user.username + "#" + applicant.user.discriminator const applicantUsername =
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.", {
color: embedColor description:
}] "Your application for the Illegitimate staff team has been accepted.",
color: embedColor,
},
],
}) })
await message.edit({ await message.edit({
@@ -41,26 +45,28 @@ 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: { footer: {
icon_url: guild.iconURL()!, icon_url: guild.iconURL()!,
text: "ID: " + applicantId text: "ID: " + applicantId,
} },
}] },
],
}) })
} },
} as Button } as Button

View File

@@ -1,4 +1,9 @@
import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js" import {
ModalBuilder,
ActionRowBuilder,
TextInputBuilder,
TextInputStyle,
} from "discord.js"
import { Button } from "../../interfaces" import { Button } from "../../interfaces"
export = { export = {
@@ -7,7 +12,6 @@ export = {
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
const modal = new ModalBuilder() const modal = new ModalBuilder()
.setTitle("Deny Reason") .setTitle("Deny Reason")
.setCustomId("staffdenyreasonbox") .setCustomId("staffdenyreasonbox")
@@ -17,10 +21,12 @@ export = {
.setLabel("Deny Reason") .setLabel("Deny Reason")
.setCustomId("staffdenyreason") .setCustomId("staffdenyreason")
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setPlaceholder("Enter a reason for denying the application") .setPlaceholder(
.setRequired(false) "Enter a reason for denying the application",
) )
.setRequired(false),
),
) )
await interaction.showModal(modal) await interaction.showModal(modal)
} },
} as Button } as Button

View File

@@ -1,4 +1,11 @@
import { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder, GuildMember, GuildTextBasedChannel } from "discord.js" import {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
EmbedBuilder,
GuildMember,
GuildTextBasedChannel,
} 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"
@@ -16,7 +23,6 @@ export = {
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
const user = interaction.member as GuildMember const user = interaction.member as GuildMember
const guild = interaction.guild! const guild = interaction.guild!
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
@@ -34,12 +40,13 @@ export = {
} }
if (interaction.customId === "staffapply") { if (interaction.customId === "staffapply") {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
if (user.user.id !== config.prod.dev) { if (user.user.id !== config.prod.dev) {
if (status === "0") { if (status === "0") {
await interaction.editReply("Staff applications are currently closed.") await interaction.editReply(
"Staff applications are currently closed.",
)
return return
} }
} }
@@ -57,7 +64,9 @@ 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("You already have an application in progress.") await interaction.editReply(
"You already have an application in progress.",
)
return return
} }
@@ -68,20 +77,25 @@ 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("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") .setDescription(
"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: "Please answer the following questions to apply for staff.\n" + description:
"Please answer the following questions to apply for staff.\n" +
"If you wish to cancel your application, please press type `cancel` at any time.\n" + "If you wish to cancel your application, please press type `cancel` at any time.\n" +
"If you wish to proceed with your application, please type `yes`.\n\n" + "If you wish to proceed with your application, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" + "**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.", "You have a minute to respond to this message.",
color: embedColor, color: embedColor,
}] },
],
}) })
} catch (error) { } catch (error) {
await interaction.editReply("Please enable your DMs.") await interaction.editReply("Please enable your DMs.")
@@ -93,7 +107,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] })
@@ -110,14 +124,20 @@ 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:
sq(1) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
ignM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 5 minutes to respond to this message." 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,
@@ -138,21 +158,26 @@ 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:
"That is not a valid Minecraft username.\n" +
"Application cancelled.", "Application cancelled.",
color: embedColor color: embedColor,
}] },
],
}) })
return return
} }
@@ -160,19 +185,24 @@ 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" + "`(64 characters max)`", description:
sq(2) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n" +
"`(64 characters max)`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -188,10 +218,12 @@ 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
} }
@@ -199,19 +231,25 @@ 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:
sq(3) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -227,29 +265,37 @@ 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:
sq(4) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -265,29 +311,37 @@ 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:
sq(5) +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -303,30 +357,38 @@ 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) +
"\n\nPlease type your answer below or type `cancel` to cancel your application." +
"`(We expect a longer answer here)`\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer: { footer: {
text: "You have 15 minutes to respond to this message." 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] })
@@ -342,25 +404,30 @@ 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`", {
color: embedColor description:
}] "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] })
@@ -376,10 +443,12 @@ 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({
@@ -391,47 +460,54 @@ export = {
await newStaffApp.save() await newStaffApp.save()
await user.deleteDM() await user.deleteDM()
const channel = guild.channels.cache.get(staffApplicationsChannel) as GuildTextBasedChannel const channel = guild.channels.cache.get(
staffApplicationsChannel,
) as GuildTextBasedChannel
await channel.send({ await channel.send({
embeds: [{ embeds: [
title: user.user.username + "#" + user.user.discriminator + " - Staff Application", {
title:
user.user.username +
"#" +
user.user.discriminator +
" - Staff Application",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: user.avatarURL() || guild.iconURL()! url: user.avatarURL() || guild.iconURL()!,
}, },
fields: [ fields: [
{ {
name: rq(1), name: rq(1),
value: "```" + answer1_1 + "```" value: "```" + answer1_1 + "```",
}, },
{ {
name: rq(2), name: rq(2),
value: "```" + answer2_1 + "```" value: "```" + answer2_1 + "```",
}, },
{ {
name: rq(3), name: rq(3),
value: "```" + answer3_1 + "```" value: "```" + answer3_1 + "```",
}, },
{ {
name: rq(4), name: rq(4),
value: "```" + answer4_1 + "```" value: "```" + answer4_1 + "```",
}, },
{ {
name: rq(5), name: rq(5),
value: "```" + answer5_1 + "```" value: "```" + answer5_1 + "```",
}, },
{ {
name: rq(6), name: rq(6),
value: "```" + answer6_1 + "```" value: "```" + answer6_1 + "```",
} },
], ],
footer: { footer: {
icon_url: guild.iconURL()!, icon_url: guild.iconURL()!,
text: "ID: " + user.user.id text: "ID: " + user.user.id,
} },
}], },
],
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -441,10 +517,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,4 +1,9 @@
import { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } from "discord.js" import {
ModalBuilder,
ActionRowBuilder,
TextInputBuilder,
TextInputStyle,
} from "discord.js"
import { Button } from "../../interfaces" import { Button } from "../../interfaces"
export = { export = {
@@ -7,7 +12,6 @@ export = {
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
const modal = new ModalBuilder() const modal = new ModalBuilder()
.setTitle("Verification") .setTitle("Verification")
.setCustomId("verifybox") .setCustomId("verifybox")
@@ -20,9 +24,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

@@ -9,7 +9,6 @@ export = {
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({ ephemeral: true }) await interaction.deferReply({ ephemeral: true })
const user = interaction.user const user = interaction.user
@@ -18,7 +17,6 @@ export = {
const accepted = await waitinglist.find() const accepted = await waitinglist.find()
for (let i = 0; i < accepted.length; i++) { for (let i = 0; i < accepted.length; i++) {
const uuid = accepted[i].uuid const uuid = accepted[i].uuid
const guild = await getGuild(uuid) const guild = await getGuild(uuid)
@@ -26,23 +24,22 @@ export = {
await waitinglist.findOneAndDelete({ uuid: uuid }) await waitinglist.findOneAndDelete({ uuid: uuid })
continue continue
} }
} }
const fields = [] const fields = []
for (let i = 0; i < accepted.length; i++) { for (let i = 0; i < accepted.length; i++) {
const timestamp = Math.floor(accepted[i].timestamp / 1000) const timestamp = Math.floor(accepted[i].timestamp / 1000)
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!,
@@ -53,9 +50,10 @@ export = {
thumbnail: embed.thumbnail!, thumbnail: embed.thumbnail!,
fields: fields, fields: fields,
timestamp: new Date().toISOString(), 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,4 +1,11 @@
import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Message, GuildMember } from "discord.js" import {
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"
@@ -16,7 +23,9 @@ 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 = interaction.fields.fields.get("denyreason")!.value || "No reason provided" const reason =
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({
@@ -36,9 +45,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
@@ -49,23 +58,35 @@ export = {
} }
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription("Your application for the Illegitimate guild has been denied\n" + .setDescription(
"**Reason:** `" + reason + "`") "Your application for the Illegitimate guild has been denied\n" +
"**Reason:** `" +
reason +
"`",
)
.setColor(embedColor) .setColor(embedColor)
const missingUser = new EmbedBuilder() const missingUser = new EmbedBuilder()
.setDescription("[WARN] User has left the server and cannot be notified.") .setDescription(
"[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("The application has been denied by <@" + interaction.user.id + ">.\n" + .setDescription(
"**Reason:** `" + reason + "`") "The application has been denied by <@" +
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`",
)
.setColor(embedColor) .setColor(embedColor)
.setThumbnail(guild.iconURL()) .setThumbnail(guild.iconURL())
.setFooter({ .setFooter({
iconURL: guild.iconURL()!, iconURL: guild.iconURL()!,
text: "ID: " + applicantId text: "ID: " + applicantId,
}) })
if (applicant !== null) { if (applicant !== null) {
@@ -82,7 +103,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,4 +1,9 @@
import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js" import {
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"
@@ -12,7 +17,9 @@ export = {
await interaction.deferReply() await interaction.deferReply()
const guild = interaction.guild const guild = interaction.guild
const reason = interaction.fields.fields.get("staffdenyreason")!.value || "No reason provided" const reason =
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!
@@ -33,13 +40,17 @@ export = {
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger) .setStyle(ButtonStyle.Danger)
.setDisabled(true), .setDisabled(true),
) ),
] ],
}) })
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription("Your application for the Illegitimate guild staff has been denied\n" + .setDescription(
"**Reason:** `" + reason + "`") "Your application for the Illegitimate guild staff has been denied\n" +
"**Reason:** `" +
reason +
"`",
)
.setColor(embedColor) .setColor(embedColor)
await applicant.send({ embeds: [dmMessage] }) await applicant.send({ embeds: [dmMessage] })
@@ -47,19 +58,26 @@ 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 <@" +
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: applicant.avatarURL() || guild!.iconURL()! url: applicant.avatarURL() || guild!.iconURL()!,
}, },
footer: { footer: {
icon_url: guild!.iconURL()!, icon_url: guild!.iconURL()!,
text: "ID: " + applicant.id text: "ID: " + applicant.id,
} },
}], },
],
}) })
} },
} as Modal } as Modal

View File

@@ -2,7 +2,17 @@ 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 { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../../config/roles.json" import {
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../../config/roles.json"
import { Modal } from "../../interfaces" import { Modal } from "../../interfaces"
import { GuildMember } from "discord.js" import { GuildMember } from "discord.js"
@@ -20,17 +30,23 @@ 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("You are already verified.\n" + "Try running /update to update your roles.") interaction.editReply(
"You are already verified.\n" +
"Try running /update to update your roles.",
)
return 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.", {
color: embedColor description:
}] "<a:questionmark_pink:1130206038008803488> That player does not exist.",
color: embedColor,
},
],
}) })
return return
} }
@@ -39,10 +55,13 @@ 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.", {
color: embedColor description:
}] "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor,
},
],
}) })
return return
} }
@@ -59,11 +78,16 @@ export = {
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
} }
@@ -72,11 +96,18 @@ export = {
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
} }
@@ -91,7 +122,9 @@ export = {
if (guildID === hypixelGuildID) { if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members const GuildMembers = guild!.members
const guildRank = GuildMembers.find((member) => member.uuid === player.uuid)!.rank const guildRank = GuildMembers.find(
member => member.uuid === player.uuid,
)!.rank
if (guildRank === "Guild Master" && guildID === hypixelGuildID) { if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
await user.roles.add(gm, "Verification") await user.roles.add(gm, "Verification")
@@ -131,7 +164,7 @@ 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()
@@ -140,19 +173,23 @@ export = {
embeds: [ embeds: [
{ {
title: interaction.guild!.name, title: interaction.guild!.name,
description: "You have successfully verified `" + username + "` with the account `" + player.displayname + "`.", description:
"You have successfully verified `" +
username +
"` with the account `" +
player.displayname +
"`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head! url: head!,
}, },
footer: { footer: {
icon_url: interaction.guild!.iconURL()!, icon_url: interaction.guild!.iconURL()!,
text: interaction.guild!.name + " | " + devMessage text: interaction.guild!.name + " | " + devMessage,
} },
} },
] ],
}) })
} }
},
}
} as Modal } as Modal

View File

@@ -9,34 +9,41 @@ const event: Event = {
event: "guildMemberAdd", event: "guildMemberAdd",
execute(member: GuildMember) { execute(member: GuildMember) {
const channel = member.guild.channels.cache.get(botLogChannel) const channel = member.guild.channels.cache.get(botLogChannel)
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!channel) { if (!channel) {
console.log("[ERROR] Could not find channel used for new join logging.") console.log(
"[ERROR] Could not find channel used for new join logging.",
)
return return
} }
if (channel.type !== ChannelType.GuildText) { if (channel.type !== ChannelType.GuildText) {
console.log("[ERROR] The channel used for new join logging is not a text channel.") console.log(
"[ERROR] The channel used for new join logging is not a text channel.",
)
return return
} }
channel.send({ channel.send({
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) +
" has joined the server.\n" +
"Account created: " +
member.user.createdAt.toLocaleString(),
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + member.id text: "ID: " + member.id,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
},
}
} }
export = event export = event

View File

@@ -10,25 +10,33 @@ const event: Event = {
execute(interaction: ChatInputCommandInteraction | ButtonInteraction) { execute(interaction: ChatInputCommandInteraction | ButtonInteraction) {
if (interaction.isCommand()) { if (interaction.isCommand()) {
try { try {
console.log(interaction.user.username + " ran " + console.log(
interaction.commandName + " " + interaction.user.username +
interaction.options.getSubcommand() " ran " +
interaction.commandName +
" " +
interaction.options.getSubcommand(),
) )
} catch { } catch {
console.log(interaction.user.username + " ran " + console.log(
interaction.commandName interaction.user.username +
" ran " +
interaction.commandName,
) )
} }
} }
if (interaction.isButton()) { if (interaction.isButton()) {
console.log(interaction.user.username + "#" + console.log(
interaction.user.discriminator + " clicked " + interaction.user.username +
interaction.customId "#" +
interaction.user.discriminator +
" clicked " +
interaction.customId,
) )
return return
} }
} },
} }
export = event export = event

View File

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

View File

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

View File

@@ -16,7 +16,9 @@ const event: Event = {
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!channel) { if (!channel) {
console.log("[ERROR] Could not find channel used for online message.") console.log(
"[ERROR] Could not find channel used for online message.",
)
return return
} }
@@ -26,12 +28,14 @@ const event: Event = {
} }
channel.send({ channel.send({
embeds: [{ embeds: [
{
description: "Bot is online!", description: "Bot is online!",
color: embedColor color: embedColor,
}] },
],
}) })
} },
} }
export = event export = event

View File

@@ -9,7 +9,6 @@ const event: Event = {
event: "ready", event: "ready",
execute(client: Client) { execute(client: Client) {
// Playing 0 // Playing 0
// Streaming 1 // Streaming 1
// Listening 2 // Listening 2
@@ -19,20 +18,16 @@ const event: Event = {
const user = client.user! const user = client.user!
user.setActivity( user.setActivity({ name: statuses[0].name, type: statuses[0].type })
{ name: statuses[0].name, type: statuses[0].type }
)
let i = 1 let i = 1
setInterval(() => setInterval(
user.setActivity( () => user.setActivity(statuses[i++ % statuses.length]),
statuses[i++ % statuses.length] 1000 * 60 * 10,
),
1000 * 60 * 10
) )
user.setStatus("dnd") user.setStatus("dnd")
} },
} }
export = event export = event

View File

@@ -1,4 +1,9 @@
import { userMention, channelMention, VoiceState, ChannelType } from "discord.js" import {
userMention,
channelMention,
VoiceState,
ChannelType,
} from "discord.js"
import { botLogChannel, color } from "../../../../config/options.json" import { botLogChannel, color } from "../../../../config/options.json"
import { Event } from "../../../interfaces" import { Event } from "../../../interfaces"
@@ -9,20 +14,23 @@ const event: Event = {
event: "voiceStateUpdate", event: "voiceStateUpdate",
execute(oldState: VoiceState, newState: VoiceState) { execute(oldState: VoiceState, newState: VoiceState) {
if (process.env.NODE_ENV === "dev") return
if (process.env.NODE_ENV === 'dev') return
const guild = oldState.guild const guild = oldState.guild
const channel = guild.channels.cache.get(botLogChannel) const channel = guild.channels.cache.get(botLogChannel)
const embedColor = Number(color.replace("#", "0x")) const embedColor = Number(color.replace("#", "0x"))
if (!channel) { if (!channel) {
console.log("[ERROR] Could not find channel used for voice channel join/leave logging.") console.log(
"[ERROR] Could not find channel used for voice channel join/leave logging.",
)
return return
} }
if (channel.type !== ChannelType.GuildText) { if (channel.type !== ChannelType.GuildText) {
console.log("[ERROR] The channel used for voice channel join/leave logging is not a text channel.") console.log(
"[ERROR] The channel used for voice channel join/leave logging is not a text channel.",
)
return return
} }
@@ -30,60 +38,62 @@ const event: Event = {
const newChannel = newState.channel const newChannel = newState.channel
if (oldChannel === null && newChannel !== null) { if (oldChannel === null && newChannel !== null) {
channel.send({ channel.send({
embeds: [{ embeds: [
{
title: "Voice Channel Join", title: "Voice Channel Join",
description: userMention(newState.member!.id) + description:
userMention(newState.member!.id) +
" joined " + " joined " +
channelMention(newChannel.id), channelMention(newChannel.id),
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + newState.member!.id text: "ID: " + newState.member!.id,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
} else if (oldChannel !== null && newChannel === null) { } else if (oldChannel !== null && newChannel === null) {
channel.send({ channel.send({
embeds: [{ embeds: [
{
title: "Voice Channel Leave", title: "Voice Channel Leave",
description: userMention(oldState.member!.id) + description:
userMention(oldState.member!.id) +
" left " + " left " +
channelMention(oldChannel.id), channelMention(oldChannel.id),
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + oldState.member!.id text: "ID: " + oldState.member!.id,
}, },
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
channel.send({ channel.send({
embeds: [{ embeds: [
{
title: "Voice Channel Switch", title: "Voice Channel Switch",
description: userMention(oldState.member!.id) + description:
userMention(oldState.member!.id) +
" switched from " + " switched from " +
channelMention(oldChannel.id) + channelMention(oldChannel.id) +
" to " + " to " +
channelMention(newChannel.id), channelMention(newChannel.id),
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + oldState.member!.id text: "ID: " + oldState.member!.id,
}, },
timestamp: new Date().toISOString() timestamp: new Date().toISOString(),
}] },
],
}) })
}
} }
},
} }
export = event export = event

View File

@@ -1,4 +1,4 @@
import { ExtendedClient as Client} from "./utils/Client" import { ExtendedClient as Client } from "./utils/Client"
import { GatewayIntentBits, Partials } from "discord.js" import { GatewayIntentBits, Partials } from "discord.js"
import config from "./utils/Config" import config from "./utils/Config"
import { redis } from "./utils/Redis" import { redis } from "./utils/Redis"
@@ -13,14 +13,14 @@ const client = new 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,
] ],
}) })
loadAllEvents(client) loadAllEvents(client)

View File

@@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, SlashCommandBuilder} from "discord.js" import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"
import { ExtendedClient as Client } from "../utils/Client" import { ExtendedClient as Client } from "../utils/Client"
export default interface Command { export default interface Command {
@@ -7,7 +7,13 @@ export default interface Command {
type: "slash" type: "slash"
dev?: boolean dev?: boolean
public: boolean public: boolean
data: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup" | "addIntegerOption"> data: Omit<
SlashCommandBuilder,
"addSubcommand" | "addSubcommandGroup" | "addIntegerOption"
>
subcommands?: boolean subcommands?: boolean
execute: (interaction: ChatInputCommandInteraction, client: Client) => Promise<void> execute: (
interaction: ChatInputCommandInteraction,
client: Client,
) => Promise<void>
} }

View File

@@ -1,4 +1,7 @@
import { ContextMenuCommandInteraction, ContextMenuCommandBuilder } from "discord.js" import {
ContextMenuCommandInteraction,
ContextMenuCommandBuilder,
} from "discord.js"
export default interface ContextMenu { export default interface ContextMenu {
name: string name: string

View File

@@ -1,9 +1,9 @@
import { ClientEvents } from "discord.js" import { ClientEvents } from "discord.js"
export default interface Event { export default interface Event {
name: string, name: string
description: string, description: string
type: "event", type: "event"
event: keyof ClientEvents event: keyof ClientEvents
execute(...args: any[]): void execute(...args: any[]): void
} }

View File

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

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,15 +1,15 @@
export type Profile = { export type Profile = {
data: { data: {
id: string id: string
name: string; name: string
} }
} }
export type Profile2 = { export type Profile2 = {
data: { data: {
id: string, id: string
name: string, name: string
properties: { name: string, value: string }[], properties: { name: string; value: string }[]
profileActions: [] profileActions: []
} }
} }

View File

@@ -1,6 +1,3 @@
import { Profile, Profile2 } from "./Profile" import { Profile, Profile2 } from "./Profile"
export { export { Profile, Profile2 }
Profile,
Profile2
}

View File

@@ -1,13 +1,22 @@
import { Command } from "../interfaces" import { Command } from "../interfaces"
import config from "./Config" import config from "./Config"
import color from "./Colors" import color from "./Colors"
import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationGuildCommandsJSONBody, Routes } from "discord.js" import {
REST,
RESTGetAPIApplicationGuildCommandResult,
RESTPutAPIApplicationGuildCommandsJSONBody,
Routes,
} from "discord.js"
import fs = require("fs") import fs = require("fs")
async function autoDeployCommands() { async function autoDeployCommands() {
const commands = [] const commands = []
const commandFiles = fs.readdirSync("./dist/src/commands/").filter(file => file.endsWith(".js")) const commandFiles = fs
const contentMenuCommands = fs.readdirSync("./dist/src/commands-contextmenu/").filter(file => file.endsWith(".js")) .readdirSync("./dist/src/commands/")
.filter(file => file.endsWith(".js"))
const contentMenuCommands = fs
.readdirSync("./dist/src/commands-contextmenu/")
.filter(file => file.endsWith(".js"))
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`../commands/${file}`) const command = require(`../commands/${file}`)
@@ -24,9 +33,9 @@ async function autoDeployCommands() {
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken) const rest = new REST({ version: "10" }).setToken(config.dev.devtoken)
const currentCommands = await rest.get( const currentCommands = (await rest.get(
Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid), Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid),
) as RESTGetAPIApplicationGuildCommandResult[] )) as RESTGetAPIApplicationGuildCommandResult[]
const currentCommandsInfo = currentCommands.map(command => { const currentCommandsInfo = currentCommands.map(command => {
return { return {
@@ -41,36 +50,61 @@ async function autoDeployCommands() {
} }
}) })
const sortedCurrentCommandsInfo = currentCommandsInfo.sort((a, b) => a.name.localeCompare(b.name)) const sortedCurrentCommandsInfo = currentCommandsInfo.sort((a, b) =>
const sortedNewCommandsInfo = newCommandsInfo.sort((a, b) => a.name.localeCompare(b.name)) a.name.localeCompare(b.name),
)
const sortedNewCommandsInfo = newCommandsInfo.sort((a, b) =>
a.name.localeCompare(b.name),
)
const newCmds = sortedNewCommandsInfo.map(cmd => { const newCmds = sortedNewCommandsInfo
.map(cmd => {
return " " + cmd.name + " was registered." return " " + cmd.name + " was registered."
}).join("\n") })
const currentCmds = sortedCurrentCommandsInfo.map(cmd => { .join("\n")
const currentCmds = sortedCurrentCommandsInfo
.map(cmd => {
return " " + cmd.name + " was unregistered." return " " + cmd.name + " was unregistered."
}).join("\n") })
.join("\n")
if (JSON.stringify(sortedNewCommandsInfo) === JSON.stringify(sortedCurrentCommandsInfo)) { if (
console.log(color.colorize("Commands are the same, skipping deploy.", "green")) JSON.stringify(sortedNewCommandsInfo) ===
JSON.stringify(sortedCurrentCommandsInfo)
) {
console.log(
color.colorize("Commands are the same, skipping deploy.", "green"),
)
console.log(color.colorize(currentCmds, "green")) console.log(color.colorize(currentCmds, "green"))
return return
} }
(async () => { ;(async () => {
try { try {
console.log(color.colorize("Commands are different, starting deploy.", "red")) console.log(
color.colorize(
"Commands are different, starting deploy.",
"red",
),
)
console.log(color.colorize(currentCmds, "red")) console.log(color.colorize(currentCmds, "red"))
console.log(`Started refreshing ${commands.length} application (/) commands.`) console.log(
`Started refreshing ${commands.length} application (/) commands.`,
)
const data = await rest.put( const data = (await rest.put(
Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid), Routes.applicationGuildCommands(
config.dev.devid,
config.dev.guildid,
),
{ body: commands }, { body: commands },
) as RESTPutAPIApplicationGuildCommandsJSONBody[] )) as RESTPutAPIApplicationGuildCommandsJSONBody[]
console.log(color.colorize("New commands deployed.", "green")) console.log(color.colorize("New commands deployed.", "green"))
console.log(color.colorize(newCmds, "green")) console.log(color.colorize(newCmds, "green"))
console.log(`Successfully reloaded ${data.length} application (/) commands.`) console.log(
`Successfully reloaded ${data.length} application (/) commands.`,
)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }

View File

@@ -6,9 +6,9 @@ import { Modal } from "../interfaces"
import { Autocomplete } from "../interfaces" import { Autocomplete } from "../interfaces"
export class ExtendedClient extends Client { export class ExtendedClient extends Client {
commands: Collection<string, Command>= new Collection() commands: Collection<string, Command> = new Collection()
contextmenus: Collection<string, ContextMenu>= new Collection() contextmenus: Collection<string, ContextMenu> = new Collection()
buttons: Collection<string, Button>= new Collection() buttons: Collection<string, Button> = new Collection()
modals: Collection<string, Modal>= new Collection() modals: Collection<string, Modal> = new Collection()
autocomplete: Collection<string, Autocomplete>= new Collection() autocomplete: Collection<string, Autocomplete> = new Collection()
} }

View File

@@ -7,14 +7,14 @@ const config: Config = {
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 config export default config

View File

@@ -3,4 +3,10 @@ export { bedwarsLevel } from "./functions/bedwars"
export { hypixelLevel } from "./functions/hypixel" export { hypixelLevel } from "./functions/hypixel"
export { formatUuid } from "./functions/uuid" export { formatUuid } from "./functions/uuid"
export { guildLevel, scaledGEXP } from "./functions/guild" export { guildLevel, scaledGEXP } from "./functions/guild"
export { getUUID, getIGN, getPlayer, getGuild, getHeadURL } from "./functions/account" export {
getUUID,
getIGN,
getPlayer,
getGuild,
getHeadURL,
} from "./functions/account"

View File

@@ -5,18 +5,31 @@ import path = require("path")
import fs = require("fs") import fs = require("fs")
function loadAutocompleteEvents(client: Client) { function loadAutocompleteEvents(client: Client) {
const autocompletePath = path.join(__dirname, "..", "..", "events", "autocomplete") const autocompletePath = path.join(
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(".js")) __dirname,
"..",
"..",
"events",
"autocomplete",
)
const autocompleteFiles = fs
.readdirSync(autocompletePath)
.filter(file => file.endsWith(".js"))
for (const file of autocompleteFiles) { for (const file of autocompleteFiles) {
const filePath = path.join(autocompletePath, file) const filePath = path.join(autocompletePath, file)
const autocomplete: Autocomplete = require(filePath) const autocomplete: Autocomplete = require(filePath)
if ("name" in autocomplete && "execute" in autocomplete && autocomplete.type === "autocomplete") { if (
"name" in autocomplete &&
"execute" in autocomplete &&
autocomplete.type === "autocomplete"
) {
client.autocomplete.set(autocomplete.name, autocomplete) client.autocomplete.set(autocomplete.name, autocomplete)
} else { } else {
console.log(`[WARNING] The autocomplete at ${filePath} is missing a required "name", "execute" or "type" property.`) console.log(
`[WARNING] The autocomplete at ${filePath} is missing a required "name", "execute" or "type" property.`,
)
} }
} }
@@ -26,7 +39,9 @@ function loadAutocompleteEvents(client: Client) {
const autocomplete = client.autocomplete.get(interaction.commandName) const autocomplete = client.autocomplete.get(interaction.commandName)
if (!autocomplete) { if (!autocomplete) {
console.error(`No autocomplete matching ${interaction.commandName} was found.`) console.error(
`No autocomplete matching ${interaction.commandName} was found.`,
)
return return
} }

View File

@@ -6,28 +6,32 @@ import fs = require("fs")
function loadButtonEvents(client: Client) { function loadButtonEvents(client: Client) {
const btnPath = path.join(__dirname, "..", "..", "events", "buttons") const btnPath = path.join(__dirname, "..", "..", "events", "buttons")
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith(".js")) const btnFiles = fs
.readdirSync(btnPath)
.filter(file => file.endsWith(".js"))
for (const file of btnFiles) { for (const file of btnFiles) {
const filePath = path.join(btnPath, file) const filePath = path.join(btnPath, file)
const btn: Button = require(filePath) const btn: Button = require(filePath)
if ("name" in btn && "execute" in btn && btn.type === "button") { if ("name" in btn && "execute" in btn && btn.type === "button") {
client.buttons.set(btn.name, btn) client.buttons.set(btn.name, btn)
} else { } else {
console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`) console.log(
`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`,
)
} }
} }
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isButton()) if (!interaction.isButton()) return
return
const button = client.buttons.get(interaction.customId) const button = client.buttons.get(interaction.customId)
if (!button) { if (!button) {
console.error(`No event matching ${interaction.customId} was found.`) console.error(
`No event matching ${interaction.customId} was found.`,
)
return return
} }
@@ -37,7 +41,7 @@ function loadButtonEvents(client: Client) {
console.error(error) console.error(error)
await interaction.reply({ await interaction.reply({
content: "There was an error while executing this event!", content: "There was an error while executing this event!",
ephemeral: true ephemeral: true,
}) })
} }
}) })

View File

@@ -6,29 +6,33 @@ import fs = require("fs")
function loadSlashCommandsEvents(client: Client) { function loadSlashCommandsEvents(client: Client) {
const cmdPath = path.join(__dirname, "..", "..", "commands") const cmdPath = path.join(__dirname, "..", "..", "commands")
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith(".js")) const cmdFiles = fs
.readdirSync(cmdPath)
.filter(file => file.endsWith(".js"))
for (const file of cmdFiles) { for (const file of cmdFiles) {
const filePath = path.join(cmdPath, file) const filePath = path.join(cmdPath, file)
const cmd: Command = require(filePath) const cmd: Command = require(filePath)
if ("data" in cmd && "execute" in cmd && cmd.type === "slash") { if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
client.commands.set(cmd.data.name, cmd) client.commands.set(cmd.data.name, cmd)
} else { } else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`) console.log(
`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`,
)
} }
} }
//! command handler //! command handler
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) if (!interaction.isChatInputCommand()) return
return
const command = client.commands.get(interaction.commandName) const command = client.commands.get(interaction.commandName)
if (!command) { if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`) console.error(
`No command matching ${interaction.commandName} was found.`,
)
return return
} }
@@ -38,7 +42,7 @@ function loadSlashCommandsEvents(client: Client) {
console.error(error) console.error(error)
await interaction.reply({ await interaction.reply({
content: "There was an error while executing this command!", content: "There was an error while executing this command!",
ephemeral: true ephemeral: true,
}) })
} }
}) })

View File

@@ -5,30 +5,39 @@ import path = require("path")
import fs = require("fs") import fs = require("fs")
function loadContextMenuEvents(client: Client) { function loadContextMenuEvents(client: Client) {
const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu") const contextMenuPath = path.join(
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(".js")) __dirname,
"..",
"..",
"commands-contextmenu",
)
const contextMenuFiles = fs
.readdirSync(contextMenuPath)
.filter(file => file.endsWith(".js"))
for (const file of contextMenuFiles) { for (const file of contextMenuFiles) {
const filePath = path.join(contextMenuPath, file) const filePath = path.join(contextMenuPath, file)
const cmd: ContextMenu = require(filePath) const cmd: ContextMenu = require(filePath)
if ("data" in cmd && "execute" in cmd && cmd.type === "contextmenu") { if ("data" in cmd && "execute" in cmd && cmd.type === "contextmenu") {
client.contextmenus.set(cmd.data.name, cmd) client.contextmenus.set(cmd.data.name, cmd)
} else { } else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`) console.log(
`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`,
)
} }
} }
//! context menu command handler //! context menu command handler
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isContextMenuCommand()) if (!interaction.isContextMenuCommand()) return
return
const command = client.contextmenus.get(interaction.commandName) const command = client.contextmenus.get(interaction.commandName)
if (!command) { if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`) console.error(
`No command matching ${interaction.commandName} was found.`,
)
return return
} }
@@ -38,7 +47,7 @@ function loadContextMenuEvents(client: Client) {
console.error(error) console.error(error)
await interaction.reply({ await interaction.reply({
content: "There was an error while executing this command!", content: "There was an error while executing this command!",
ephemeral: true ephemeral: true,
}) })
} }
}) })

View File

@@ -14,7 +14,6 @@ function loadEvents(client: Client) {
client.on(event.event, event.execute) client.on(event.event, event.execute)
} }
} }
} }
export { loadEvents } export { loadEvents }

View File

@@ -6,28 +6,32 @@ import fs = require("fs")
function loadModalEvents(client: Client) { function loadModalEvents(client: Client) {
const modalPath = path.join(__dirname, "..", "..", "events", "modals") const modalPath = path.join(__dirname, "..", "..", "events", "modals")
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(".js")) const modalFiles = fs
.readdirSync(modalPath)
.filter(file => file.endsWith(".js"))
for (const file of modalFiles) { for (const file of modalFiles) {
const filePath = path.join(modalPath, file) const filePath = path.join(modalPath, file)
const modal: Modal = require(filePath) const modal: Modal = require(filePath)
if ("name" in modal && "execute" in modal && modal.type === "modal") { if ("name" in modal && "execute" in modal && modal.type === "modal") {
client.modals.set(modal.name, modal) client.modals.set(modal.name, modal)
} else { } else {
console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`) console.log(
`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`,
)
} }
} }
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isModalSubmit()) if (!interaction.isModalSubmit()) return
return
const modal = client.modals.get(interaction.customId) const modal = client.modals.get(interaction.customId)
if (!modal) { if (!modal) {
console.error(`No modal matching ${interaction.customId} was found.`) console.error(
`No modal matching ${interaction.customId} was found.`,
)
return return
} }
@@ -37,7 +41,7 @@ function loadModalEvents(client: Client) {
console.error(error) console.error(error)
await interaction.reply({ await interaction.reply({
content: "There was an error while executing this modal!", content: "There was an error while executing this modal!",
ephemeral: true ephemeral: true,
}) })
} }
}) })

View File

@@ -10,7 +10,7 @@ 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/"
async function getUUID(ign: string): Promise<string|null> { async function getUUID(ign: string): Promise<string | null> {
try { try {
const req: Profile = await fetch(mojang + ign) const req: Profile = await fetch(mojang + ign)
return req.data.id return req.data.id
@@ -19,7 +19,7 @@ async function getUUID(ign: string): Promise<string|null> {
} }
} }
async function getIGN(uuid: string): Promise<string|null> { async function getIGN(uuid: string): Promise<string | null> {
try { try {
const req: Profile2 = await fetch(mojanguuid + uuid) const req: Profile2 = await fetch(mojanguuid + uuid)
return req.data.name return req.data.name
@@ -28,12 +28,12 @@ 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, key: apikey,
uuid: uuid uuid: uuid,
} },
}) })
if (!playerReq.data.player) { if (!playerReq.data.player) {
@@ -43,14 +43,17 @@ async function getPlayer(uuid: string): Promise<PlayerData|null> {
return playerReq.data.player return playerReq.data.player
} }
async function getGuild(query: string, type?: string): Promise<GuildData|null> { async function getGuild(
query: string,
type?: string,
): 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, key: apikey,
[reqType]: query [reqType]: query,
} },
}) })
if (!guildReq.data.guild) { if (!guildReq.data.guild) {
@@ -60,14 +63,8 @@ async function getGuild(query: string, type?: string): Promise<GuildData|null> {
return guildReq.data.guild return guildReq.data.guild
} }
async function getHeadURL(ign: string): Promise<string|null> { async function getHeadURL(ign: string): Promise<string | null> {
return minotar + ign return minotar + ign
} }
export { export { getUUID, getIGN, getPlayer, getGuild, getHeadURL }
getUUID,
getIGN,
getPlayer,
getGuild,
getHeadURL
}

View File

@@ -25,8 +25,7 @@ function getExpForLevel(level: number): number {
function getLevelRespectingPrestige(level: number): number { function getLevelRespectingPrestige(level: number): number {
if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) { if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE
} } else {
else {
return level % LEVELS_PER_PRESTIGE return level % LEVELS_PER_PRESTIGE
} }
} }
@@ -39,7 +38,7 @@ const HIGHEST_PRESTIGE = 50
function bedwarsLevel(exp: number): number { function bedwarsLevel(exp: number): number {
const prestiges = Math.floor(exp / XP_PER_PRESTIGE) const prestiges = Math.floor(exp / XP_PER_PRESTIGE)
let level = prestiges * LEVELS_PER_PRESTIGE let level = prestiges * LEVELS_PER_PRESTIGE
let expWithoutPrestiges = exp - (prestiges * XP_PER_PRESTIGE) let expWithoutPrestiges = exp - prestiges * XP_PER_PRESTIGE
for (let i = 1; i <= EASY_LEVELS; ++i) { for (let i = 1; i <= EASY_LEVELS; ++i) {
const expForEasyLevel = getExpForLevel(i) const expForEasyLevel = getExpForLevel(i)

View File

@@ -3,21 +3,8 @@
*/ */
function guildLevel(exp: number): number { function guildLevel(exp: number): number {
const EXP_NEEDED = [ const EXP_NEEDED = [
100000, 100000, 150000, 250000, 500000, 750000, 1000000, 1250000, 1500000,
150000, 2000000, 2500000, 2500000, 2500000, 2500000, 2500000, 3000000,
250000,
500000,
750000,
1000000,
1250000,
1500000,
2000000,
2500000,
2500000,
2500000,
2500000,
2500000,
3000000,
] ]
let level = 0 let level = 0
@@ -28,13 +15,15 @@ function guildLevel(exp: number): number {
let need = 0 let need = 0
if (i >= EXP_NEEDED.length) { if (i >= EXP_NEEDED.length) {
need = EXP_NEEDED[EXP_NEEDED.length - 1] need = EXP_NEEDED[EXP_NEEDED.length - 1]
} else { need = EXP_NEEDED[i] } } else {
need = EXP_NEEDED[i]
}
// If the required exp to get to the next level isn't met returns // If the required exp to get to the next level isn't met returns
// the current level plus progress towards the next (unused exp/need) // the current level plus progress towards the next (unused exp/need)
// Otherwise increments the level and substracts the used exp from exp var // Otherwise increments the level and substracts the used exp from exp var
if ((exp - need) < 0) { if (exp - need < 0) {
return Math.round((level + (exp / need)) * 100) / 100 return Math.round((level + exp / need) * 100) / 100
} }
level += 1 level += 1
exp -= need exp -= need
@@ -49,8 +38,10 @@ 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) return Number(Math.round(((input - 200000) / 10) + 200000)) if (input <= 700000)
if (input > 700000) return Number(Math.round(((input - 700000) / 33) + 250000)) return Number(Math.round((input - 200000) / 10 + 200000))
if (input > 700000)
return Number(Math.round((input - 700000) / 33 + 250000))
return 0 return 0
} }

View File

@@ -9,7 +9,13 @@ const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX
const GROWTH_DIVIDES_2 = 2 / GROWTH const GROWTH_DIVIDES_2 = 2 / GROWTH
function getLevel(exp: number): number { function getLevel(exp: number): number {
return exp <= 1 ? 1 : Math.floor(1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp)) return exp <= 1
? 1
: Math.floor(
1 +
REVERSE_PQ_PREFIX +
Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp),
)
} }
function hypixelLevel(exp: number): number { function hypixelLevel(exp: number): number {
@@ -17,8 +23,8 @@ function hypixelLevel(exp: number): number {
} }
function getTotalExpToLevel(level: number): number { function getTotalExpToLevel(level: number): number {
const lv = Math.floor(level); const const lv = Math.floor(level)
x0 = getTotalExpToFullLevel(lv) const x0 = getTotalExpToFullLevel(lv)
if (level === lv) return x0 if (level === lv) return x0
return (getTotalExpToFullLevel(lv + 1) - x0) * (level % 1) + x0 return (getTotalExpToFullLevel(lv + 1) - x0) * (level % 1) + x0
} }
@@ -33,5 +39,4 @@ function getPercentageToNextLevel(exp: number): number {
return (exp - x0) / (getTotalExpToLevel(lv + 1) - x0) return (exp - x0) / (getTotalExpToLevel(lv + 1) - x0)
} }
export { hypixelLevel } export { hypixelLevel }

View File

@@ -444,6 +444,11 @@ parse-ms@^3.0.0:
resolved "https://registry.npmjs.org/parse-ms/-/parse-ms-3.0.0.tgz" resolved "https://registry.npmjs.org/parse-ms/-/parse-ms-3.0.0.tgz"
integrity sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw== integrity sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw==
prettier@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848"
integrity sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==
pretty-ms@^8.0.0: pretty-ms@^8.0.0:
version "8.0.0" version "8.0.0"
resolved "https://registry.npmjs.org/pretty-ms/-/pretty-ms-8.0.0.tgz" resolved "https://registry.npmjs.org/pretty-ms/-/pretty-ms-8.0.0.tgz"