Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!215
This commit is contained in:
@@ -4,6 +4,7 @@ import { ContextMenu } from "interfaces"
|
|||||||
import verifySchema from "schemas/verifySchema"
|
import verifySchema from "schemas/verifySchema"
|
||||||
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel"
|
import { getGuild, getHeadURL, getIGN } from "utils/Hypixel"
|
||||||
import roleManage from "utils/functions/rolesmanage"
|
import roleManage from "utils/functions/rolesmanage"
|
||||||
|
import { waitingListRole } from "config/roles"
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
name: "Update User",
|
name: "Update User",
|
||||||
@@ -134,6 +135,10 @@ export = {
|
|||||||
replyRank = "Member"
|
replyRank = "Member"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user.roles.cache.has(waitingListRole)) {
|
||||||
|
await user.roles.remove(waitingListRole, "User was force updated.")
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
description: usermentioned + " was given the " + replyRank + " role.",
|
description: usermentioned + " was given the " + replyRank + " role.",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { hypixelGuildID, embedColor, devMessage } from "config/options"
|
|||||||
import verify from "schemas/verifySchema"
|
import verify from "schemas/verifySchema"
|
||||||
import { Command } from "interfaces"
|
import { Command } from "interfaces"
|
||||||
import roleManage from "utils/functions/rolesmanage"
|
import roleManage from "utils/functions/rolesmanage"
|
||||||
|
import { waitingListRole } from "config/roles"
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
name: "forceupdate",
|
name: "forceupdate",
|
||||||
@@ -140,6 +141,10 @@ export = {
|
|||||||
replyRank = "Member"
|
replyRank = "Member"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user.roles.cache.has(waitingListRole)) {
|
||||||
|
await user.roles.remove(waitingListRole, "User was force updated.")
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
description: usermentioned + " was given the the " + replyRank + " role.",
|
description: usermentioned + " was given the the " + replyRank + " role.",
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import { embedColor, devMessage } from "config/options"
|
|||||||
import { Command } from "interfaces"
|
import { Command } from "interfaces"
|
||||||
import help from "./staff/help"
|
import help from "./staff/help"
|
||||||
import beast from "./staff/beast"
|
import beast from "./staff/beast"
|
||||||
import updateDiscordRoles from "./staff/updatediscordroles"
|
import updateAll from "./staff/updateall"
|
||||||
import prune from "./staff/prune"
|
import prune from "./staff/prune"
|
||||||
|
import removeGuildRoles from "./staff/removeguildroles"
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
name: "staff",
|
name: "staff",
|
||||||
@@ -39,7 +40,12 @@ export = {
|
|||||||
)
|
)
|
||||||
.addSubcommand(subcommand =>
|
.addSubcommand(subcommand =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName("updatediscordroles")
|
.setName("removeguildroles")
|
||||||
|
.setDescription("Remove guild roles from non members")
|
||||||
|
)
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName("updateall")
|
||||||
.setDescription("Update the discord roles of all guild members")
|
.setDescription("Update the discord roles of all guild members")
|
||||||
)
|
)
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||||
@@ -63,8 +69,13 @@ export = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === "updatediscordroles") {
|
if (subcommand === "removeguildroles") {
|
||||||
updateDiscordRoles(interaction)
|
removeGuildRoles(interaction)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subcommand === "updateall") {
|
||||||
|
updateAll(interaction)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
63
src/commands/staff/removeguildroles.ts
Normal file
63
src/commands/staff/removeguildroles.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { embedColor, hypixelGuildID } from "config/options"
|
||||||
|
import { ChatInputCommandInteraction, GuildMember } from "discord.js"
|
||||||
|
import verify from "schemas/verifySchema"
|
||||||
|
import { GuildData } from "interfaces"
|
||||||
|
import env from "utils/Env"
|
||||||
|
import { getGuild } from "utils/Hypixel"
|
||||||
|
import roleManage from "utils/functions/rolesmanage"
|
||||||
|
|
||||||
|
export default async function removeGuildRoles(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||||
|
await interaction.deferReply()
|
||||||
|
|
||||||
|
const discordMember = interaction.member as GuildMember
|
||||||
|
|
||||||
|
if (discordMember.user.id !== env.prod.dev) {
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [{
|
||||||
|
description: "You do not have permission to use this command.",
|
||||||
|
color: embedColor
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const guildMembers = await interaction.guild!.members.fetch().then(
|
||||||
|
members => members.map(member => {
|
||||||
|
return {
|
||||||
|
id: member.id,
|
||||||
|
member: member
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const guildData = (await getGuild(hypixelGuildID, "id")) as GuildData
|
||||||
|
|
||||||
|
const hypixelGuildMembers = guildData.members.map(gmember => gmember.uuid)
|
||||||
|
|
||||||
|
const allVerifiedUsers = (await verify.find({})) as {
|
||||||
|
userID: string
|
||||||
|
uuid: string
|
||||||
|
}[]
|
||||||
|
|
||||||
|
const verifiedUsers = allVerifiedUsers.map(user => {
|
||||||
|
return {
|
||||||
|
userID: user.userID,
|
||||||
|
uuid: user.uuid
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const gmember of guildMembers) {
|
||||||
|
const gmemberuuid = verifiedUsers.find(user => user.userID === gmember.id)?.uuid
|
||||||
|
const roles = roleManage("default")
|
||||||
|
|
||||||
|
if (!gmemberuuid) {
|
||||||
|
await gmember.member.roles.remove(roles.rolesToRemove)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hypixelGuildMembers.includes(gmemberuuid)) {
|
||||||
|
await gmember.member.roles.remove(roles.rolesToRemove)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import env from "utils/Env"
|
|||||||
import { getGuild } from "utils/Hypixel"
|
import { getGuild } from "utils/Hypixel"
|
||||||
import { GuildData } from "interfaces"
|
import { GuildData } from "interfaces"
|
||||||
|
|
||||||
export default async function updateDiscordRoles(interaction: ChatInputCommandInteraction): Promise<void> {
|
export default async function updateAll(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const discordMember = interaction.member as GuildMember
|
const discordMember = interaction.member as GuildMember
|
||||||
@@ -72,7 +72,7 @@ export default async function updateDiscordRoles(interaction: ChatInputCommandIn
|
|||||||
await gmember.member.roles.remove(rolesToremove, "Updating all discord members")
|
await gmember.member.roles.remove(rolesToremove, "Updating all discord members")
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
await gmember.member.roles.add(verifyTick)
|
await gmember.member.roles.add(verifyTick, "Updating all discord members")
|
||||||
console.log(color(" Added verified tick to " + gmember.member.user.username, "lavender"))
|
console.log(color(" Added verified tick to " + gmember.member.user.username, "lavender"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4,6 +4,7 @@ import verify from "schemas/verifySchema"
|
|||||||
import { embedColor, hypixelGuildID, devMessage } from "config/options"
|
import { embedColor, hypixelGuildID, devMessage } from "config/options"
|
||||||
import roleManage from "utils/functions/rolesmanage"
|
import roleManage from "utils/functions/rolesmanage"
|
||||||
import { Command } from "interfaces"
|
import { Command } from "interfaces"
|
||||||
|
import { waitingListRole } from "config/roles"
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
name: "update",
|
name: "update",
|
||||||
@@ -123,6 +124,10 @@ export = {
|
|||||||
replyRank = "Member"
|
replyRank = "Member"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user.roles.cache.has(waitingListRole)) {
|
||||||
|
await user.roles.remove(waitingListRole, "User used the update command")
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
description: "Updated your roles to `" + replyRank + "`",
|
description: "Updated your roles to `" + replyRank + "`",
|
||||||
|
|||||||
Reference in New Issue
Block a user