Converted main codebase to typescript

Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
2023-12-28 13:17:57 +01:00
parent 1d9ded82a4
commit 68fde04bbb
122 changed files with 14230 additions and 1834 deletions

View File

@@ -1,8 +1,9 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { admin, helper } = require("../../config/roles.json")
const { color } = require("../../config/options.json")
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"
module.exports = {
export = {
name: "ban",
description: "Ban a user",
type: "slash",
@@ -38,32 +39,38 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const member = interaction.options.getMember("user")
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 mod = await interaction.guild.members.fetch(interaction.user.id)
const embedColor = Number(color.replace("#", "0x"))
if (!member) {
await interaction.editReply("You must specify a user.")
return
}
const mod = await interaction.guild!.members.fetch(interaction.user.id)
const memberRoles = member.roles.cache.map(role => role.id)
const modRoles = mod.roles.cache.map(role => role.id)
const embedColor = Number(color.replace("#", "0x"))
if (!modRoles.includes(admin)) {
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
}
if (member.id === mod.id) {
return interaction.editReply("You cannot ban yourself.")
await interaction.editReply("You cannot ban yourself.")
return
}
if (member.id === interaction.applicationId) {
@@ -71,7 +78,7 @@ module.exports = {
return
}
if (member.id === interaction.guild.ownerId) {
if (member.id === interaction.guild!.ownerId) {
await interaction.editReply("I ban kick the server owner.")
return
}
@@ -87,8 +94,8 @@ module.exports = {
}
await member.ban({
deleteMessageSeconds: messageDeletionDays * 86400,
reason: reason + ` - ${mod.user.username}`
reason: reason,
deleteMessageDays: messageDeletionDays
})
await interaction.editReply({
@@ -101,11 +108,11 @@ module.exports = {
color: embedColor,
footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL({ dynamic: true })
icon_url: member.user.avatarURL({ forceStatic: false }) || undefined
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
}
}
} as Command

View File

@@ -1,9 +1,10 @@
const { SlashCommandBuilder } = require("discord.js")
const { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } = require("../../config/reqs.json")
const { color, devMessage } = require("../../config/options.json")
const { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild, getHeadURL } = require("../utils/utils.js")
import { SlashCommandBuilder } from "discord.js"
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 { Command } from "../interfaces"
module.exports = {
export = {
name: "check",
description: "Check a player's stats.",
type: "slash",
@@ -17,8 +18,6 @@ module.exports = {
.setDescription("The player's IGN.")
.setRequired(true)),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply({})
@@ -111,7 +110,7 @@ module.exports = {
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 = []
@@ -235,7 +234,7 @@ module.exports = {
const level = hypixelLevel(hypixelExp)
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
@@ -246,14 +245,14 @@ module.exports = {
"**Guild Rank:** `" + guildRank + "`",
color: embedColor,
thumbnail: {
url: head
url: head!
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon!
},
fields: statsFields
}]
})
}
}
} as Command

View File

@@ -1,7 +1,8 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
const { color } = require("../../config/options.json")
import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, GuildTextBasedChannel } from "discord.js"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "clear",
description: "Clears messages",
type: "slash",
@@ -19,14 +20,12 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const amount = interaction.options.getInteger("amount")
const channel = interaction.channel
const amount = interaction.options.getInteger("amount")!
const channel2 = interaction.channel!
const embedColor = Number(color.replace("#", "0x"))
if (!amount || amount < 1 || amount > 100) {
@@ -38,6 +37,17 @@ module.exports = {
})
}
if (channel2.type !== ChannelType.GuildText) {
await interaction.editReply({
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 =>
@@ -56,4 +66,4 @@ module.exports = {
})
})
}
}
} as Command

View File

@@ -1,9 +1,10 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
const { color } = require("../../config/options.json")
const settings = require("../schemas/settingsSchema.js")
const mongoose = require("mongoose")
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
import { color } from "../../config/options.json"
import settings = require("../schemas/settingsSchema")
import mongoose = require("mongoose")
import { Command } from "../interfaces"
module.exports = {
export = {
name: "config",
description: "Configure the bot",
type: "slash",
@@ -30,8 +31,6 @@ module.exports = {
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
@@ -70,6 +69,5 @@ module.exports = {
}]
})
}
}
}
} as Command

36
src/commands/dev-info.ts Normal file
View File

@@ -0,0 +1,36 @@
import { SlashCommandBuilder, PermissionFlagsBits, ChatInputCommandInteraction } from "discord.js"
import { Command } from "../interfaces"
const command: Command = {
name: "dev-info",
description: "Test command for the bot.",
type: "slash",
dev: true,
public: false,
data: new SlashCommandBuilder()
.setName("dev-info")
.setDescription("Test command for the bot.")
.addStringOption(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)
const embed = message.embeds[0]
const fields = embed.fields
const field1 = fields[0]
console.log(field1.value)
await interaction.reply({ content: "Test command.", ephemeral: true })
}
}
export = command

View File

@@ -1,6 +1,7 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "devel",
description: "Admin command.",
type: "slash",
@@ -17,8 +18,6 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
const subcommand = interaction.options.getSubcommand()
@@ -28,7 +27,7 @@ module.exports = {
const { exec } = require("child_process")
await interaction.reply({ content: "Reloading...", ephemeral: true })
exec("pm2 restart 0", async (err) => {
exec("pm2 restart 0", async (err: Error) => {
if (err) {
await interaction.reply({ content: "Error while reloading: " + err, ephemeral: true })
}
@@ -36,4 +35,4 @@ module.exports = {
}
}
}
} as Command

View File

@@ -1,10 +1,11 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
const verify = require("../schemas/verifySchema.js")
const { gm, manager, moderator, beast, member, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
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 { Command } from "../interfaces"
const removeThese = [gm, manager, moderator, beast, member, guildRole, guildStaff, defaultMember]
module.exports = {
export = {
name: "forceunverify",
description: "Force unverify a user",
type: "slash",
@@ -22,13 +23,10 @@ module.exports = {
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
const member1 = interaction.options.getUser("user")
const member = interaction.guild.members.cache.get(member1.id)
const member = interaction.options.getMember("user") as GuildMember
const embedColor = Number(color.replace("#", "0x"))
const verifiedUser = await verify.findOne({ userID: member1.id })
const verifiedUser = await verify.findOne({ userID: member.user.id })
if (!verifiedUser) {
return interaction.reply({
@@ -39,19 +37,19 @@ module.exports = {
})
}
await verify.findOneAndDelete({ userID: member1.id })
await verify.findOneAndDelete({ userID: member.user.id })
await member.roles.remove(removeThese)
await interaction.reply({
embeds: [{
description: "Successfully unverified " + userMention(member1.id),
description: "Successfully unverified " + userMention(member.user.id),
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
}
}
} as Command

View File

@@ -1,11 +1,12 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { getGuild, getHeadURL, getIGN } = require("../utils/utils.js")
const { hypixelGuildID, color, devMessage } = require("../../config/options.json")
const { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
const verify = require("../schemas/verifySchema.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 verify = require("../schemas/verifySchema")
import { Command } from "../interfaces"
const removeThese = [gm, manager, moderator, beast, elite, member, guildRole, guildStaff]
module.exports = {
export = {
name: "forceupdate",
description: "Force update the user",
type: "slash",
@@ -23,19 +24,16 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const user = interaction.options.getUser("user")
const usermentioned = userMention(user.id)
const verifyData = await verify.findOne({ userID: user.id })
const user = interaction.options.getMember("user") as GuildMember
const usermentioned = userMention(user.user.id)
const verifyData = await verify.findOne({ userID: user.user.id })
const embedColor = Number(color.replace("#", "0x"))
const user1 = interaction.guild.members.cache.get(user.id)
const roleManage = user1.roles
const roleManage = user.roles
if (!verifyData) {
await interaction.editReply({
@@ -43,8 +41,8 @@ module.exports = {
description: "User is not verified.",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -58,7 +56,7 @@ module.exports = {
}]
})
const ign = await getIGN(verifyData.uuid)
const ign = await getIGN(verifyData.uuid) as string
const head = await getHeadURL(ign)
await interaction.editReply({
@@ -70,7 +68,7 @@ module.exports = {
const guild = await getGuild(verifyData.uuid)
let responseGuildID = ""
let responseGuildID: string | null
if (!guild) {
responseGuildID = null
} else {
@@ -88,11 +86,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -102,8 +100,8 @@ module.exports = {
if (responseGuildID === hypixelGuildID) {
const GuildMembers = guild.members
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank
const GuildMembers = guild!.members
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid)!.rank
if (guildRank === "Guild Master") {
@@ -122,11 +120,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -149,11 +147,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -176,11 +174,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -203,11 +201,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -230,11 +228,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -257,11 +255,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -269,4 +267,4 @@ module.exports = {
}
}
}
}
} as Command

View File

@@ -1,12 +1,12 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
const { getUUID, getPlayer, getGuild, getHeadURL } = require("../utils/utils.js")
const { color, hypixelGuildID, devMessage } = require("../../config/options.json")
const verify = require("../schemas/verifySchema.js")
const { mongoose } = require("mongoose")
const { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
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 { Command } from "../interfaces"
module.exports = {
export = {
name: "forceverify",
description: "Force verify a user.",
type: "slash",
@@ -27,19 +27,16 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const user1 = interaction.options.getUser("user")
const user = interaction.guild.members.cache.get(user1.id)
const user = interaction.member as GuildMember
const ign = interaction.options.getString("ign")
const mod = interaction.user
const embedColor = Number(color.replace("#", "0x"))
const verifyData = await verify.findOne({ userID: user.id })
const verifyData = await verify.findOne({ userID: user.user.id })
if (verifyData) {
interaction.editReply("That user is already verified.")
return
@@ -56,10 +53,10 @@ module.exports = {
}
let username = ""
if (user1.discriminator == "0") {
username = user1.username
if (user.user.discriminator == "0") {
username = user.user.username
} else {
username = user1.username + "#" + user1.discriminator
username = user.user.username + "#" + user.user.discriminator
}
let modName = ""
@@ -113,7 +110,7 @@ module.exports = {
})
const guild = await getGuild(uuid)
let responseGuildID = ""
let responseGuildID: string | null
if (!guild) {
responseGuildID = null
} else {
@@ -122,8 +119,8 @@ module.exports = {
const head = await getHeadURL(ign)
if (responseGuildID === hypixelGuildID) {
const GuildMembers = guild.members
const guildRank = GuildMembers.find(member => member.uuid === player.uuid).rank
const GuildMembers = guild!.members
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)
@@ -171,18 +168,18 @@ module.exports = {
await interaction.editReply({
embeds: [{
title: interaction.guild.name,
title: interaction.guild!.name,
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(),
text: interaction.guild.name + " | " + devMessage
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}]
})
}
}
} as Command

View File

@@ -1,10 +1,11 @@
const { SlashCommandBuilder } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
const { guildMember } = require("./guild/member.js")
const { guildInfo } = require("./guild/info.js")
const { guildTop } = require("./guild/top.js")
import { SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
import guildMember = require("./guild/member")
import guildInfo = require("./guild/info")
import guildTop = require("./guild/top")
module.exports = {
export = {
name: "guild",
description: "Subcommands for guilds",
type: "slash",
@@ -72,8 +73,6 @@ module.exports = {
.setDescription("The amount of guild members to show. [Default: 10]"))
),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
const subcommand = interaction.options.getSubcommand()
@@ -95,7 +94,7 @@ module.exports = {
}
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: true })
await interaction.reply({
embeds: [{
@@ -103,9 +102,9 @@ module.exports = {
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon!
}
}]
})
}
}
} as Command

View File

@@ -1,15 +1,15 @@
const { getUUID, getIGN, getPlayer, getGuild, guildLevel } = require("../../utils/utils.js")
const { color, devMessage } = require("../../../config/options.json")
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"
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildInfo(interaction) {
async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void> {
await interaction.deferReply()
const query = interaction.options.getString("query")
const query = interaction.options.getString("query")!
const type = interaction.options.getString("type") || "ign"
const embedColor = Number(color.replace("#", "0x"))
let guild
let guild: GuildData | null
if (type === "ign") {
await interaction.editReply({
@@ -103,14 +103,14 @@ async function guildInfo(interaction) {
}
}
const guildName = guild.name
const guildCreatedMS = guild.created
const guildName = guild!.name
const guildCreatedMS = guild!.created
const guildCreated = new Date(guildCreatedMS)
const guildTag = guild.tag
const guildExpUnformatted = guild.exp
const guildTag = guild!.tag
const guildExpUnformatted = guild!.exp
const guildExp = new Intl.NumberFormat("en-US").format(guildExpUnformatted)
const guildLvl = guildLevel(guildExpUnformatted)
const guildMembers = guild.members
const guildMembers = guild!.members
const guildCreatedDate = guildCreated.getDate()
const guildCreatedMonth = guildCreated.getMonth() + 1
@@ -126,9 +126,9 @@ async function guildInfo(interaction) {
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 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)
@@ -143,7 +143,7 @@ async function guildInfo(interaction) {
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({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
@@ -171,10 +171,10 @@ async function guildInfo(interaction) {
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon!
}
}]
})
}
module.exports = { guildInfo }
export = guildInfo

View File

@@ -1,12 +1,11 @@
const { getUUID, getPlayer, getGuild, getHeadURL } = require("../../utils/utils.js")
const { color, devMessage } = require("../../../config/options.json")
import { getUUID, getPlayer, getGuild, getHeadURL } from "../../utils/Hypixel"
import { color, devMessage } from "../../../config/options.json"
import { ChatInputCommandInteraction } from "discord.js"
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildMember(interaction) {
async function guildMember(interaction: ChatInputCommandInteraction): Promise<void> {
await interaction.deferReply()
const ign = interaction.options.getString("ign")
const ign = interaction.options.getString("ign")!
const embedColor = Number(color.replace("#", "0x"))
await interaction.editReply({
@@ -45,11 +44,11 @@ async function guildMember(interaction) {
description: "This user never logged on to hypixel",
color: embedColor,
thumbnail: {
url: head,
url: head!,
},
footer: {
text: interaction?.guild.name || interaction.user.username + " | " + devMessage,
icon_url: interaction?.guild.iconURL({ dynamic: true }) || interaction.user.avatarURL({ dynamic: true }),
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
},
],
@@ -88,11 +87,11 @@ async function guildMember(interaction) {
description: "This user is not in a guild",
color: embedColor,
thumbnail: {
url: head,
url: head!,
},
footer: {
text: interaction.guild.name + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true }),
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
},
}],
})
@@ -104,8 +103,8 @@ async function guildMember(interaction) {
const guildMembers = guild.members
const guildMember = guildMembers.find((member) => member.uuid === uuid)
const guildRank = guildMember.rank
const memberGexp = guildMember.expHistory
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"
})
@@ -115,7 +114,7 @@ async function guildMember(interaction) {
const averageWeeklyGexpUnformatted = Math.round(totalWeeklyGexpUnformatted / 7)
const averageWeeklyGexp = new Intl.NumberFormat("en-US").format(averageWeeklyGexpUnformatted)
const guildMemberJoinMS = guildMember.joined
const guildMemberJoinMS = guildMember!.joined
const guildMemberJoinTime = new Date(guildMemberJoinMS)
const guildMemberJoinDate = guildMemberJoinTime.getDate()
const guildMemberJoinMonth = guildMemberJoinTime.getMonth() + 1
@@ -133,7 +132,7 @@ async function guildMember(interaction) {
guildMemberJoinSeconds
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
@@ -142,7 +141,7 @@ async function guildMember(interaction) {
"**Guild Rank:** `" + guildRank + "`\n",
color: embedColor,
thumbnail: {
url: head,
url: head!,
},
fields: [
{
@@ -161,10 +160,10 @@ async function guildMember(interaction) {
],
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon!
},
}],
})
}
module.exports = { guildMember }
export = guildMember

View File

@@ -1,20 +1,19 @@
const { getUUID, getPlayer, getGuild, getIGN } = require("../../utils/utils.js")
const { color, devMessage } = require("../../../config/options.json")
const { ChannelType } = require("discord.js")
const { redis } = require("../../utils/redis.js")
import { getUUID, getPlayer, getGuild, getIGN } from "../../utils/Hypixel"
import { color, devMessage } from "../../../config/options.json"
import { ChannelType, ChatInputCommandInteraction } from "discord.js"
import { redis } from "../../utils/Redis"
import { GuildData } from "../../interfaces/Guild"
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function guildTop(interaction) {
async function guildTop(interaction: ChatInputCommandInteraction): Promise<void> {
await interaction.deferReply()
const query = interaction.options.getString("query")
const query = interaction.options.getString("query")!
const type = interaction.options.getString("type") || "ign"
let amount = interaction.options.getNumber("amount") || 10
const embedColor = Number(color.replace("#", "0x"))
let guild
let guild: GuildData | null
if (interaction.channel.type === ChannelType.DM) {
if (interaction.channel!.type === ChannelType.DM) {
interaction.editReply({
embeds: [{
description: "You can't use this command in DMs!",
@@ -116,9 +115,9 @@ async function guildTop(interaction) {
}
}
const guildName = guild.name
const guildMembers = guild.members
const guildId = guild._id
const guildName = guild!.name
const guildMembers = guild!.members
const guildId = guild!._id
const cachedData = await redis.get("guildTop+" + guildId)
@@ -145,9 +144,12 @@ async function guildTop(interaction) {
amount = 1
}
let cacheStatus
let guildData = []
const fieldsValueRaw = []
type GuildTopData = { ign: string, gexp: string }[]
type NewList = { name: string, value: string, inline: boolean }[]
let cacheStatus: boolean
let guildData: GuildTopData = []
const fieldsValueRaw: string[] = []
const allMembersSorted = allMembersDailyGEXP.sort((a, b) => b.gexp - a.gexp)
if (!cachedData) {
@@ -160,7 +162,7 @@ async function guildTop(interaction) {
})
for (let i = 0; i < allMembersSorted.length; i++) {
const ign = await getIGN(allMembersSorted[i].uuid)
const ign = await getIGN(allMembersSorted[i].uuid) as string
const gexpUnformatted = allMembersSorted[i].gexp
const gexp = new Intl.NumberFormat("en-US").format(gexpUnformatted)
@@ -195,7 +197,7 @@ async function guildTop(interaction) {
}
const list = Array.from({ length: sliceSize }, (_, i) => fieldsValueRaw.slice(i * sliceSize, (i + 1) * sliceSize))
const newList = []
const newList: NewList = []
list.forEach((item, index) => {
if (item.length === 0) return
@@ -208,7 +210,7 @@ async function guildTop(interaction) {
})
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
const cacheStatusText = cacheStatus ? " | [Cache]" : ""
await interaction.editReply({
@@ -220,10 +222,10 @@ async function guildTop(interaction) {
fields: newList,
footer: {
text: footerText + " | " + devMessage + cacheStatusText,
icon_url: footerIcon
icon_url: footerIcon!
}
}]
})
}
module.exports = { guildTop }
export = guildTop

View File

@@ -1,73 +0,0 @@
const { SlashCommandBuilder } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
const fs = require("fs")
module.exports = {
name: "help",
description: "Help command",
type: "slash",
dev: false,
public: true,
data: new SlashCommandBuilder()
.setName("help")
.setDescription("List's all commands usable by a member")
.setDMPermission(true),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const commands = []
const commandFiles = fs.readdirSync(__dirname).filter(file => file.endsWith(".js"))
for (const file of commandFiles) {
const command = require(`./${file}`)
if (command.public && !command.subcommands) {
commands.push(command)
} else if (command.public && command.subcommands) {
const commandName = command.data.name
const subcommands = command.data.options.map((subcommand) => {
return {
name: commandName + " " + subcommand.name,
description: subcommand.description
}
})
for (const subcommand of subcommands) {
commands.push(subcommand)
}
}
}
const commandList = commands.map((command) => {
return {
name: "**/" + command.name + "**",
value: "`" + command.description + "`"
}
})
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
await interaction.editReply({
embeds: [{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction?.guild?.iconURL({ dynamic: true }) || null
},
footer: {
icon_url: footerIcon,
text: footerText + " | " + devMessage
}
}]
})
}
}

79
src/commands/help.ts Normal file
View File

@@ -0,0 +1,79 @@
import { SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
export = {
name: "help",
description: "Help command",
type: "slash",
dev: false,
public: true,
data: new SlashCommandBuilder()
.setName("help")
.setDescription("List's all commands usable by a member")
.setDMPermission(true),
async execute(interaction, client) {
await interaction.deferReply({ ephemeral: true })
type CommandList = {
name: string,
value: string
}
const commandList: CommandList[] = []
const commandRawList = client.commands.map((command) => {
return {
name: command.name,
command: command
}
})
for (const command of commandRawList) {
const commandName = command.name
if (!command.command.subcommands && command.command.public) {
commandList.push({
name: "**/" + commandName + "**",
value: "`" + command.command.description + "`"
})
} else if (command.command.subcommands && command.command.public) {
const subcommands = command.command.data.options.map((subcommand) => {
return {
name: commandName + " " + subcommand.toJSON().name,
description: subcommand.toJSON().description
}
})
for (const subcommand of subcommands) {
commandList.push({
name: "**/" + subcommand.name + "**",
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 })
await interaction.editReply({
embeds: [{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction?.guild?.iconURL({ forceStatic: true })!
},
footer: {
icon_url: footerIcon!,
text: footerText + " | " + devMessage
}
}]
})
}
} as Command

View File

@@ -1,11 +1,12 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
const { color, devMessage, instructionsgif } = require("../../config/options.json")
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
import { color, devMessage, instructionsgif } from "../../config/options.json"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "instructions",
description: "Instructions for verification",
type: "slash",
dev: true,
dev: false,
public: false,
data: new SlashCommandBuilder()
@@ -13,8 +14,6 @@ module.exports = {
.setDescription("Instructions for verification")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
const embedColor = Number(color.replace("#", "0x"))
@@ -29,14 +28,15 @@ module.exports = {
"6. Run the `/verify` command in this channel.\n",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
image: {
url: instructionsgif
url: instructionsgif,
proxy_url: instructionsgif
}
}]
})
}
}
} as Command

View File

@@ -1,8 +1,9 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { admin, helper } = require("../../config/roles.json")
const { color } = require("../../config/options.json")
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"
module.exports = {
export = {
name: "kick",
description: "Kick a member from the server.",
type: "slash",
@@ -24,18 +25,22 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const member = interaction.options.getMember("member")
const member = interaction.options.getMember("member") as GuildMember | null
const reason = interaction.options.getString("reason") ?? "No reason provided."
const mod = await interaction.guild.members.fetch(interaction.user.id)
const embedColor = Number(color.replace("#", "0x"))
if (!member) {
await interaction.editReply("You must specify a member.")
return
}
const mod = await interaction.guild!.members.fetch(interaction.user.id)
const memberRoles = member.roles.cache.map(role => role.id)
const modRoles = mod.roles.cache.map(role => role.id)
const embedColor = Number(color.replace("#", "0x"))
if (!modRoles.includes(helper) && !modRoles.includes(admin)) {
await interaction.editReply("You do not have permission to use this command.")
@@ -47,13 +52,14 @@ module.exports = {
return
}
if (member.id === interaction.guild.ownerId) {
if (member.id === interaction.guild!.ownerId) {
await interaction.editReply("I cannot kick the server owner.")
return
}
if (member.id === mod.id) {
return interaction.editReply("You cannot kick yourself.")
await interaction.editReply("You cannot kick yourself.")
return
}
if (memberRoles.includes(helper) || memberRoles.includes(admin)) {
@@ -77,11 +83,11 @@ module.exports = {
color: embedColor,
footer: {
text: "ID: " + member.user.id,
icon_url: member.user.avatarURL({ dynamic: true })
icon_url: member.user.avatarURL({ forceStatic: false }) || undefined
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
}
}
} as Command

View File

@@ -1,7 +1,8 @@
const { SlashCommandBuilder } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
import { SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "ping",
description: "Get the bot's ping.",
type: "slash",
@@ -12,18 +13,13 @@ module.exports = {
.setName("ping")
.setDescription("Get's the bot's ping."),
/**
* @param { import("discord.js").ChatInputCommandInteraction } interaction
* @param { import("discord.js").Client } client}
*/
async execute(interaction, client) {
await interaction.deferReply()
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
@@ -31,10 +27,10 @@ module.exports = {
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon || undefined
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
}
}
} as Command

View File

@@ -1,8 +1,9 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { color } = require("../../config/options.json")
const { waitinglistSchema } = require("../schemas/waitinglistSchema.js")
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
import { color } from "../../config/options.json"
import waitinglistSchema = require("../schemas/waitinglistSchema")
import { Command } from "../interfaces"
module.exports = {
export = {
name: "remove",
description: "Remove a person on the waiting list.",
type: "slash",
@@ -27,15 +28,13 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
interaction.deferReply()
await interaction.deferReply()
const user = interaction.options.getUser("user")
const user = interaction.options.getUser("user")!
const reason = interaction.options.getString("reason") ?? "No reason provided."
const mod = interaction.user
const mod = interaction.user!
const embedColor = Number(color.replace("#", "0x"))
const waitinglist = await waitinglistSchema.findOne({ UserID: user.id })
@@ -44,7 +43,7 @@ module.exports = {
await interaction.editReply({
embeds: [{
description: userMention(user.id) + " is not on the waiting list.",
color: color
color: embedColor
}]
})
return
@@ -60,10 +59,10 @@ module.exports = {
color: embedColor,
footer: {
text: "User ID: " + user.id,
icon_url: user.displayAvatarURL( { dynamic: true })
icon_url: user.displayAvatarURL({ forceStatic: false })
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
}
}
} as Command

View File

@@ -1,8 +1,9 @@
const { SlashCommandBuilder } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
const { bwfkdr, bwstars, bwwins, swstars, swkdr, duelswins, duelswlr } = require("../../config/reqs.json")
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 { Command } from "../interfaces"
module.exports = {
export = {
name: "reqs",
description: "Displays the requirements for the guild.",
type: "slash",
@@ -13,15 +14,13 @@ module.exports = {
.setName("reqs")
.setDescription("Displays the requirements for the guild."),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
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({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
@@ -29,7 +28,7 @@ module.exports = {
description: "**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**",
color: embedColor,
thumbnail: {
url: interaction?.guild?.iconURL({ dynamic: true }) || null
url: interaction?.guild?.iconURL({ forceStatic: false }) || ""
},
fields: [
{
@@ -51,9 +50,9 @@ module.exports = {
],
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon || undefined
}
}]
})
}
}
} as Command

View File

@@ -1,62 +0,0 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
module.exports = {
name: "send",
description: "Send a message to a channel.",
type: "slash",
dev: false,
public: false,
data: new SlashCommandBuilder()
.setName("send")
.setDescription("Send a message to a channel.")
.addStringOption(option =>
option
.setName("message")
.setDescription("The message to send."))
.addChannelOption(option =>
option
.setName("channel")
.setDescription("The channel to send the message to."))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
const message = interaction.options.getString("message")
const channel = interaction.options.getChannel("channel")
const embedColor = Number(color.replace("#", "0x"))
if (!message) {
interaction.editReply({ content: "Please provide a message to send.", ephemeral: true })
return
}
if (!channel) {
interaction.editReply({ content: "Please provide a channel to send the message to.", ephemeral: true })
return
}
channel.send({
embeds: [
{
title: interaction.guild.name,
description: message,
color: embedColor,
thumbnail: {
url: interaction.guild.iconURL({ dynamic: true })
},
footer: {
text: interaction.guild.id + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true })
}
}
]
})
}
}

79
src/commands/send.ts Normal file
View File

@@ -0,0 +1,79 @@
import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, GuildTextBasedChannel } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
export = {
name: "send",
description: "Send a message to a channel.",
type: "slash",
dev: false,
public: false,
data: new SlashCommandBuilder()
.setName("send")
.setDescription("Send a message to a channel.")
.addStringOption(option =>
option
.setName("message")
.setDescription("The message to send.")
.setRequired(true))
.addChannelOption(option =>
option
.setName("channel")
.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 embedColor = Number(color.replace("#", "0x"))
if (channel2?.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [{
description: "You can only send a message to a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
})
return
}
const channel = channel2 as GuildTextBasedChannel
channel.send({
embeds: [
{
title: interaction.guild!.name,
description: message,
color: embedColor,
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
},
footer: {
text: interaction.guild!.id + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: true }) || undefined
}
}
]
})
await interaction.editReply({
embeds: [{
description: "Message sent.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
})
}
} as Command

View File

@@ -1,6 +1,7 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
import { SlashCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "setnick",
description: "Set your nickname",
type: "slash",
@@ -23,16 +24,15 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
const user = interaction.options.getUser("user")
const user = interaction.options.getUser("user")!
const nickname = interaction.options.getString("nickname")
const member = await interaction.guild.members.fetch(user.id)
const member = await interaction.guild!.members.fetch(user.id)
if (!member.manageable) {
return 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}`)
@@ -40,4 +40,4 @@ module.exports = {
await interaction.reply({ content: "Set the nickname of " + userMention(member.id) + " to " + nickname, ephemeral: true })
}
}
} as Command

View File

@@ -1,7 +1,8 @@
const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
import { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, ChannelType, GuildTextBasedChannel } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "setup",
description: "Used for setup of the bot.",
type: "slash",
@@ -61,45 +62,57 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x"))
if (subcommand === "sendguildapplication") {
const channel = interaction.options.getChannel("channel")
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [
{
title: "Guild Application",
description: "You can apply for the guild by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
iconURL: interaction.guild.iconURL({ dynamic: true })
},
thumbnail: {
url: interaction.guild.iconURL({ dynamic: true })
}
embeds: [{
title: "Guild Application",
description: "You can apply for the guild by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
},
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false }) || ""
}
],
}],
components: [
new ActionRowBuilder()
.addComponents(new ButtonBuilder()
new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId("guildapply")
.setLabel("Apply")
.setStyle(ButtonStyle.Primary)
.setEmoji({ name: "✅" }))
.setEmoji({ name: "✅" })
)
]
})
await interaction.reply({ content: "Message sent", ephemeral: true })
}
if (subcommand === "sendstaffapplication") {
const channel = interaction.options.getChannel("channel")
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [
@@ -108,16 +121,16 @@ module.exports = {
description: "You can apply for the staff team by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
iconURL: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
thumbnail: {
url: interaction.guild.iconURL({ dynamic: true })
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}
],
components: [
new ActionRowBuilder()
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
.setCustomId("staffapply")
.setLabel("Apply")
@@ -130,7 +143,14 @@ module.exports = {
}
if (subcommand === "sendinactivityapplication") {
const channel = interaction.options.getChannel("channel")
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [
@@ -139,16 +159,16 @@ module.exports = {
description: "You can send an inactivity log by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
iconURL: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
thumbnail: {
url: interaction.guild.iconURL({ dynamic: true })
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}
],
components: [
new ActionRowBuilder()
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
.setCustomId("guildinactivitylog")
.setLabel("Submit")
@@ -161,7 +181,14 @@ module.exports = {
}
if (subcommand === "sendverfiymessage") {
const channel = interaction.options.getChannel("channel")
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [{
@@ -169,15 +196,15 @@ module.exports = {
description: "You can verify by clicking the button below.",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
iconURL: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
thumbnail: {
url: interaction.guild.iconURL({ dynamic: true })
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}],
components: [
new ActionRowBuilder()
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
.setCustomId("verify")
.setLabel("Verify")
@@ -190,7 +217,14 @@ module.exports = {
}
if (subcommand === "sendwaitinglistmessage") {
const channel = interaction.options.getChannel("channel")
const channel2 = interaction.options.getChannel("channel")!
if (channel2.type !== ChannelType.GuildText) {
await interaction.reply({ content: "That channel is not a text channel.", ephemeral: true })
return
}
const channel = channel2 as GuildTextBasedChannel
await channel.send({
embeds: [{
@@ -199,15 +233,15 @@ module.exports = {
"Try to invite them in order.",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
iconURL: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
thumbnail: {
url: interaction.guild.iconURL({ dynamic: true })
url: interaction.guild!.iconURL({ forceStatic: false })!
}
}],
components: [
new ActionRowBuilder()
new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder()
.setCustomId("waitinglistupdate")
.setLabel("Update")
@@ -219,4 +253,4 @@ module.exports = {
}
}
}
} as Command

View File

@@ -1,7 +1,8 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, GuildTextBasedChannel } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "slowmode",
description: "Set the slowmode of a channel.",
type: "slash",
@@ -22,16 +23,30 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply({ ephermeral: true })
await interaction.deferReply({ ephemeral: true })
const seconds = interaction.options.getInteger("seconds") ?? 5
const channel = interaction.options.getChannel("channel") ?? interaction.channel
const channel2 = interaction.options.getChannel("channel") ?? interaction.channel
const embedColor = Number(color.replace("#", "0x"))
if (channel2?.type !== ChannelType.GuildText) {
await interaction.editReply({
embeds: [{
description: "You can only set the slowmode of a text channel.",
color: embedColor,
footer: {
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
})
return
}
const channel = channel2 as GuildTextBasedChannel
if (seconds > 21600) {
await channel.setRateLimitPerUser(21600)
await interaction.editReply({
@@ -39,8 +54,8 @@ module.exports = {
description: `Set the slowmode of ${channel} to 21600 seconds.`,
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false }) || undefined
}
}]
})
@@ -52,12 +67,12 @@ module.exports = {
description: `Set the slowmode of ${channel} to ${seconds} seconds.`,
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: true }) || undefined
}
}]
})
await channel.setRateLimitPerUser(seconds)
}
}
} as Command

View File

@@ -1,14 +1,15 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
const { beast } = require("./staff/beast.js")
const { help } = require("./staff/help.js")
const { updateDiscordRoles } = require("./staff/updatediscordroles.js")
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { Command } from "../interfaces"
import { help} from "./staff/help"
import { beast } from "./staff/beast"
import { updateDiscordRoles } from "./staff/updatediscordroles"
module.exports = {
export = {
name: "staff",
description: "Subcommands for staff",
type: "slash",
dev: true,
dev: false,
public: false,
subcommands: true,
@@ -38,15 +39,13 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
async execute(interaction, client) {
const subcommand = interaction.options.getSubcommand()
const embedColor = Number(color.replace("#", "0x"))
if (subcommand === "help") {
help(interaction)
help(interaction, client)
return
}
@@ -61,7 +60,7 @@ module.exports = {
}
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
await interaction.reply({
embeds: [{
@@ -69,9 +68,9 @@ module.exports = {
color: embedColor,
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon!
}
}]
})
}
}
} as Command

View File

@@ -1,13 +1,12 @@
const { bwwins, beastbwfkdr, beastbwstars, beastswkdr, beastswstars, beastduelswins, duelswlr } = require("../../../config/reqs.json")
const { color, devMessage } = require("../../../config/options.json")
const { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild, getHeadURL } = require("../../utils/utils.js")
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 { ChatInputCommandInteraction } from "discord.js"
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async function beast(interaction) {
export async function beast(interaction: ChatInputCommandInteraction): Promise<void> {
await interaction.deferReply()
const ign = interaction.options.getString("ign")
const ign = interaction.options.getString("ign")!
const embedColor = Number(color.replace("#", "0x"))
if (!ign) {
@@ -212,7 +211,7 @@ async function beast(interaction) {
const level = hypixelLevel(hypixelExp)
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
await interaction.editReply({
embeds: [{
@@ -222,15 +221,13 @@ async function beast(interaction) {
"**Current Guild:** `" + guildName + "`",
color: embedColor,
thumbnail: {
url: head
url: head!
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon!
},
fields: statsFields
}]
})
}
module.exports = { beast }
}

View File

@@ -1,59 +0,0 @@
const { color, devMessage } = require("../../../config/options.json")
const fs = require("fs")
const path = require("path")
/** @param { import("discord.js").ChatInputCommandInteraction } interaction */
async function help(interaction) {
const commands = []
const commandFiles = fs.readdirSync(path.join(__dirname, "..")).filter(file => file.endsWith(".js"))
for (const file of commandFiles) {
const command = require(`../../commands/${file}`)
if (!command.public && !command.subcommands) {
commands.push(command)
} else if (!command.public && command.subcommands) {
const commandName = command.data.name
const subcommands = command.data.options.map((subcommand) => {
return {
name: commandName + " " + subcommand.name,
description: subcommand.description
}
})
for (const subcommand of subcommands) {
commands.push(subcommand)
}
}
}
const commandList = commands.map((command) => {
return {
name: "**/" + command.name + "**",
value: "`" + command.description + "`"
}
})
const embedColor = Number(color.replace("#", "0x"))
const footerText = interaction.guild ? interaction.guild.name : interaction.user.username
const footerIcon = interaction.guild ? interaction.guild.iconURL({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
await interaction.reply({
embeds: [{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction?.guild?.iconURL({ dynamic: true }) || null
},
footer: {
icon_url: footerIcon,
text: footerText + " | " + devMessage
}
}],
ephemeral: true
})
}
module.exports = { help }

View File

@@ -0,0 +1,65 @@
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> {
await interaction.deferReply({ ephemeral: true })
type CommandList = {
name: string,
value: string
}
const commandList: CommandList[] = []
const commandRawList = client.commands.map((command) => {
return {
name: command.name,
command: command
}
})
for (const command of commandRawList) {
const commandName = command.name
if (!command.command.subcommands && !command.command.public) {
commandList.push({
name: "**/" + commandName + "**",
value: "`" + command.command.description + "`"
})
} else if (command.command.subcommands && !command.command.public) {
const subcommands = command.command.data.options.map((subcommand) => {
return {
name: commandName + " " + subcommand.toJSON().name,
description: subcommand.toJSON().description
}
})
for (const subcommand of subcommands) {
commandList.push({
name: "**/" + subcommand.name + "**",
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 })
await interaction.editReply({
embeds: [{
title: "Commands",
description: "List of commands",
fields: commandList,
color: embedColor,
thumbnail: {
url: interaction.guild!.iconURL({ forceStatic: false })!
},
footer: {
icon_url: footerIcon!,
text: footerText + " | " + devMessage
}
}],
})
}

View File

@@ -1,99 +0,0 @@
const verify = require("../../schemas/verifySchema.js")
const { color, hypixelGuildID } = require("../../../config/options.json")
const { admin, gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } = require("../../../config/roles.json")
const removeThese = [gm, manager, beast, elite, member, guildRole, guildStaff]
const { getGuild } = require("../../utils/utils.js")
/** @param { import("discord.js").ChatInputCommandInteraction } interaction */
async function updateDiscordRoles(interaction) {
interaction.deferReply()
if (!interaction.member.roles.cache.has(admin)) {
interaction.editReply({
content: "You do not have permission to use this command.",
ephemeral: true
})
}
const embedColor = Number(color.replace("#", "0x"))
const guildMembers = await interaction.guild.members.fetch()
for (let i = 0; i < guildMembers.size; i++) {
const memberData = await verify.findOne({
userID: guildMembers[i].user.id
})
if (!memberData) {
for (const role of removeThese) {
guildMembers[i].roles.remove(role)
}
}
if (memberData) {
const igGuildMember = getGuild(memberData[i].uuid)
if (!igGuildMember) {
for (const role of removeThese) {
guildMembers[i].roles.remove(role)
}
}
const guildId = igGuildMember._id
const guildRank = igGuildMember.members.find(member => member.uuid === memberData[i].uuid).rank
if (!guildId === hypixelGuildID) {
for (const role of removeThese) {
guildMembers[i].roles.remove(role)
}
} else {
if (guildRank === "Guild Master") {
guildMembers[i].add(guildRole, "All users updated forcefully by staff")
guildMembers[i].add(guildStaff, "All users updated forcefully by staff")
guildMembers[i].add(gm, "All users updated forcefully by staff")
guildMembers[i].add(defaultMember, "All users updated forcefully by staff")
}
if (guildRank === "Manager") {
guildMembers[i].add(guildRole, "All users updated forcefully by staff")
guildMembers[i].add(guildStaff, "All users updated forcefully by staff")
guildMembers[i].add(manager, "All users updated forcefully by staff")
guildMembers[i].add(defaultMember, "All users updated forcefully by staff")
}
if (guildRank === "Moderator") {
guildMembers[i].add(guildRole, "All users updated forcefully by staff")
guildMembers[i].add(guildStaff, "All users updated forcefully by staff")
guildMembers[i].add(moderator, "All users updated forcefully by staff")
guildMembers[i].add(defaultMember, "All users updated forcefully by staff")
}
if (guildRank === "Beast") {
guildMembers[i].add(guildRole, "All users updated forcefully by staff")
guildMembers[i].add(beast, "All users updated forcefully by staff")
guildMembers[i].add(defaultMember, "All users updated forcefully by staff")
}
if (guildRank === "Elite") {
guildMembers[i].add(guildRole, "All users updated forcefully by staff")
guildMembers[i].add(elite, "All users updated forcefully by staff")
guildMembers[i].add(defaultMember, "All users updated forcefully by staff")
}
if (guildRank === "Member") {
guildMembers[i].add(guildRole, "All users updated forcefully by staff")
guildMembers[i].add(member, "All users updated forcefully by staff")
guildMembers[i].add(defaultMember, "All users updated forcefully by staff")
}
}
}
}
interaction.editReply({
embeds: [{
color: embedColor,
description: "Successfully updated all users.",
footer: {
text: interaction.guild.name,
iconURL: interaction.guild.iconURL({ dynamic: true })
}
}]
})
}
module.exports = { updateDiscordRoles }

View File

@@ -0,0 +1,108 @@
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"
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> {
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.")
return
}
const embedColor = Number(color.replace("#", "0x"))
const guildMembers = await interaction.guild!.members.fetch()
const memberList = guildMembers.map(member => {
return {
id: member.user.id,
member: member
}
})
for (const guildMember of memberList) {
const memberData = await verify.findOne({
userID: guildMember.id
})
if (!memberData) {
for (const role of removeThese) {
guildMember.member.roles.remove(role)
}
return
}
if (memberData) {
const isGuildMember = getGuild(memberData.uuid)
if (!isGuildMember) {
for (const role of removeThese) {
guildMember.member.roles.remove(role)
}
return
}
const hypixelGuildMember = isGuildMember as unknown as GuildData
const guildId = hypixelGuildMember!._id
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")
}
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")
}
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")
}
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")
}
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")
}
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")
}
} else {
for (const role of removeThese) {
guildMember.member.roles.remove(role)
}
}
}
}
interaction.editReply({
embeds: [{
color: embedColor,
description: "Successfully updated all users.",
footer: {
text: interaction.guild!.name,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
}

View File

@@ -1,8 +1,9 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { color } = require("../../config/options.json")
const ms = require("ms")
import { SlashCommandBuilder, PermissionFlagsBits, userMention, ChatInputCommandInteraction, GuildMember } from "discord.js"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
import ms from "ms"
module.exports = {
const command: Command = {
name: "timeout",
description: "Times out a memeber",
type: "slash",
@@ -29,23 +30,21 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
async execute(interaction: ChatInputCommandInteraction) {
await interaction.deferReply()
const { default: prettyms } = await import("pretty-ms")
const target1 = interaction.options.getUser("user")
const target = interaction.guild.members.cache.get(target1.id)
const timeString = interaction.options.getString("time")
const target = interaction.options.getMember("user")! as GuildMember
const timeString = interaction.options.getString("time")!
const reason = interaction.options.getString("reason") || "No reason provided"
const time = ms(timeString)
const prettyTime = prettyms(time, { verbose: true })
const mod = interaction.member! as GuildMember
const embedColor = Number(color.replace("#", "0x"))
const time = ms(timeString)
const { default: prettyMs } = await import("pretty-ms")
const prettyTime = prettyMs(time, { verbose: true })
if (target.bot) {
interaction.deferReply({
if (target.user.bot) {
interaction.editReply({
embeds: [{
description: "You cannot timeout a bot.",
color: embedColor,
@@ -54,8 +53,8 @@ module.exports = {
return
}
if (target.id == interaction.guild.ownerId) {
await interaction.deferReply({
if (target.id == interaction.guild!.ownerId) {
await interaction.editReply({
embeds: [{
description: "You cannot timeout the server owner.",
color: embedColor,
@@ -64,8 +63,8 @@ module.exports = {
return
}
if (interaction.guild.members.me.roles.highest.position <= target.roles.highest.position) {
interaction.deferReply({
if (interaction.guild!.members.me!.roles.highest.position <= target.roles.highest.position) {
interaction.editReply({
embeds: [{
description: "I cannot timeout this user because their role is higher than mine.",
color: embedColor,
@@ -74,8 +73,8 @@ module.exports = {
return
}
if (interaction.member.roles.highest.position <= target.roles.highest.position) {
await interaction.deferReply({
if (mod.roles.highest.position <= target.roles.highest.position) {
await interaction.editReply({
embeds: [{
description: "You cannot timeout this user because their role is higher than yours.",
color: embedColor,
@@ -85,7 +84,7 @@ module.exports = {
}
if (target.id == interaction.user.id) {
interaction.deferReply({
interaction.editReply({
embeds: [{
description: "You cannot timeout yourself.",
color: embedColor,
@@ -103,9 +102,9 @@ module.exports = {
color: embedColor,
footer: {
text: "ID: " + target.id,
iconURL: target.avatarURL()
icon_url: target.avatarURL() || undefined
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
return
@@ -118,9 +117,9 @@ module.exports = {
color: embedColor,
footer: {
text: "ID: " + target.id,
iconURL: target.avatarURL()
icon_url: target.avatarURL() || undefined
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
return
@@ -133,10 +132,12 @@ module.exports = {
color: embedColor,
footer: {
text: "ID: " + target.id,
iconURL: target.avatarURL()
icon_url: target.avatarURL() || undefined
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
}
}
export = command

View File

@@ -1,7 +1,8 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { color } = require("../../config/options.json")
import { SlashCommandBuilder, PermissionFlagsBits, userMention, User } from "discord.js"
import { color } from "../../config/options.json"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "unban",
description: "Unban a user from the server",
type: "slash",
@@ -27,16 +28,14 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.setDMPermission(false),
/** @param { import("discord.js").ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const userid = interaction.options.getString("user")
const userid = interaction.options.getString("user")!
const reason = interaction.options.getString("reason") || "No reason provided"
const mod = interaction.user
const embedColor = Number(color.replace("#", "0x"))
let user
let user: User | null
if (userid === "none") {
await interaction.editReply({
@@ -59,24 +58,24 @@ module.exports = {
})
}
await interaction.guild.members.unban(user.id, reason)
await interaction.guild!.members.unban(user!.id, reason)
await interaction.editReply({
embeds: [{
title: "User unbanned",
description: "The user " + user.username + " has been unbanned.\n" +
description: "The user " + user!.username + " has been unbanned.\n" +
"**Reason:** `" + reason + "`\n" +
"**Moderator:** " + userMention(mod.id),
color: embedColor,
thumbnail: {
url: user?.avatarURL({ dynamic: true }) || null
url: user!.avatarURL({ forceStatic: false }) || ""
},
footer: {
text: "ID: " + user.id,
icon_url: interaction.guild.iconURL({ dynamic: true })
text: "ID: " + user!.id,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
},
timestamp: new Date()
timestamp: new Date().toISOString()
}]
})
}
}
} as Command

View File

@@ -1,11 +1,12 @@
const { SlashCommandBuilder } = require("discord.js")
const { getGuild, getIGN, getHeadURL } = require("../utils/utils.js")
const verify = require("../schemas/verifySchema.js")
const { color, hypixelGuildID, devMessage } = require("../../config/options.json")
const { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
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 { Command } from "../interfaces"
const removeThese = [gm, manager, moderator, beast, elite, member, guildRole, guildStaff]
module.exports = {
export = {
name: "update",
description: "Update your guild rank.",
type: "slash",
@@ -17,15 +18,12 @@ module.exports = {
.setDescription("Update your discord roles.")
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const user1 = interaction.user
const user = interaction.guild.members.cache.get(user1.id)
const verifyData = await verify.findOne({ userID: user.id })
const user = interaction.member as GuildMember
const verifyData = await verify.findOne({ userID: user.user.id })
const roleManage = user.roles
const embedColor = Number(color.replace("#", "0x"))
@@ -35,8 +33,8 @@ module.exports = {
description: "You are not verified. Please run `/verify` to verify yourself",
color: embedColor,
footer: {
text: interaction.guild.name + " | " + devMessage,
icon_url: interaction.guild.iconURL({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -51,14 +49,14 @@ module.exports = {
})
const guild = await getGuild(verifyData.uuid)
let guildID = ""
let guildID: string | null
if (!guild) {
guildID = null
} else {
guildID = guild._id
}
const ign = await getIGN(verifyData.uuid)
const ign = await getIGN(verifyData.uuid) as string
const head = await getHeadURL(ign)
if (guildID !== hypixelGuildID) {
@@ -73,11 +71,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -86,8 +84,8 @@ module.exports = {
if (guildID === hypixelGuildID) {
const GuildMembers = guild.members
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank
const GuildMembers = guild!.members
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid)!.rank
if (guildRank === "Guild Master") {
@@ -106,11 +104,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -133,11 +131,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -160,11 +158,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -187,11 +185,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -214,11 +212,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -241,11 +239,11 @@ module.exports = {
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: false })!
}
}]
})
@@ -253,4 +251,4 @@ module.exports = {
}
}
}
}
} as Command

View File

@@ -1,8 +1,9 @@
const { SlashCommandBuilder } = require("discord.js")
const { color, devMessage } = require("../../config/options.json")
const { getUUID, getIGN, getHeadURL, formatUuid } = require("../utils/utils.js")
import { SlashCommandBuilder } from "discord.js"
import { color, devMessage } from "../../config/options.json"
import { getUUID, getIGN, getHeadURL, formatUuid } from "../utils/Hypixel"
import { Command } from "../interfaces"
module.exports = {
export = {
name: "uuid",
description: "Get a player's UUID",
type: "slash",
@@ -15,28 +16,27 @@ module.exports = {
.addStringOption(option => option
.setName("ign")
.setDescription("Player's name")
.setRequired(true)
),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
.setRequired(true)),
async execute(interaction) {
await interaction.deferReply()
const ign = interaction.options.getString("ign")
const uuid = await getUUID(ign)
const ign = interaction.options.getString("ign")!
const uuid = await getUUID(ign) as string
const formattedUuid = formatUuid(uuid)
const newIgn = await getIGN(uuid)
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({ dynamic: true }) : interaction.user.avatarURL({ dynamic: true })
const footerIcon = interaction.guild ? interaction.guild.iconURL({ forceStatic: false }) : interaction.user.avatarURL({ forceStatic: false })
if (!uuid) {
interaction.editReply({
description: "That player doesn't exist!",
color: embedColor
embeds: [{
description: "That player doesn't exist!",
color: embedColor
}]
})
return
}
@@ -48,13 +48,13 @@ module.exports = {
"**Formatted UUID:** `" + formattedUuid + "`",
color: embedColor,
thumbnail: {
url: head
url: head!
},
footer: {
text: footerText + " | " + devMessage,
icon_url: footerIcon
icon_url: footerIcon || undefined
}
}]
})
}
}
} as Command

View File

@@ -1,11 +1,14 @@
const { SlashCommandBuilder } = require("discord.js")
const { getUUID, getPlayer, getGuild, getHeadURL } = require("../utils/utils.js")
const { color, hypixelGuildID, devMessage } = require("../../config/options.json")
const verify = require("../schemas/verifySchema.js")
const mongoose = require("mongoose")
const { gm, manager, moderator, beast, elite, member, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
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 { Command } from "../interfaces"
import verify = require("../schemas/verifySchema")
import { PlayerData } from "../interfaces/Player"
import { GuildData } from "../interfaces/Guild"
module.exports = {
export = {
name: "verify",
description: "Verify yourself as a member of the server.",
type: "slash",
@@ -22,14 +25,12 @@ module.exports = {
.setRequired(true))
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const user1 = interaction.user
const user = interaction.guild.members.cache.get(user1.id)
const ign = interaction.options.getString("ign")
const user = interaction.guild!.members.cache.get(user1.id)!
const ign = interaction.options.getString("ign")!
const embedColor = Number(color.replace("#", "0x"))
const verifyData = await verify.findOne({ userID: user.id })
@@ -74,7 +75,7 @@ module.exports = {
})
const head = await getHeadURL(ign)
const player = await getPlayer(uuid)
const player = await getPlayer(uuid) as PlayerData
if (!player) {
interaction.editReply({
embeds: [{
@@ -99,7 +100,7 @@ module.exports = {
}]
})
const linkedDiscord = player?.socialMedia?.links?.DISCORD || null
const linkedDiscord = player.socialMedia.links.DISCORD || null
if (!linkedDiscord) {
interaction.editReply({
embeds: [
@@ -133,8 +134,8 @@ module.exports = {
}]
})
const guild = await getGuild(uuid)
let guildID = ""
const guild = await getGuild(uuid) as GuildData | null
let guildID: string | null
if (!guild) {
guildID = null
} else {
@@ -143,8 +144,8 @@ module.exports = {
if (guildID === hypixelGuildID) {
const GuildMembers = guild.members
const guildRank = GuildMembers.find((member) => member.uuid === player.uuid).rank
const GuildMembers = guild!.members
const guildRank = GuildMembers.find((member) => member.uuid === player.uuid)!.rank
if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
await user.roles.add(gm, "Verification")
@@ -193,18 +194,18 @@ module.exports = {
await interaction.editReply({
embeds: [
{
title: interaction.guild.name,
title: interaction.guild!.name,
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
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.guild!.name + " | " + devMessage
}
}
]
})
}
}
} as Command

View File

@@ -1,9 +1,10 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
const { getIGN, getHeadURL } = require("../utils/utils.js")
const { color, devMessage } = require("../../config/options.json")
const verify = require("../schemas/verifySchema.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")
import { Command } from "../interfaces"
module.exports = {
export = {
name: "whois",
description: "Get's the ign of a user.",
type: "slash",
@@ -21,13 +22,11 @@ module.exports = {
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const user = interaction.options.getUser("user")
const user = interaction.options.getUser("user")!
const embedColor = Number(color.replace("#", "0x"))
const verifiedUser = await verify.findOne({ userID: user.id })
@@ -36,23 +35,23 @@ module.exports = {
return
}
const ign = await getIGN(verifiedUser.uuid)
const ign = await getIGN(verifiedUser.uuid) as string
const head = await getHeadURL(ign)
await interaction.editReply({
embeds: [{
title: interaction.guild.name,
title: interaction.guild!.name,
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({ dynamic: true })
text: interaction.guild!.name + " | " + devMessage,
icon_url: interaction.guild!.iconURL({ forceStatic: true }) || undefined
}
}]
})
}
}
} as Command