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:build": "ts-node scripts/dev-deploy.ts",
"dev:delete": "ts-node scripts/delete-commands.ts",
"format": "prettier --write src/",
"lint": "eslint_d src",
"lint:fix": "eslint_d --fix src",
"prod:build": "ts-node scripts/deploy-commands.ts"
@@ -28,6 +29,7 @@
"devDependencies": {
"@types/ms": "^0.7.34",
"@types/node": "^20.10.5",
"prettier": "^3.1.1",
"ts-node": "^10.9.2",
"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"
export = {
@@ -13,24 +18,31 @@ export = {
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
async execute(interaction) {
const { targetId } = interaction
const message = await interaction.channel!.messages.fetch(targetId)
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
await message.reply({
embeds: [{
embeds: [
{
title: "Congratulations!",
description: `GG to ${userMention(target.id)}!`,
}]
},
],
})
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,17 @@
import { getUUID, getIGN, getPlayer, getGuild, guildLevel } from "../../utils/Hypixel"
import {
getUUID,
getIGN,
getPlayer,
getGuild,
guildLevel,
} from "../../utils/Hypixel"
import { color, devMessage } from "../../../config/options.json"
import { ChatInputCommandInteraction } from "discord.js"
import { GuildData } from "../../interfaces/Guild"
async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void> {
async function guildInfo(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const query = interaction.options.getString("query")!
@@ -13,91 +21,111 @@ async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void
if (type === "ign") {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your uuid...",
color: embedColor
}]
color: embedColor,
},
],
})
const uuid = await getUUID(query)
if (!uuid) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That player doen't exist!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your player data...",
color: embedColor
}]
color: embedColor,
},
],
})
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That player has never joined the server!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your guild data...",
color: embedColor
}]
color: embedColor,
},
],
})
guild = await getGuild(uuid, "player")
if (!guild) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That player is not in a guild!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
} else if (type === "name") {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your guild data...",
color: embedColor
}]
color: embedColor,
},
],
})
guild = await getGuild(query, "name")
if (!guild) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
} else if (type === "id") {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your guild data...",
color: embedColor
}]
color: embedColor,
},
],
})
guild = await getGuild(query, "id")
if (!guild) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -119,61 +147,104 @@ async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void
const guildCreatedMinute = guildCreated.getMinutes()
const guildCreatedSecond = guildCreated.getSeconds()
const guildCreatedTime = guildCreatedDate + "." +
guildCreatedMonth + "." +
guildCreatedYear + " " +
guildCreatedHour + ":" +
guildCreatedMinute + ":" +
const guildCreatedTime =
guildCreatedDate +
"." +
guildCreatedMonth +
"." +
guildCreatedYear +
" " +
guildCreatedHour +
":" +
guildCreatedMinute +
":" +
guildCreatedSecond
const guildOwner = guildMembers.find((m) => m.rank === "Guild Master")!.uuid
const guildOwner = guildMembers.find(m => m.rank === "Guild Master")!.uuid
const guildOwnerName = await getIGN(guildOwner)
const guildRanksUnsorted = guild!.ranks.sort((a, b) => b.priority - a.priority)
const guildRanks = guildRanksUnsorted.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n")
const guildRanksUnsorted = guild!.ranks.sort(
(a, b) => b.priority - a.priority,
)
const guildRanks = guildRanksUnsorted
.map(r => "**➺ " + r.name + "** `[" + r.tag + "]`")
.join("\n")
const allGuildMembersWeeklyXP = guildMembers.map(member => member.expHistory)
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map((member) => {
const allGuildMembersWeeklyXP = guildMembers.map(
member => member.expHistory,
)
const guildMembersWeeklyXP = allGuildMembersWeeklyXP.map(member => {
return Object.values(member).reduce((a, b) => a + b, 0)
})
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce((a, b) => a + b, 0)
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(totalGuildMembersWeeklyXPUnformatted)
const totalGuildMembersWeeklyXPUnformatted = guildMembersWeeklyXP.reduce(
(a, b) => a + b,
0,
)
const totalGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
totalGuildMembersWeeklyXPUnformatted,
)
const averageGuildMembersWeeklyXPUnformatted = Math.round(totalGuildMembersWeeklyXPUnformatted / 7)
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(averageGuildMembersWeeklyXPUnformatted)
const averageGuildMembersWeeklyXPUnformatted = Math.round(
totalGuildMembersWeeklyXPUnformatted / 7,
)
const averageGuildMembersWeeklyXP = new Intl.NumberFormat("en-US").format(
averageGuildMembersWeeklyXPUnformatted,
)
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
embeds: [
{
title: "**Info on** " + guildName,
description: "**Guild Name: **`" + guildName + "`\n" +
"**Guild Tag: **`" + guildTag + "`\n" +
"**Guild Level: **`" + guildLvl + "`\n" +
"**Guild Owner: **`" + guildOwnerName + "`",
description:
"**Guild Name: **`" +
guildName +
"`\n" +
"**Guild Tag: **`" +
guildTag +
"`\n" +
"**Guild Level: **`" +
guildLvl +
"`\n" +
"**Guild Owner: **`" +
guildOwnerName +
"`",
fields: [
{
name: "**Guild Ranks**",
value: guildRanks
value: guildRanks,
},
{
name: "**GEXP**",
value: "**➺ Total weekly GEXP:** `" + totalGuildMembersWeeklyXP + "`\n" +
"**➺ Daily avarage:** `" + averageGuildMembersWeeklyXP + "`\n" +
"**➺ Total GEXP:** `" + guildExp + "`"
value:
"**➺ Total weekly GEXP:** `" +
totalGuildMembersWeeklyXP +
"`\n" +
"**➺ Daily avarage:** `" +
averageGuildMembersWeeklyXP +
"`\n" +
"**➺ Total GEXP:** `" +
guildExp +
"`",
},
{
name: "**Guild Created**",
value: "**➺ **`" + guildCreatedTime + "`"
}
value: "**➺ **`" + guildCreatedTime + "`",
},
],
color: embedColor,
footer: {
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 { ChatInputCommandInteraction } from "discord.js"
async function guildMember(interaction: ChatInputCommandInteraction): Promise<void> {
async function guildMember(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const ign = interaction.options.getString("ign")!
const embedColor = Number(color.replace("#", "0x"))
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your uuid...",
color: embedColor
}]
color: embedColor,
},
],
})
const uuid = await getUUID(ign)
@@ -29,10 +33,12 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
}
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your player data...",
color: embedColor
}]
color: embedColor,
},
],
})
const head = await getHeadURL(ign)
@@ -48,7 +54,9 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
},
],
@@ -74,16 +82,19 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
}
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your guild data...",
color: embedColor
}]
color: embedColor,
},
],
})
const guild = await getGuild(uuid)
if (!guild) {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "This user is not in a guild",
color: embedColor,
thumbnail: {
@@ -91,9 +102,12 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
},
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
}],
},
],
})
return
}
@@ -102,17 +116,34 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
const guildTag = " [" + guild.tag + "]" ?? ""
const guildMembers = guild.members
const guildMember = guildMembers.find((member) => member.uuid === uuid)
const guildMember = guildMembers.find(member => member.uuid === uuid)
const guildRank = guildMember!.rank
const memberGexp = guildMember!.expHistory
const allDaysGexp = Object.keys(memberGexp).map((key) => {
return "**➺ " + key + ":** " + "`" + new Intl.NumberFormat("en-US").format(memberGexp[key]) + "`" + "\n"
const allDaysGexp = Object.keys(memberGexp).map(key => {
return (
"**➺ " +
key +
":** " +
"`" +
new Intl.NumberFormat("en-US").format(memberGexp[key]) +
"`" +
"\n"
)
})
const expValue = allDaysGexp.join("")
const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce((a, b) => a + b, 0)
const totalWeeklyGexp = new Intl.NumberFormat("en-US").format(totalWeeklyGexpUnformatted)
const averageWeeklyGexpUnformatted = Math.round(totalWeeklyGexpUnformatted / 7)
const averageWeeklyGexp = new Intl.NumberFormat("en-US").format(averageWeeklyGexpUnformatted)
const totalWeeklyGexpUnformatted = Object.values(memberGexp).reduce(
(a, b) => a + b,
0,
)
const totalWeeklyGexp = new Intl.NumberFormat("en-US").format(
totalWeeklyGexpUnformatted,
)
const averageWeeklyGexpUnformatted = Math.round(
totalWeeklyGexpUnformatted / 7,
)
const averageWeeklyGexp = new Intl.NumberFormat("en-US").format(
averageWeeklyGexpUnformatted,
)
const guildMemberJoinMS = guildMember!.joined
const guildMemberJoinTime = new Date(guildMemberJoinMS)
@@ -124,21 +155,36 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds()
const guildMemberJoin =
guildMemberJoinDate + "." +
guildMemberJoinMonth + "." +
guildMemberJoinYear + " " +
guildMemberJoinHours + ":" +
guildMemberJoinMinutes + ":" +
guildMemberJoinDate +
"." +
guildMemberJoinMonth +
"." +
guildMemberJoinYear +
" " +
guildMemberJoinHours +
":" +
guildMemberJoinMinutes +
":" +
guildMemberJoinSeconds
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
embeds: [
{
title: rank + displayName + guildTag,
description: "**Guild Name:** `" + guildName + "`\n" +
"**Guild Rank:** `" + guildRank + "`\n",
description:
"**Guild Name:** `" +
guildName +
"`\n" +
"**Guild Rank:** `" +
guildRank +
"`\n",
color: embedColor,
thumbnail: {
url: head!,
@@ -150,8 +196,13 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
},
{
name: "**Weekly GEXP**",
value: "**➺ Total:** `" + totalWeeklyGexp + "`\n" +
"**➺ Daily avarage:** `" + averageWeeklyGexp + "`",
value:
"**➺ Total:** `" +
totalWeeklyGexp +
"`\n" +
"**➺ Daily avarage:** `" +
averageWeeklyGexp +
"`",
},
{
name: "**Join date**",
@@ -160,9 +211,10 @@ async function guildMember(interaction: ChatInputCommandInteraction): Promise<vo
],
footer: {
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 { GuildData } from "../../interfaces/Guild"
async function guildTop(interaction: ChatInputCommandInteraction): Promise<void> {
async function guildTop(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const query = interaction.options.getString("query")!
@@ -15,101 +17,123 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
if (interaction.channel!.type === ChannelType.DM) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "You can't use this command in DMs!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
if (type === "ign") {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your uuid...",
color: embedColor
}]
color: embedColor,
},
],
})
const uuid = await getUUID(query)
if (!uuid) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That player doen't exist!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your player data...",
color: embedColor
}]
color: embedColor,
},
],
})
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That player has never joined the server!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your guild data...",
color: embedColor
}]
color: embedColor,
},
],
})
guild = await getGuild(uuid, "player")
if (!guild) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That player is not in a guild!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
} else if (type === "name") {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your guild data...",
color: embedColor
}]
color: embedColor,
},
],
})
guild = await getGuild(query, "name")
if (!guild) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
} else if (type === "id") {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "Fetching your guild data...",
color: embedColor
}]
color: embedColor,
},
],
})
guild = await getGuild(query, "id")
if (!guild) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "That guild doesn't exist!",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -121,18 +145,26 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
const cachedData = await redis.get("guildTop+" + guildId)
const gexpTodayUnformatted = guildMembers.map((member) => {
const gexpTodayUnformatted = guildMembers
.map(member => {
return member.expHistory[Object.keys(member.expHistory)[0]]
}).reduce((a, b) => a + b, 0)
const gexpToday = new Intl.NumberFormat("en-US").format(gexpTodayUnformatted)
})
.reduce((a, b) => a + b, 0)
const gexpToday = new Intl.NumberFormat("en-US").format(
gexpTodayUnformatted,
)
const averageGuildMemberGEXPUnformatted = Math.floor(gexpTodayUnformatted / guildMembers.length)
const averageGuildMemberGEXP = new Intl.NumberFormat("en-US").format(averageGuildMemberGEXPUnformatted)
const averageGuildMemberGEXPUnformatted = Math.floor(
gexpTodayUnformatted / guildMembers.length,
)
const averageGuildMemberGEXP = new Intl.NumberFormat("en-US").format(
averageGuildMemberGEXPUnformatted,
)
const allMembersDailyGEXP = guildMembers.map((member) => {
const allMembersDailyGEXP = guildMembers.map(member => {
return {
uuid: member.uuid,
gexp: member.expHistory[Object.keys(member.expHistory)[0]]
gexp: member.expHistory[Object.keys(member.expHistory)[0]],
}
})
@@ -144,8 +176,8 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
amount = 1
}
type GuildTopData = { ign: string, gexp: string }[]
type NewList = { name: string, value: string, inline: boolean }[]
type GuildTopData = { ign: string; gexp: string }[]
type NewList = { name: string; value: string; inline: boolean }[]
let cacheStatus: boolean
let guildData: GuildTopData = []
@@ -155,14 +187,21 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
if (!cachedData) {
cacheStatus = false
await interaction.editReply({
embeds: [{
description: "Fetching the top " + amount + " members of " + guildName + "...",
color: embedColor
}]
embeds: [
{
description:
"Fetching the top " +
amount +
" members of " +
guildName +
"...",
color: embedColor,
},
],
})
for (let i = 0; i < allMembersSorted.length; i++) {
const ign = await getIGN(allMembersSorted[i].uuid) as string
const ign = (await getIGN(allMembersSorted[i].uuid)) as string
const gexpUnformatted = allMembersSorted[i].gexp
const gexp = new Intl.NumberFormat("en-US").format(gexpUnformatted)
@@ -172,14 +211,26 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
})
}
await redis.set("guildTop+" + guildId, JSON.stringify(guildData), "EX", 60 * 30)
await redis.set(
"guildTop+" + guildId,
JSON.stringify(guildData),
"EX",
60 * 30,
)
} else {
cacheStatus = true
await interaction.editReply({
embeds: [{
description: "Fetching the top " + amount + " members of " + guildName + "using cache...",
embeds: [
{
description:
"Fetching the top " +
amount +
" members of " +
guildName +
"using cache...",
color: embedColor,
}]
},
],
})
guildData = JSON.parse(cachedData)
}
@@ -196,7 +247,9 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
fieldsValueRaw.push("**#" + position + " " + ign + ":** `" + gexp + "`")
}
const list = Array.from({ length: sliceSize }, (_, i) => fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize))
const list = Array.from({ length: sliceSize }, (_, i) =>
fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize),
)
const newList: NewList = []
list.forEach((item, index) => {
@@ -205,26 +258,37 @@ async function guildTop(interaction: ChatInputCommandInteraction): Promise<void>
newList[index] = {
name: "",
value: item.join("\n"),
inline: true
inline: true,
}
})
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const footerText = interaction.guild
? interaction.guild.name
: interaction.user.username
const footerIcon = interaction.guild
? interaction.guild.iconURL({ forceStatic: false })
: interaction.user.avatarURL({ forceStatic: false })
const cacheStatusText = cacheStatus ? " | [Cache]" : ""
await interaction.editReply({
embeds: [{
embeds: [
{
title: "Top members of " + guildName,
description: "**Total daily GEXP:** `" + gexpToday + "`\n" +
"**Average guild memeber GEXP:** `" + averageGuildMemberGEXP + "`",
description:
"**Total daily GEXP:** `" +
gexpToday +
"`\n" +
"**Average guild memeber GEXP:** `" +
averageGuildMemberGEXP +
"`",
color: embedColor,
fields: newList,
footer: {
text: footerText + " | " + devMessage + cacheStatusText,
icon_url: footerIcon!
}
}]
icon_url: footerIcon!,
},
},
],
})
}

View File

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

View File

@@ -18,9 +18,11 @@ export = {
const embedColor = Number(color.replace("#", "0x"))
await interaction.reply({
embeds: [{
embeds: [
{
title: "Verification",
description: "1. Log onto hypixel.\n" +
description:
"1. Log onto hypixel.\n" +
"2. Right click with the head in your hotbar.\n" +
"3. Click on the social media icon.\n" +
"4. Click on the discord icon.\n" +
@@ -29,14 +31,16 @@ export = {
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
icon_url: interaction.guild!.iconURL({
forceStatic: false,
})!,
},
image: {
url: instructionsgif,
proxy_url: instructionsgif
}
}]
proxy_url: instructionsgif,
},
},
],
})
}
},
} as Command

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,19 +1,33 @@
import verify = require("../../schemas/verifySchema")
import { color, hypixelGuildID } from "../../../config/options.json"
import { admin, gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../../config/roles.json"
import {
admin,
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../../config/roles.json"
const removeThese = [gm, manager, beast, elite, member, guildRole, guildStaff]
import { getGuild } from "../../utils/Hypixel"
import { ChatInputCommandInteraction, GuildMember } from "discord.js"
import { GuildData } from "../../interfaces/Guild"
export async function updateDiscordRoles(interaction: ChatInputCommandInteraction): Promise<void> {
export async function updateDiscordRoles(
interaction: ChatInputCommandInteraction,
): Promise<void> {
await interaction.deferReply()
const user = interaction.member as GuildMember
if (!user.roles.cache.has(admin)) {
await interaction.editReply("You do not have permission to use this command.")
await interaction.editReply(
"You do not have permission to use this command.",
)
return
}
@@ -22,13 +36,13 @@ export async function updateDiscordRoles(interaction: ChatInputCommandInteractio
const memberList = guildMembers.map(member => {
return {
id: member.user.id,
member: member
member: member,
}
})
for (const guildMember of memberList) {
const memberData = await verify.findOne({
userID: guildMember.id
userID: guildMember.id,
})
if (!memberData) {
@@ -51,41 +65,106 @@ export async function updateDiscordRoles(interaction: ChatInputCommandInteractio
const hypixelGuildMember = isGuildMember as unknown as GuildData
const guildId = hypixelGuildMember!._id
const guildRank = hypixelGuildMember!.members!.find(member => member.uuid === memberData.uuid)!.rank
const guildRank = hypixelGuildMember!.members!.find(
member => member.uuid === memberData.uuid,
)!.rank
if (guildId === hypixelGuildID) {
if (guildRank === "Guild Master") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(guildStaff, "All users updated forcefully by staff")
guildMember.member.roles.add(gm, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
guildStaff,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
gm,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Manager") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(guildStaff, "All users updated forcefully by staff")
guildMember.member.roles.add(manager, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
guildStaff,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
manager,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Moderator") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(guildStaff, "All users updated forcefully by staff")
guildMember.member.roles.add(moderator, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
guildStaff,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
moderator,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Beast") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(beast, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
beast,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Elite") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(elite, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
elite,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
if (guildRank === "Member") {
guildMember.member.roles.add(guildRole, "All users updated forcefully by staff")
guildMember.member.roles.add(member, "All users updated forcefully by staff")
guildMember.member.roles.add(defaultMember, "All users updated forcefully by staff")
guildMember.member.roles.add(
guildRole,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
member,
"All users updated forcefully by staff",
)
guildMember.member.roles.add(
defaultMember,
"All users updated forcefully by staff",
)
}
} else {
for (const role of removeThese) {
@@ -96,13 +175,17 @@ export async function updateDiscordRoles(interaction: ChatInputCommandInteractio
}
interaction.editReply({
embeds: [{
embeds: [
{
color: embedColor,
description: "Successfully updated all users.",
footer: {
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 { Command } from "../interfaces"
import ms from "ms"
@@ -17,26 +23,29 @@ const command: Command = {
option
.setName("user")
.setDescription("The user to timeout")
.setRequired(true))
.setRequired(true),
)
.addStringOption(option =>
option
.setName("time")
.setDescription("The time to timeout the user for")
.setRequired(true))
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription("The reason for the timeout"))
.setDescription("The reason for the timeout"),
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction: ChatInputCommandInteraction) {
await interaction.deferReply()
const target = interaction.options.getMember("user")! as GuildMember
const timeString = interaction.options.getString("time")!
const reason = interaction.options.getString("reason") || "No reason provided"
const reason =
interaction.options.getString("reason") || "No reason provided"
const mod = interaction.member! as GuildMember
const embedColor = Number(color.replace("#", "0x"))
const time = ms(timeString)
@@ -45,50 +54,65 @@ const command: Command = {
if (target.user.bot) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "You cannot timeout a bot.",
color: embedColor,
}]
},
],
})
return
}
if (target.id == interaction.guild!.ownerId) {
await interaction.editReply({
embeds: [{
embeds: [
{
description: "You cannot timeout the server owner.",
color: embedColor,
}]
},
],
})
return
}
if (interaction.guild!.members.me!.roles.highest.position <= target.roles.highest.position) {
if (
interaction.guild!.members.me!.roles.highest.position <=
target.roles.highest.position
) {
interaction.editReply({
embeds: [{
description: "I cannot timeout this user because their role is higher than mine.",
embeds: [
{
description:
"I cannot timeout this user because their role is higher than mine.",
color: embedColor,
}]
},
],
})
return
}
if (mod.roles.highest.position <= target.roles.highest.position) {
await interaction.editReply({
embeds: [{
description: "You cannot timeout this user because their role is higher than yours.",
embeds: [
{
description:
"You cannot timeout this user because their role is higher than yours.",
color: embedColor,
}]
},
],
})
return
}
if (target.id == interaction.user.id) {
interaction.editReply({
embeds: [{
embeds: [
{
description: "You cannot timeout yourself.",
color: embedColor,
}]
},
],
})
return
}
@@ -97,47 +121,69 @@ const command: Command = {
if (time === 0) {
await target.timeout(null, reason)
await interaction.editReply({
embeds: [{
description: "Removed timeout of " + userMention(target.id) + " for " + reason,
embeds: [
{
description:
"Removed timeout of " +
userMention(target.id) +
" for " +
reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined
icon_url: target.avatarURL() || undefined,
},
timestamp: new Date().toISOString()
}]
timestamp: new Date().toISOString(),
},
],
})
return
}
await target.timeout(time, reason)
await interaction.editReply({
embeds: [{
description: "Updated timeout of " + userMention(target.id) + " to " + prettyTime + " for " + reason,
embeds: [
{
description:
"Updated timeout of " +
userMention(target.id) +
" to " +
prettyTime +
" for " +
reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined
icon_url: target.avatarURL() || undefined,
},
timestamp: new Date().toISOString()
}]
timestamp: new Date().toISOString(),
},
],
})
return
}
await target.timeout(time, reason)
await interaction.editReply({
embeds: [{
description: "Timed out " + userMention(target.id) + " for " + prettyTime + " for " + reason,
embeds: [
{
description:
"Timed out " +
userMention(target.id) +
" for " +
prettyTime +
" for " +
reason,
color: embedColor,
footer: {
text: "ID: " + target.id,
icon_url: target.avatarURL() || undefined
icon_url: target.avatarURL() || undefined,
},
timestamp: new Date().toISOString()
}]
timestamp: new Date().toISOString(),
},
],
})
}
},
}
export = command

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,23 +12,29 @@ export = {
}
if (focusedOption.value === "") {
await interaction.respond([{
await interaction.respond([
{
name: "Please start typing a username to unban",
value: "none"
}])
value: "none",
},
])
return
}
const bannedUsers = await interaction.guild!.bans.fetch()
const filteredUsers = bannedUsers.filter((user) =>
user.user.username.toLowerCase().includes(focusedOption.value.toLowerCase())
const filteredUsers = bannedUsers.filter(user =>
user.user.username
.toLowerCase()
.includes(focusedOption.value.toLowerCase()),
)
const results = filteredUsers.map((user) => ({
const results = filteredUsers.map(user => ({
name: user.user.username,
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

View File

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

View File

@@ -12,7 +12,6 @@ export = {
type: "button",
async execute(interaction) {
await interaction.deferReply()
const user = interaction.user
@@ -25,7 +24,8 @@ export = {
const applicantIGN = embed.fields[0].value.replaceAll("`", "")
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({
components: [
@@ -44,16 +44,19 @@ export = {
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
.setDisabled(true)
)
]
.setDisabled(true),
),
],
})
await applicant.send({
embeds: [{
description: "Your application for the Illegitimate guild has been accepted.",
color: embedColor
}]
embeds: [
{
description:
"Your application for the Illegitimate guild has been accepted.",
color: embedColor,
},
],
})
const applicantEntry = await guildapp.findOne({ userID: applicantId })
@@ -65,7 +68,7 @@ export = {
userID: applicantId,
uuid: applicantUUID,
IGN: applicantIGN,
timestamp: time
timestamp: time,
})
await waitingListAdd.save()
@@ -73,20 +76,22 @@ export = {
await applicant.roles.add(waitingListRole)
await guildapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({
embeds: [{
embeds: [
{
title: applicantUsername + " - Guild Application",
description: "Application has been accepted by <@" + user.id + ">.",
description:
"Application has been accepted by <@" + user.id + ">.",
color: embedColor,
thumbnail: {
url: applicant.avatarURL() || guild.iconURL()!
url: applicant.avatarURL() || guild.iconURL()!,
},
footer: {
icon_url: guild.iconURL()!,
text: "ID: " + applicant.id
}
}]
text: "ID: " + applicant.id,
},
},
],
})
}
},
} 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"
export = {
@@ -7,7 +12,6 @@ export = {
type: "button",
async execute(interaction) {
const modal = new ModalBuilder()
.setTitle("Deny Reason")
.setCustomId("denyreasonbox")
@@ -17,10 +21,12 @@ export = {
.setLabel("Deny Reason")
.setCustomId("denyreason")
.setStyle(TextInputStyle.Paragraph)
.setPlaceholder("Enter a reason for denying the application")
.setRequired(false)
.setPlaceholder(
"Enter a reason for denying the application",
)
.setRequired(false),
),
)
await interaction.showModal(modal)
}
},
} 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 { largeM, smallM, ignM } from "../../../config/limitmessages.json"
import { applicationsChannel } from "../../../config/options.json"
@@ -15,7 +22,6 @@ export = {
type: "button",
async execute(interaction) {
const user = interaction.member as GuildMember
const guild = interaction.guild!
const embedColor = Number(color.replace("#", "0x"))
@@ -31,18 +37,21 @@ export = {
}
if (interaction.customId === "guildapply") {
await interaction.deferReply({ ephemeral: true })
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
}
const application = await guildapp.findOne({ userID: user.user.id })
if (application) {
await interaction.editReply("You already have an application in progress.")
await interaction.editReply(
"You already have an application in progress.",
)
return
}
@@ -53,20 +62,25 @@ export = {
.setDescription("You have cancelled your application.")
.setColor(embedColor)
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)
try {
await user.send({
embeds: [{
embeds: [
{
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 proceed with your application, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor,
}]
},
],
})
} catch (error) {
await interaction.editReply("Please enable your DMs.")
@@ -78,7 +92,7 @@ export = {
const input = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60
time: 1000 * 60,
})
if (input.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -95,14 +109,20 @@ export = {
// first question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
@@ -123,21 +143,26 @@ export = {
}
if (answer1.first()!.content.length > 16) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 16.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
const uuid = await getUUID(answer1.first()!.content)
if (!uuid) {
await user.send({
embeds: [{
description: "That is not a valid Minecraft username.\n" +
embeds: [
{
description:
"That is not a valid Minecraft username.\n" +
"Application cancelled.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -145,19 +170,24 @@ export = {
// second question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer2.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -173,10 +203,12 @@ export = {
}
if (answer2.first()!.content.length > 8) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 8.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -184,19 +216,25 @@ export = {
// third question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer3.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -212,30 +250,38 @@ export = {
}
if (answer3.first()!.content.length > 128) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 128.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer3_1 = answer3.first()!.content
// fourth question
await user.send({
embeds: [{
embeds: [
{
title: "**Question 4**",
description: qu(4) + "\n\nPlease type your answer below or type `cancel` to cancel your application." +
" `(We expect a longer answer.)`\n`" + largeM + "`",
description:
qu(4) +
"\n\nPlease type your answer below or type `cancel` to cancel your application." +
" `(We expect a longer answer.)`\n`" +
largeM +
"`",
color: embedColor,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer4.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -251,29 +297,37 @@ export = {
}
if (answer4.first()!.content.length > 256) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 256.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer4_1 = answer4.first()!.content
// fifth question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer5.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -289,29 +343,37 @@ export = {
}
if (answer5.first()!.content.length > 128) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 128.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer5_1 = answer5.first()!.content
// sixth question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer6.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -327,29 +389,37 @@ export = {
}
if (answer6.first()!.content.length > 256) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 256.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer6_1 = answer6.first()!.content
// seventh question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer7.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -365,29 +435,36 @@ export = {
}
if (answer7.first()!.content.length > 128) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 128.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer7_1 = answer7!.first()!.content
// eighth question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer8.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -403,25 +480,30 @@ export = {
}
if (answer8.first()!.content.length > 64) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 64.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer8_1 = answer8.first()!.content
await user.send({
embeds: [{
description: "If you want to submit your application, type `yes` if not, type `no`",
color: embedColor
}]
embeds: [
{
description:
"If you want to submit your application, type `yes` if not, type `no`",
color: embedColor,
},
],
})
const final = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 5
time: 1000 * 60 * 5,
})
if (final.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -437,10 +519,12 @@ export = {
}
await user.send({
embeds: [{
embeds: [
{
description: "Your application has been submitted!",
color: embedColor
}]
color: embedColor,
},
],
})
const newGuildApp = new guildapp({
@@ -451,53 +535,61 @@ export = {
await newGuildApp.save()
const channel = guild.channels.cache.get(applicationsChannel) as GuildTextBasedChannel
const channel = guild.channels.cache.get(
applicationsChannel,
) as GuildTextBasedChannel
await channel.send({
embeds: [{
title: user.user.username + "#" + user.user.discriminator + " - Guild Application",
embeds: [
{
title:
user.user.username +
"#" +
user.user.discriminator +
" - Guild Application",
color: embedColor,
thumbnail: {
url: user.avatarURL() || guild.iconURL()!
url: user.avatarURL() || guild.iconURL()!,
},
fields: [
{
name: rq(1),
value: "```" + answer1_1 + "```"
value: "```" + answer1_1 + "```",
},
{
name: rq(2),
value: "```" + answer2_1 + "```"
value: "```" + answer2_1 + "```",
},
{
name: rq(3),
value: "```" + answer3_1 + "```"
value: "```" + answer3_1 + "```",
},
{
name: rq(4),
value: "```" + answer4_1 + "```"
value: "```" + answer4_1 + "```",
},
{
name: rq(5),
value: "```" + answer5_1 + "```"
value: "```" + answer5_1 + "```",
},
{
name: rq(6),
value: "```" + answer6_1 + "```"
value: "```" + answer6_1 + "```",
},
{
name: rq(7),
value: "```" + answer7_1 + "```"
value: "```" + answer7_1 + "```",
},
{
name: rq(8),
value: "```" + answer8_1 + "```"
}
value: "```" + answer8_1 + "```",
},
],
footer: {
icon_url: guild.iconURL()!,
text: "ID: " + user.user.id
}
}],
text: "ID: " + user.user.id,
},
},
],
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
@@ -511,11 +603,10 @@ export = {
new ButtonBuilder()
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
)
]
.setStyle(ButtonStyle.Secondary),
),
],
})
}
}
},
} as Button

View File

@@ -1,10 +1,33 @@
import { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder, GuildMember, GuildTextBasedChannel } from "discord.js"
import { gm, manager, moderator, beast, member, guildStaff, guildRole } from "../../../config/roles.json"
import {
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 { inactivity } from "../../../config/questions.json"
import { color, inactivityLogChannel } from "../../../config/options.json"
import { Button } from "../../interfaces"
const guildRoles = [gm, manager, moderator, beast, member, guildStaff, guildRole]
const guildRoles = [
gm,
manager,
moderator,
beast,
member,
guildStaff,
guildRole,
]
module.exports = {
name: "guildinactivitylog",
@@ -18,10 +41,10 @@ module.exports = {
const userRoles = user.roles.cache
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"
if (!userRoles.some((role) => guildRoles.includes(role.id))) {
if (!userRoles.some(role => guildRoles.includes(role.id))) {
return await interaction.reply({
content: "Only guild members can use this button.",
ephemeral: true
ephemeral: true,
})
}
@@ -40,30 +63,42 @@ module.exports = {
.setDescription("You have cancelled your application.")
.setColor(embedColor)
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)
try {
await user.send({
embeds: [{
embeds: [
{
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 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.",
color: embedColor
}]
color: embedColor,
},
],
})
} 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({
filter: (m) => m.author.id === user.user.id,
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60
time: 1000 * 60,
})
if (input.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] })
@@ -79,20 +114,26 @@ module.exports = {
}
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: (m) => m.author.id === user.user.id,
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 5
time: 1000 * 60 * 5,
})
if (answer1.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] })
@@ -100,10 +141,12 @@ module.exports = {
}
if (answer1.first()!.content.length > 16) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 16.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -111,10 +154,14 @@ module.exports = {
await fetch(mojangAPI + answer1.first()!.content)
} catch (error) {
await user.send({
embeds: [{
description: "That is not a valid Minecraft username.\n" + "Application cancelled.",
color: embedColor
}]
embeds: [
{
description:
"That is not a valid Minecraft username.\n" +
"Application cancelled.",
color: embedColor,
},
],
})
return
}
@@ -129,19 +176,25 @@ module.exports = {
const answer1_1 = answer1.first()!.content
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: (m) => m.author.id === user.user.id,
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 5
time: 1000 * 60 * 5,
})
if (answer2.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] })
@@ -149,10 +202,12 @@ module.exports = {
}
if (answer2.first()!.content.length > 128) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 128.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -167,19 +222,25 @@ module.exports = {
const answer2_1 = answer1.first()!.content
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: (m) => m.author.id === user.user.id,
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer3.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] })
@@ -187,10 +248,12 @@ module.exports = {
}
if (answer3.first()!.content.length > 256) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 256",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -205,15 +268,18 @@ module.exports = {
const answer3_1 = answer1.first()!.content
await user.send({
embeds: [{
description: "If you want to submit your application, type `yes` if not, type `no`",
color: embedColor
}]
embeds: [
{
description:
"If you want to submit your application, type `yes` if not, type `no`",
color: embedColor,
},
],
})
const final = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 5
time: 1000 * 60 * 5,
})
if (final.first()!.attachments.size > 0) {
await user.send({ embeds: [attachments] })
@@ -229,40 +295,50 @@ module.exports = {
}
await user.send({
embeds: [{
embeds: [
{
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({
embeds: [{
title: user.user.username + "#" + user.user.discriminator + " - Inactivity Application",
embeds: [
{
title:
user.user.username +
"#" +
user.user.discriminator +
" - Inactivity Application",
color: embedColor,
thumbnail: {
url: user.displayAvatarURL({ forceStatic: false })
url: user.displayAvatarURL({ forceStatic: false }),
},
fields: [
{
name: rq(1),
value: "`" + answer1_1 + "`"
value: "`" + answer1_1 + "`",
},
{
name: rq(2),
value: "`" + answer2_1 + "`"
value: "`" + answer2_1 + "`",
},
{
name: rq(3),
value: "`" + answer3_1 + "`"
}
value: "`" + answer3_1 + "`",
},
],
footer: {
icon_url: user.displayAvatarURL({ forceStatic: false }),
text: "ID: " + user.user.id
}
}],
text: "ID: " + user.user.id,
},
},
],
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
@@ -273,8 +349,8 @@ module.exports = {
.setCustomId("inactiveapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger),
)
]
),
],
})
}
},
} as Button

View File

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

View File

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

View File

@@ -20,13 +20,17 @@ export = {
const applicantId = embed.footer!.text.split(" ")[1]
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({
embeds: [{
description: "Your application for the Illegitimate staff team has been accepted.",
color: embedColor
}]
embeds: [
{
description:
"Your application for the Illegitimate staff team has been accepted.",
color: embedColor,
},
],
})
await message.edit({
@@ -41,26 +45,28 @@ export = {
.setCustomId("staffapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger)
.setDisabled(true)
)
]
.setDisabled(true),
),
],
})
await staffapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({
embeds: [{
embeds: [
{
title: applicantUsername + " - Staff Application.",
description: "Application accepted by <@" + user.id + ">.",
color: embedColor,
thumbnail: {
url: applicant.avatarURL()!
url: applicant.avatarURL()!,
},
footer: {
icon_url: guild.iconURL()!,
text: "ID: " + applicantId
}
}]
text: "ID: " + applicantId,
},
},
],
})
}
},
} 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"
export = {
@@ -7,7 +12,6 @@ export = {
type: "button",
async execute(interaction) {
const modal = new ModalBuilder()
.setTitle("Deny Reason")
.setCustomId("staffdenyreasonbox")
@@ -17,10 +21,12 @@ export = {
.setLabel("Deny Reason")
.setCustomId("staffdenyreason")
.setStyle(TextInputStyle.Paragraph)
.setPlaceholder("Enter a reason for denying the application")
.setRequired(false)
.setPlaceholder(
"Enter a reason for denying the application",
)
.setRequired(false),
),
)
await interaction.showModal(modal)
}
},
} 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 { largeM, ignM } from "../../../config/limitmessages.json"
import questions from "../../../config/questions.json"
@@ -16,7 +23,6 @@ export = {
type: "button",
async execute(interaction) {
const user = interaction.member as GuildMember
const guild = interaction.guild!
const embedColor = Number(color.replace("#", "0x"))
@@ -34,12 +40,13 @@ export = {
}
if (interaction.customId === "staffapply") {
await interaction.deferReply({ ephemeral: true })
if (user.user.id !== config.prod.dev) {
if (status === "0") {
await interaction.editReply("Staff applications are currently closed.")
await interaction.editReply(
"Staff applications are currently closed.",
)
return
}
}
@@ -57,7 +64,9 @@ export = {
const application = await staffapp.findOne({ userID: user.user.id })
if (application) {
await interaction.editReply("You already have an application in progress.")
await interaction.editReply(
"You already have an application in progress.",
)
return
}
@@ -68,20 +77,25 @@ export = {
.setDescription("You have cancelled your application.")
.setColor(embedColor)
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)
try {
await user.send({
embeds: [{
embeds: [
{
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 proceed with your application, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor,
}]
},
],
})
} catch (error) {
await interaction.editReply("Please enable your DMs.")
@@ -93,7 +107,7 @@ export = {
const input = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60
time: 1000 * 60,
})
if (input.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -110,14 +124,20 @@ export = {
// first question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
@@ -138,21 +158,26 @@ export = {
}
if (answer1.first()!.content.length > 16) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 16.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
const uuid = await getUUID(answer1.first()!.content)
if (!uuid) {
await user.send({
embeds: [{
description: "That is not a valid Minecraft username.\n" +
embeds: [
{
description:
"That is not a valid Minecraft username.\n" +
"Application cancelled.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -160,19 +185,24 @@ export = {
// second question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer2.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -188,10 +218,12 @@ export = {
}
if (answer2.first()!.content.length > 64) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 64.",
color: embedColor
}]
color: embedColor,
},
],
})
return
}
@@ -199,19 +231,25 @@ export = {
// third question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer3.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -227,29 +265,37 @@ export = {
}
if (answer3.first()!.content.length > 256) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 256.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer3_1 = answer3.first()!.content
// fourth question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer4.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -265,29 +311,37 @@ export = {
}
if (answer4.first()!.content.length > 256) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 256.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer4_1 = answer4.first()!.content
// fifth question
await user.send({
embeds: [{
embeds: [
{
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer5.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -303,30 +357,38 @@ export = {
}
if (answer5.first()!.content.length > 256) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 256.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer5_1 = answer5.first()!.content
// sixth question
await user.send({
embeds: [{
embeds: [
{
title: "**Question 6**",
description: sq(6) + "\n\nPlease type your answer below or type `cancel` to cancel your application." +
"`(We expect a longer answer here)`\n`" + largeM + "`",
description:
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,
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({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 15
time: 1000 * 60 * 15,
})
if (answer6.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -342,25 +404,30 @@ export = {
}
if (answer6.first()!.content.length > 256) {
await user.send({
embeds: [{
embeds: [
{
description: "Max character limit is 256.",
color: embedColor
}]
color: embedColor,
},
],
})
}
const answer6_1 = answer6.first()!.content
await user.send({
embeds: [{
description: "If you want to submit your application, type `yes` if not, type `no`",
color: embedColor
}]
embeds: [
{
description:
"If you want to submit your application, type `yes` if not, type `no`",
color: embedColor,
},
],
})
const final = await user.dmChannel!.awaitMessages({
filter: m => m.author.id === user.user.id,
max: 1,
time: 1000 * 60 * 5
time: 1000 * 60 * 5,
})
if (final.size === 0) {
await user.send({ embeds: [tooLong] })
@@ -376,10 +443,12 @@ export = {
}
await user.send({
embeds: [{
embeds: [
{
description: "Your application has been submitted!",
color: embedColor
}]
color: embedColor,
},
],
})
const newStaffApp = new staffapp({
@@ -391,47 +460,54 @@ export = {
await newStaffApp.save()
await user.deleteDM()
const channel = guild.channels.cache.get(staffApplicationsChannel) as GuildTextBasedChannel
const channel = guild.channels.cache.get(
staffApplicationsChannel,
) as GuildTextBasedChannel
await channel.send({
embeds: [{
title: user.user.username + "#" + user.user.discriminator + " - Staff Application",
embeds: [
{
title:
user.user.username +
"#" +
user.user.discriminator +
" - Staff Application",
color: embedColor,
thumbnail: {
url: user.avatarURL() || guild.iconURL()!
url: user.avatarURL() || guild.iconURL()!,
},
fields: [
{
name: rq(1),
value: "```" + answer1_1 + "```"
value: "```" + answer1_1 + "```",
},
{
name: rq(2),
value: "```" + answer2_1 + "```"
value: "```" + answer2_1 + "```",
},
{
name: rq(3),
value: "```" + answer3_1 + "```"
value: "```" + answer3_1 + "```",
},
{
name: rq(4),
value: "```" + answer4_1 + "```"
value: "```" + answer4_1 + "```",
},
{
name: rq(5),
value: "```" + answer5_1 + "```"
value: "```" + answer5_1 + "```",
},
{
name: rq(6),
value: "```" + answer6_1 + "```"
}
value: "```" + answer6_1 + "```",
},
],
footer: {
icon_url: guild.iconURL()!,
text: "ID: " + user.user.id
}
}],
text: "ID: " + user.user.id,
},
},
],
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
@@ -441,10 +517,10 @@ export = {
new ButtonBuilder()
.setCustomId("staffapplicationdeny")
.setLabel("Deny")
.setStyle(ButtonStyle.Danger)
)
]
.setStyle(ButtonStyle.Danger),
),
],
})
}
}
},
} 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"
export = {
@@ -7,7 +12,6 @@ export = {
type: "button",
async execute(interaction) {
const modal = new ModalBuilder()
.setTitle("Verification")
.setCustomId("verifybox")
@@ -20,9 +24,9 @@ export = {
.setPlaceholder("Enter your ign.")
.setRequired(true)
.setMinLength(3)
.setMaxLength(16)
)
.setMaxLength(16),
),
)
await interaction.showModal(modal)
}
},
} as Button

View File

@@ -9,7 +9,6 @@ export = {
type: "button",
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const user = interaction.user
@@ -18,7 +17,6 @@ export = {
const accepted = await waitinglist.find()
for (let i = 0; i < accepted.length; i++) {
const uuid = accepted[i].uuid
const guild = await getGuild(uuid)
@@ -26,23 +24,22 @@ export = {
await waitinglist.findOneAndDelete({ uuid: uuid })
continue
}
}
const fields = []
for (let i = 0; i < accepted.length; i++) {
const timestamp = Math.floor(accepted[i].timestamp / 1000)
fields.push({
name: `${i + 1}. ${accepted[i].IGN}`,
value: `TS: <t:${timestamp}:R>`
value: `TS: <t:${timestamp}:R>`,
})
}
await message.edit({
embeds: [{
embeds: [
{
title: embed.title!,
description: embed.description!,
color: embed.color!,
@@ -53,9 +50,10 @@ export = {
thumbnail: embed.thumbnail!,
fields: fields,
timestamp: new Date().toISOString(),
}],
},
],
})
await interaction.editReply("Updated the waiting list")
}
},
} 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 guildapp from "../../schemas/guildAppSchema"
import { Modal } from "../../interfaces"
@@ -16,7 +23,9 @@ export = {
const embed = message.embeds[0]
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"))
await message.edit({
@@ -36,9 +45,9 @@ export = {
.setCustomId("checkstats")
.setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary)
.setDisabled(true)
)
]
.setDisabled(true),
),
],
})
let applicant: GuildMember | null
@@ -49,23 +58,35 @@ export = {
}
const dmMessage = new EmbedBuilder()
.setDescription("Your application for the Illegitimate guild has been denied\n" +
"**Reason:** `" + reason + "`")
.setDescription(
"Your application for the Illegitimate guild has been denied\n" +
"**Reason:** `" +
reason +
"`",
)
.setColor(embedColor)
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)
const responseEmbed = new EmbedBuilder()
.setTitle("Application Denied")
.setDescription("The application has been denied by <@" + interaction.user.id + ">.\n" +
"**Reason:** `" + reason + "`")
.setDescription(
"The application has been denied by <@" +
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`",
)
.setColor(embedColor)
.setThumbnail(guild.iconURL())
.setFooter({
iconURL: guild.iconURL()!,
text: "ID: " + applicantId
text: "ID: " + applicantId,
})
if (applicant !== null) {
@@ -82,7 +103,7 @@ export = {
await guildapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({
embeds: responseEmbeds
embeds: responseEmbeds,
})
}
},
} 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 staffapp from "../../schemas/staffAppSchema"
import { Modal } from "../../interfaces"
@@ -12,7 +17,9 @@ export = {
await interaction.deferReply()
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 message = interaction.message!
@@ -33,13 +40,17 @@ export = {
.setLabel("Deny")
.setStyle(ButtonStyle.Danger)
.setDisabled(true),
)
]
),
],
})
const dmMessage = new EmbedBuilder()
.setDescription("Your application for the Illegitimate guild staff has been denied\n" +
"**Reason:** `" + reason + "`")
.setDescription(
"Your application for the Illegitimate guild staff has been denied\n" +
"**Reason:** `" +
reason +
"`",
)
.setColor(embedColor)
await applicant.send({ embeds: [dmMessage] })
@@ -47,19 +58,26 @@ export = {
await staffapp.findOneAndDelete({ userID: applicantId })
await interaction.editReply({
embeds: [{
embeds: [
{
title: "Application Denied",
description: "The application has been denied by <@" + interaction.user.id + ">.\n" +
"**Reason:** `" + reason + "`",
description:
"The application has been denied by <@" +
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`",
color: embedColor,
thumbnail: {
url: applicant.avatarURL() || guild!.iconURL()!
url: applicant.avatarURL() || guild!.iconURL()!,
},
footer: {
icon_url: guild!.iconURL()!,
text: "ID: " + applicant.id
}
}],
text: "ID: " + applicant.id,
},
},
],
})
}
},
} 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 verify from "../../schemas/verifySchema"
import mongoose from "mongoose"
import { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } from "../../../config/roles.json"
import {
gm,
manager,
moderator,
beast,
elite,
member,
guildRole,
guildStaff,
defaultMember,
} from "../../../config/roles.json"
import { Modal } from "../../interfaces"
import { GuildMember } from "discord.js"
@@ -20,17 +30,23 @@ export = {
const verifyData = await verify.findOne({ userID: user.user.id })
if (verifyData) {
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
interaction.editReply(
"You are already verified.\n" +
"Try running /update to update your roles.",
)
return
}
const uuid = await getUUID(ign)
if (!uuid) {
interaction.editReply({
embeds: [{
description: "<a:questionmark_pink:1130206038008803488> That player does not exist.",
color: embedColor
}]
embeds: [
{
description:
"<a:questionmark_pink:1130206038008803488> That player does not exist.",
color: embedColor,
},
],
})
return
}
@@ -39,10 +55,13 @@ export = {
const player = await getPlayer(uuid)
if (!player) {
interaction.editReply({
embeds: [{
description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor
}]
embeds: [
{
description:
"<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor,
},
],
})
return
}
@@ -59,11 +78,16 @@ export = {
interaction.editReply({
embeds: [
{
description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + player.displayname + "`.\n\n" +
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
color: embedColor
}
]
description:
"<a:cross_a:1087808606897983539> There is no Discord account linked to `" +
player.displayname +
"`.\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
})
return
}
@@ -72,11 +96,18 @@ export = {
interaction.editReply({
embeds: [
{
description: "<a:cross_a:1087808606897983539> The Discord account linked to `" + player.displayname + "` is currently `" + linkedDiscord + "`\n\n" +
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
color: embedColor
}
]
description:
"<a:cross_a:1087808606897983539> The Discord account linked to `" +
player.displayname +
"` is currently `" +
linkedDiscord +
"`\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
})
return
}
@@ -91,7 +122,9 @@ export = {
if (guildID === hypixelGuildID) {
const GuildMembers = guild!.members
const guildRank = GuildMembers.find((member) => member.uuid === player.uuid)!.rank
const guildRank = GuildMembers.find(
member => member.uuid === player.uuid,
)!.rank
if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
await user.roles.add(gm, "Verification")
@@ -131,7 +164,7 @@ export = {
const newVerify = new verify({
_id: new mongoose.Types.ObjectId(),
userID: user.id,
uuid: uuid
uuid: uuid,
})
await newVerify.save()
@@ -140,19 +173,23 @@ export = {
embeds: [
{
title: interaction.guild!.name,
description: "You have successfully verified `" + username + "` with the account `" + player.displayname + "`.",
description:
"You have successfully verified `" +
username +
"` with the account `" +
player.displayname +
"`.",
color: embedColor,
thumbnail: {
url: head!
url: head!,
},
footer: {
icon_url: interaction.guild!.iconURL()!,
text: interaction.guild!.name + " | " + devMessage
}
}
]
text: interaction.guild!.name + " | " + devMessage,
},
},
],
})
}
}
},
} as Modal

View File

@@ -9,34 +9,41 @@ const event: Event = {
event: "guildMemberAdd",
execute(member: GuildMember) {
const channel = member.guild.channels.cache.get(botLogChannel)
const embedColor = Number(color.replace("#", "0x"))
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
}
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
}
channel.send({
embeds: [{
embeds: [
{
title: "New Member",
description: userMention(member.id) + " has joined the server.\n" +
"Account created: " + member.user.createdAt.toLocaleString(),
description:
userMention(member.id) +
" has joined the server.\n" +
"Account created: " +
member.user.createdAt.toLocaleString(),
color: embedColor,
footer: {
text: "ID: " + member.id
text: "ID: " + member.id,
},
timestamp: new Date().toISOString()
}]
timestamp: new Date().toISOString(),
},
],
})
}
},
}
export = event

View File

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

View File

@@ -8,10 +8,13 @@ const event: Event = {
event: "messageCreate",
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")
}
}
},
}
export = event

View File

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

View File

@@ -16,7 +16,9 @@ const event: Event = {
const embedColor = Number(color.replace("#", "0x"))
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
}
@@ -26,12 +28,14 @@ const event: Event = {
}
channel.send({
embeds: [{
embeds: [
{
description: "Bot is online!",
color: embedColor
}]
color: embedColor,
},
],
})
}
},
}
export = event

View File

@@ -9,7 +9,6 @@ const event: Event = {
event: "ready",
execute(client: Client) {
// Playing 0
// Streaming 1
// Listening 2
@@ -19,20 +18,16 @@ const event: Event = {
const user = client.user!
user.setActivity(
{ name: statuses[0].name, type: statuses[0].type }
)
user.setActivity({ name: statuses[0].name, type: statuses[0].type })
let i = 1
setInterval(() =>
user.setActivity(
statuses[i++ % statuses.length]
),
1000 * 60 * 10
setInterval(
() => user.setActivity(statuses[i++ % statuses.length]),
1000 * 60 * 10,
)
user.setStatus("dnd")
}
},
}
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 { Event } from "../../../interfaces"
@@ -9,20 +14,23 @@ const event: Event = {
event: "voiceStateUpdate",
execute(oldState: VoiceState, newState: VoiceState) {
if (process.env.NODE_ENV === 'dev') return
if (process.env.NODE_ENV === "dev") return
const guild = oldState.guild
const channel = guild.channels.cache.get(botLogChannel)
const embedColor = Number(color.replace("#", "0x"))
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
}
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
}
@@ -30,60 +38,62 @@ const event: Event = {
const newChannel = newState.channel
if (oldChannel === null && newChannel !== null) {
channel.send({
embeds: [{
embeds: [
{
title: "Voice Channel Join",
description: userMention(newState.member!.id) +
description:
userMention(newState.member!.id) +
" joined " +
channelMention(newChannel.id),
color: embedColor,
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) {
channel.send({
embeds: [{
embeds: [
{
title: "Voice Channel Leave",
description: userMention(oldState.member!.id) +
description:
userMention(oldState.member!.id) +
" left " +
channelMention(oldChannel.id),
color: embedColor,
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) {
if (oldChannel.id === newChannel.id) return
channel.send({
embeds: [{
embeds: [
{
title: "Voice Channel Switch",
description: userMention(oldState.member!.id) +
description:
userMention(oldState.member!.id) +
" switched from " +
channelMention(oldChannel.id) +
" to " +
channelMention(newChannel.id),
color: embedColor,
footer: {
text: "ID: " + oldState.member!.id
text: "ID: " + oldState.member!.id,
},
timestamp: new Date().toISOString()
}]
timestamp: new Date().toISOString(),
},
],
})
}
}
},
}
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 config from "./utils/Config"
import { redis } from "./utils/Redis"
@@ -13,14 +13,14 @@ const client = new Client({
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildVoiceStates
GatewayIntentBits.GuildVoiceStates,
],
partials: [
Partials.GuildMember,
Partials.User,
Partials.Message,
Partials.Channel
]
Partials.Channel,
],
})
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"
export default interface Command {
@@ -7,7 +7,13 @@ export default interface Command {
type: "slash"
dev?: boolean
public: boolean
data: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup" | "addIntegerOption">
data: Omit<
SlashCommandBuilder,
"addSubcommand" | "addSubcommandGroup" | "addIntegerOption"
>
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 {
name: string

View File

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

View File

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

View File

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

View File

@@ -1,15 +1,15 @@
export type Profile = {
data: {
id: string
name: string;
name: string
}
}
export type Profile2 = {
data: {
id: string,
name: string,
properties: { name: string, value: string }[],
id: string
name: string
properties: { name: string; value: string }[]
profileActions: []
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,4 +3,10 @@ export { bedwarsLevel } from "./functions/bedwars"
export { hypixelLevel } from "./functions/hypixel"
export { formatUuid } from "./functions/uuid"
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")
function loadAutocompleteEvents(client: Client) {
const autocompletePath = path.join(__dirname, "..", "..", "events", "autocomplete")
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(".js"))
const autocompletePath = path.join(
__dirname,
"..",
"..",
"events",
"autocomplete",
)
const autocompleteFiles = fs
.readdirSync(autocompletePath)
.filter(file => file.endsWith(".js"))
for (const file of autocompleteFiles) {
const filePath = path.join(autocompletePath, file)
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)
} 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)
if (!autocomplete) {
console.error(`No autocomplete matching ${interaction.commandName} was found.`)
console.error(
`No autocomplete matching ${interaction.commandName} was found.`,
)
return
}

View File

@@ -6,28 +6,32 @@ import fs = require("fs")
function loadButtonEvents(client: Client) {
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) {
const filePath = path.join(btnPath, file)
const btn: Button = require(filePath)
if ("name" in btn && "execute" in btn && btn.type === "button") {
client.buttons.set(btn.name, btn)
} 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 => {
if (!interaction.isButton())
return
if (!interaction.isButton()) return
const button = client.buttons.get(interaction.customId)
if (!button) {
console.error(`No event matching ${interaction.customId} was found.`)
console.error(
`No event matching ${interaction.customId} was found.`,
)
return
}
@@ -37,7 +41,7 @@ function loadButtonEvents(client: Client) {
console.error(error)
await interaction.reply({
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) {
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) {
const filePath = path.join(cmdPath, file)
const cmd: Command = require(filePath)
if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
client.commands.set(cmd.data.name, cmd)
} 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
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand())
return
if (!interaction.isChatInputCommand()) return
const command = client.commands.get(interaction.commandName)
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`)
console.error(
`No command matching ${interaction.commandName} was found.`,
)
return
}
@@ -38,7 +42,7 @@ function loadSlashCommandsEvents(client: Client) {
console.error(error)
await interaction.reply({
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")
function loadContextMenuEvents(client: Client) {
const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu")
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(".js"))
const contextMenuPath = path.join(
__dirname,
"..",
"..",
"commands-contextmenu",
)
const contextMenuFiles = fs
.readdirSync(contextMenuPath)
.filter(file => file.endsWith(".js"))
for (const file of contextMenuFiles) {
const filePath = path.join(contextMenuPath, file)
const cmd: ContextMenu = require(filePath)
if ("data" in cmd && "execute" in cmd && cmd.type === "contextmenu") {
client.contextmenus.set(cmd.data.name, cmd)
} 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
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isContextMenuCommand())
return
if (!interaction.isContextMenuCommand()) return
const command = client.contextmenus.get(interaction.commandName)
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`)
console.error(
`No command matching ${interaction.commandName} was found.`,
)
return
}
@@ -38,7 +47,7 @@ function loadContextMenuEvents(client: Client) {
console.error(error)
await interaction.reply({
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)
}
}
}
export { loadEvents }

View File

@@ -6,28 +6,32 @@ import fs = require("fs")
function loadModalEvents(client: Client) {
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) {
const filePath = path.join(modalPath, file)
const modal: Modal = require(filePath)
if ("name" in modal && "execute" in modal && modal.type === "modal") {
client.modals.set(modal.name, modal)
} 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 => {
if (!interaction.isModalSubmit())
return
if (!interaction.isModalSubmit()) return
const modal = client.modals.get(interaction.customId)
if (!modal) {
console.error(`No modal matching ${interaction.customId} was found.`)
console.error(
`No modal matching ${interaction.customId} was found.`,
)
return
}
@@ -37,7 +41,7 @@ function loadModalEvents(client: Client) {
console.error(error)
await interaction.reply({
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 minotar = "https://minotar.net/helm/"
async function getUUID(ign: string): Promise<string|null> {
async function getUUID(ign: string): Promise<string | null> {
try {
const req: Profile = await fetch(mojang + ign)
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 {
const req: Profile2 = await fetch(mojanguuid + uuid)
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, {
params: {
key: apikey,
uuid: uuid
}
uuid: uuid,
},
})
if (!playerReq.data.player) {
@@ -43,14 +43,17 @@ async function getPlayer(uuid: string): Promise<PlayerData|null> {
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 guildReq: Guild = await fetch(guild, {
params: {
key: apikey,
[reqType]: query
}
[reqType]: query,
},
})
if (!guildReq.data.guild) {
@@ -60,14 +63,8 @@ async function getGuild(query: string, type?: string): Promise<GuildData|null> {
return guildReq.data.guild
}
async function getHeadURL(ign: string): Promise<string|null> {
async function getHeadURL(ign: string): Promise<string | null> {
return minotar + ign
}
export {
getUUID,
getIGN,
getPlayer,
getGuild,
getHeadURL
}
export { getUUID, getIGN, getPlayer, getGuild, getHeadURL }

View File

@@ -25,8 +25,7 @@ function getExpForLevel(level: number): number {
function getLevelRespectingPrestige(level: number): number {
if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE
}
else {
} else {
return level % LEVELS_PER_PRESTIGE
}
}
@@ -39,7 +38,7 @@ const HIGHEST_PRESTIGE = 50
function bedwarsLevel(exp: number): number {
const prestiges = Math.floor(exp / XP_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) {
const expForEasyLevel = getExpForLevel(i)

View File

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

View File

@@ -9,7 +9,13 @@ const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX
const GROWTH_DIVIDES_2 = 2 / GROWTH
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 {
@@ -17,8 +23,8 @@ function hypixelLevel(exp: number): number {
}
function getTotalExpToLevel(level: number): number {
const lv = Math.floor(level); const
x0 = getTotalExpToFullLevel(lv)
const lv = Math.floor(level)
const x0 = getTotalExpToFullLevel(lv)
if (level === lv) return 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)
}
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"
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:
version "8.0.0"
resolved "https://registry.npmjs.org/pretty-ms/-/pretty-ms-8.0.0.tgz"