Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!305
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ApplicationCommandType, ContextMenuCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
|
||||
import { ApplicationCommandType, ContextMenuCommandBuilder, InteractionContextType, PermissionFlagsBits, userMention } from "discord.js"
|
||||
import { IContextMenu } from "~/interfaces"
|
||||
|
||||
export default {
|
||||
@@ -9,6 +9,7 @@ export default {
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Congratulate")
|
||||
.setType(ApplicationCommandType.Message)
|
||||
.setContexts(InteractionContextType.Guild)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
|
||||
|
||||
async execute({ interaction }) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApplicationCommandType, ContextMenuCommandBuilder, PermissionFlagsBits } from "discord.js"
|
||||
import { ApplicationCommandType, ContextMenuCommandBuilder, InteractionContextType, PermissionFlagsBits } from "discord.js"
|
||||
import { IContextMenu } from "~/interfaces"
|
||||
|
||||
export default {
|
||||
@@ -9,6 +9,7 @@ export default {
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Reset Nickname")
|
||||
.setType(ApplicationCommandType.User)
|
||||
.setContexts(InteractionContextType.Guild)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames),
|
||||
|
||||
async execute({ interaction }) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApplicationCommandType, ContextMenuCommandBuilder, PermissionFlagsBits, userMention } from "discord.js"
|
||||
import { ApplicationCommandType, ContextMenuCommandBuilder, InteractionContextType, PermissionFlagsBits, userMention } from "discord.js"
|
||||
import db from "src/drizzle/db.js"
|
||||
import { devMessage, embedColor, hypixelGuildID } from "~/config/options.js"
|
||||
import { waitingListRole } from "~/config/roles.js"
|
||||
@@ -14,6 +14,7 @@ export default {
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Update User")
|
||||
.setType(ApplicationCommandType.User)
|
||||
.setContexts(InteractionContextType.Guild)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||
|
||||
async execute({ interaction }) {
|
||||
@@ -51,7 +52,7 @@ export default {
|
||||
})
|
||||
|
||||
const ign = (await getIGN(verifyData.uuid)) as string
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -53,7 +53,7 @@ export default {
|
||||
}]
|
||||
})
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
|
||||
@@ -61,7 +61,7 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
const formattedIgn = await getIGN(uuid)
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
})
|
||||
|
||||
const ign = (await getIGN(verifyData.uuid)) as string
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -111,7 +111,7 @@ export default {
|
||||
responseGuildID = guild._id
|
||||
}
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
if (responseGuildID === hypixelGuildID) {
|
||||
const GuildMembers = guild!.members
|
||||
const guildRank = GuildMembers.find(member => member.uuid === player.uuid)!.rank
|
||||
|
||||
@@ -32,7 +32,7 @@ export default async function guildMember(interaction: ChatInputCommandInteracti
|
||||
}]
|
||||
})
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
await interaction.editReply({
|
||||
|
||||
@@ -38,7 +38,7 @@ export default async function beast(interaction: ChatInputCommandInteraction): P
|
||||
}]
|
||||
})
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
|
||||
@@ -58,7 +58,7 @@ export default {
|
||||
}
|
||||
|
||||
const ign = (await getIGN(verifyData.uuid)) as string
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
if (guildID !== hypixelGuildID) {
|
||||
const roles = roleManage("default")
|
||||
await user.roles.remove(roles.rolesToRemove, "User used the update command")
|
||||
|
||||
@@ -40,7 +40,7 @@ export default {
|
||||
|
||||
const formattedUuid = formatUuid(uuid)
|
||||
const newIgn = await getIGN(uuid) as string
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -76,7 +76,7 @@ export default {
|
||||
}]
|
||||
})
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
const player = (await getPlayer(uuid)) as IPlayerData
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
}
|
||||
|
||||
const ign = await getIGN(verifyData.uuid)
|
||||
const head = await getHeadURL(ign!)
|
||||
const head = getHeadURL(ign!)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -40,7 +40,7 @@ export default {
|
||||
}
|
||||
|
||||
const ign = (await getIGN(verifiedUser.uuid)) as string
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
}
|
||||
|
||||
const ign = player?.playername || ""
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
const rank2 = player.newPackageRank
|
||||
const monthlyRank = player.monthlyPackageRank
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export default {
|
||||
}]
|
||||
})
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const head = getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// dprint-ignore-file
|
||||
export interface IGuild {
|
||||
data: {
|
||||
success: boolean
|
||||
guild: IGuildData
|
||||
}
|
||||
}
|
||||
|
||||
export interface IGuildData {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// dprint-ignore-file
|
||||
export interface IPlayer {
|
||||
data: {
|
||||
success: boolean
|
||||
player: IPlayerData
|
||||
}
|
||||
}
|
||||
|
||||
export interface IPlayerData {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import fetch from "axios"
|
||||
import axios from "axios"
|
||||
import { IPlayer, IPlayerData } from "~/interfaces"
|
||||
import { IGuild, IGuildData } from "~/interfaces"
|
||||
import env from "~/utils/Env.js"
|
||||
@@ -10,25 +10,21 @@ const guild = "https://api.hypixel.net/guild"
|
||||
const minotar = "https://minotar.net/helm/"
|
||||
type GuildQueryType = "player" | "name" | "id"
|
||||
|
||||
type Profile = {
|
||||
data: {
|
||||
type UUIDData = {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
}
|
||||
|
||||
type Profile2 = {
|
||||
data: {
|
||||
type IGNData = {
|
||||
id: string
|
||||
name: string
|
||||
properties: { name: string, value: string }[]
|
||||
profileActions: []
|
||||
}
|
||||
}
|
||||
|
||||
async function getUUID(ign: string): Promise<string | null> {
|
||||
try {
|
||||
const req: Profile = await fetch(mojang + ign)
|
||||
const req = await axios.get<UUIDData>(mojang + ign)
|
||||
return req.data.id
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
@@ -38,7 +34,7 @@ async function getUUID(ign: string): Promise<string | null> {
|
||||
|
||||
async function getIGN(uuid: string): Promise<string | null> {
|
||||
try {
|
||||
const req: Profile2 = await fetch(mojanguuid + uuid)
|
||||
const req = await axios.get<IGNData>(mojanguuid + uuid)
|
||||
return req.data.name
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
@@ -47,7 +43,8 @@ async function getIGN(uuid: string): Promise<string | null> {
|
||||
}
|
||||
|
||||
async function getPlayer(uuid: string): Promise<IPlayerData | null> {
|
||||
const playerReq: IPlayer = await fetch(hypixel, {
|
||||
try {
|
||||
const req = await axios.get<IPlayer>(hypixel, {
|
||||
params: {
|
||||
uuid: uuid
|
||||
},
|
||||
@@ -55,18 +52,20 @@ async function getPlayer(uuid: string): Promise<IPlayerData | null> {
|
||||
"API-Key": apikey
|
||||
}
|
||||
})
|
||||
|
||||
if (!playerReq.data.player) {
|
||||
if (!req.data.player) {
|
||||
return null
|
||||
}
|
||||
|
||||
return playerReq.data.player
|
||||
return req.data.player
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function getGuild(query: string, type?: GuildQueryType): Promise<IGuildData | null> {
|
||||
const reqType = type ? type : "player"
|
||||
|
||||
const guildReq: IGuild = await fetch(guild, {
|
||||
async function getGuild(query: string, reqType: GuildQueryType = "player"): Promise<IGuildData | null> {
|
||||
try {
|
||||
const req = await axios.get<IGuild>(guild, {
|
||||
params: {
|
||||
[reqType]: query
|
||||
},
|
||||
@@ -75,14 +74,18 @@ async function getGuild(query: string, type?: GuildQueryType): Promise<IGuildDat
|
||||
}
|
||||
})
|
||||
|
||||
if (!guildReq.data.guild) {
|
||||
if (!req.data.guild) {
|
||||
return null
|
||||
}
|
||||
|
||||
return guildReq.data.guild
|
||||
return req.data.guild
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function getHeadURL(ign: string): Promise<string | null> {
|
||||
function getHeadURL(ign: string): string {
|
||||
return minotar + ign
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user