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