Moved code to src folder
This commit is contained in:
36
src/commands-contextmenu/congratsmessage.js
Normal file
36
src/commands-contextmenu/congratsmessage.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "congratsmessage",
|
||||
description: "Congratulate a user.",
|
||||
type: "contextmenu",
|
||||
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Congratulate")
|
||||
.setType(ApplicationCommandType.Message)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
|
||||
|
||||
/** @param { import('discord.js').ContextMenuCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const { targetId } = interaction
|
||||
const message = await interaction.channel.messages.fetch(targetId)
|
||||
|
||||
if (!message) {
|
||||
return interaction.reply({ content: "That user does not exist.", ephemeral: true })
|
||||
}
|
||||
|
||||
const target = message.author
|
||||
|
||||
await message.reply({
|
||||
embeds: [{
|
||||
title: "Congratulations!",
|
||||
description: `GG to ${userMention(target.id)}!`,
|
||||
}]
|
||||
})
|
||||
await message.react("🎉")
|
||||
|
||||
await interaction.reply({ content: "Sent a congrats message", ephemeral: true })
|
||||
}
|
||||
}
|
||||
36
src/commands-contextmenu/resetnick.js
Normal file
36
src/commands-contextmenu/resetnick.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "resetnick",
|
||||
description: "Reset your nickname.",
|
||||
type: "contextmenu",
|
||||
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Reset Nickname")
|
||||
.setType(ApplicationCommandType.User)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames),
|
||||
|
||||
/** @param { import('discord.js').ContextMenuCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const { targetId } = interaction
|
||||
const target = await interaction.guild.members.fetch(targetId)
|
||||
|
||||
if (!target) {
|
||||
return interaction.reply({ content: "That user does not exist.", ephemeral: true })
|
||||
}
|
||||
|
||||
if (target.id === interaction.user.id) {
|
||||
return interaction.reply({ content: "You can't reset your own nickname.", ephemeral: true })
|
||||
}
|
||||
|
||||
if (!target.manageable) {
|
||||
return interaction.reply({ content: "I cannot reset that user's nickname.", ephemeral: true })
|
||||
}
|
||||
|
||||
await target.setNickname(target.user.username, "Reset by " + interaction.user.username + "#" + interaction.user.discriminator)
|
||||
|
||||
return interaction.reply({ content: `Reset ${target.user.username}'s nickname.`, ephemeral: true })
|
||||
}
|
||||
}
|
||||
33
src/commands-testing/dev-info.js
Normal file
33
src/commands-testing/dev-info.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "dev-info",
|
||||
description: "Test command for the bot.",
|
||||
type: "slash",
|
||||
|
||||
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),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
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 })
|
||||
}
|
||||
}
|
||||
103
src/commands/ban.js
Normal file
103
src/commands/ban.js
Normal file
@@ -0,0 +1,103 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
const { admin, helper } = require("../../config/roles.json")
|
||||
const { color } = require("../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "ban",
|
||||
description: "Ban a user",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("ban")
|
||||
.setDescription("Ban a user")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("User to ban")
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("reason")
|
||||
.setDescription("Reason for ban"))
|
||||
.addNumberOption(option =>
|
||||
option
|
||||
.setName("messagedeletiondays")
|
||||
.setDescription("Number of days to delete messages")
|
||||
.addChoices(
|
||||
{ name: "1 day", value: 1 },
|
||||
{ name: "2 days", value: 2 },
|
||||
{ name: "3 days", value: 3 },
|
||||
{ name: "4 days", value: 4 },
|
||||
{ name: "5 days", value: 5 },
|
||||
{ name: "6 days", value: 6 },
|
||||
{ name: "7 days", value: 7 }
|
||||
)
|
||||
)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute (interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const member = interaction.options.getMember("user")
|
||||
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 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 (member.id === interaction.applicationId) {
|
||||
await interaction.editReply("I cannot ban myself.")
|
||||
return
|
||||
}
|
||||
|
||||
if (member.id === interaction.guild.ownerId) {
|
||||
await interaction.editReply("I ban kick the server owner.")
|
||||
return
|
||||
}
|
||||
|
||||
if (member.id === mod.id) {
|
||||
return interaction.editReply("You cannot ban yourself.")
|
||||
}
|
||||
|
||||
if (memberRoles.includes(helper) || memberRoles.includes(admin)) {
|
||||
await interaction.editReply("I cannot ban a moderator.")
|
||||
return
|
||||
}
|
||||
|
||||
if (!member.bannable) {
|
||||
await interaction.editReply("I cannot ban this member.")
|
||||
return
|
||||
}
|
||||
|
||||
await member.ban({
|
||||
deleteMessageSeconds: messageDeletionDays * 86400,
|
||||
reason: reason + ` - ${mod.user.username}`
|
||||
})
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: "Member Banned",
|
||||
description: "**User:** " + userMention(member.user.id) + "\n" +
|
||||
"**Reason:** " + reason + "\n" +
|
||||
"**Moderator:** " + mod.user.username + "\n" +
|
||||
"**Messages Deleted:** " + messageDeletionDays + " days",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: member.user.id,
|
||||
icon_url: member.user.avatarURL({ dynamic: true })
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
200
src/commands/check.js
Normal file
200
src/commands/check.js
Normal file
@@ -0,0 +1,200 @@
|
||||
const { SlashCommandBuilder } = require("discord.js")
|
||||
const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require("../../config/reqs.json")
|
||||
const { color } = require("../../config/options.json")
|
||||
const { hypixelLevel, bedwarsLevel, skywarsLevel, getUUID, getPlayer, getGuild, getHeadURL } = require("../utils/utils.js")
|
||||
|
||||
module.exports = {
|
||||
name: "check",
|
||||
description: "Check a player's stats.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("check")
|
||||
.setDescription("Check a player's stats.")
|
||||
.addStringOption((option) => option.setName("ign")
|
||||
.setDescription("The player's IGN.")
|
||||
.setRequired(true))
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply({})
|
||||
|
||||
const ign = interaction.options.getString("ign")
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (!ign) {
|
||||
await interaction.editReply("Please provide a player's IGN.")
|
||||
return
|
||||
}
|
||||
|
||||
const uuid = await getUUID(ign)
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{ description: "That player doesn't exist.", color: embedColor }
|
||||
]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "That player hasn't played Hypixel before.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const rank2 = player.newPackageRank
|
||||
const monthlyRank = player.monthlyPackageRank
|
||||
|
||||
let rank = ""
|
||||
if (rank2 === "VIP") {
|
||||
rank = "[VIP] "
|
||||
} else if (rank2 === "VIP_PLUS") {
|
||||
rank = "[VIP+] "
|
||||
} else if (rank2 === "MVP") {
|
||||
rank = "[MVP] "
|
||||
} else if (rank2 === "MVP_PLUS" && monthlyRank === "NONE") {
|
||||
rank = "[MVP+] "
|
||||
} else if (rank2 === "MVP_PLUS" && monthlyRank === "SUPERSTAR") {
|
||||
rank = "[MVP++] "
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
let guildName = ""
|
||||
if (!guild) {
|
||||
guildName = "None"
|
||||
} else {
|
||||
guildName = guild.name
|
||||
}
|
||||
|
||||
let guildTag = ""
|
||||
if (!guild) {
|
||||
guildTag = ""
|
||||
} else if (!guild.tag) {
|
||||
guildTag = ""
|
||||
} else {
|
||||
guildTag = " [" + guild.tag + "]"
|
||||
}
|
||||
|
||||
//bedwars level
|
||||
const hsbwexp = player.stats.Bedwars.Experience
|
||||
const hsbwstars = bedwarsLevel(hsbwexp)
|
||||
// bedwars fkdr
|
||||
const hsbwfk = player.stats.Bedwars.final_kills_bedwars
|
||||
const hsbwfd = player.stats.Bedwars.final_deaths_bedwars
|
||||
const hsbwfkdr = hsbwfk / hsbwfd
|
||||
// bedwars wins
|
||||
const hsbwwins = player.stats.Bedwars.wins_bedwars
|
||||
// skywars level
|
||||
const hsswexp = player.stats.SkyWars.skywars_experience
|
||||
const hsswstars = skywarsLevel(hsswexp)
|
||||
// skywars kdr
|
||||
const hsswkills = player.stats.SkyWars.kills
|
||||
const hsswdeaths = player.stats.SkyWars.deaths
|
||||
const hsswkd = hsswkills / hsswdeaths
|
||||
//skywars wins
|
||||
const hsswwins = player.stats.SkyWars.wins
|
||||
// dueks kdr
|
||||
const hsduelskills = player.stats.Duels.kills
|
||||
const hsduelsdeaths = player.stats.Duels.deaths
|
||||
const hsduelskd = hsduelskills / hsduelsdeaths
|
||||
// duels wins
|
||||
const hsduelswins = player.stats.Duels.wins
|
||||
// duels wlr
|
||||
const hsduelslosses = player.stats.Duels.losses
|
||||
const hsduelswlr = hsduelswins / hsduelslosses
|
||||
// network level
|
||||
const hypixelExp = player.networkExp
|
||||
const level = hypixelLevel(hypixelExp)
|
||||
|
||||
let bwtitle = ""
|
||||
let swtitle = ""
|
||||
let duelstitle = ""
|
||||
if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
|
||||
bwtitle =
|
||||
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
|
||||
} else {
|
||||
bwtitle =
|
||||
"<a:check_a:1087808632172847134> This player meets the BedWars requirements."
|
||||
}
|
||||
|
||||
if (hsswstars < swstars) {
|
||||
swtitle =
|
||||
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
|
||||
} else {
|
||||
swtitle =
|
||||
"<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
|
||||
}
|
||||
|
||||
if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
|
||||
duelstitle =
|
||||
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
|
||||
} else {
|
||||
duelstitle =
|
||||
"<a:check_a:1087808632172847134> This player meets the Duels requirements."
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: rank + player.displayname + guildTag,
|
||||
description: "**Network Level:** `" +
|
||||
level.toFixed(2).toString() + "`\n" +
|
||||
"**Current Guild:** `" + guildName + "`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL()
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: bwtitle,
|
||||
value: "**➺ Stars:** `" +
|
||||
hsbwstars.toFixed(2).toString() + " / " +
|
||||
bwstars.toString() + "`\n" +
|
||||
"**➺ FKDR:** `" +
|
||||
hsbwfkdr.toFixed(2).toString() +
|
||||
" / " + bwfkdr.toString() + "`\n" +
|
||||
"**➺ Wins:** `" +
|
||||
hsbwwins.toString() + " / " +
|
||||
bwwins.toString() + "`"
|
||||
},
|
||||
{
|
||||
name: swtitle,
|
||||
value:
|
||||
"**➺ Stars:** `" +
|
||||
hsswstars.toFixed(2).toString() +
|
||||
" / " + swstars.toString() + "`\n" +
|
||||
"**➺ KDR:** `" +
|
||||
hsswkd.toFixed(2).toString() +
|
||||
"`\n" +
|
||||
"**➺ Wins:** `" +
|
||||
hsswwins.toString() + "`"
|
||||
},
|
||||
{
|
||||
name: duelstitle,
|
||||
value: "**➺ Wins:** `" +
|
||||
hsduelswins.toString() +
|
||||
" / " + duelswins.toString() + "`\n" +
|
||||
"**➺ WLR:** `" +
|
||||
hsduelswlr.toFixed(2).toString() +
|
||||
" / " + duelswlr.toString() + "`\n" +
|
||||
"**➺ KDR:** `" +
|
||||
hsduelskd.toFixed(2).toString() + "`"
|
||||
}
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
57
src/commands/clear.js
Normal file
57
src/commands/clear.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "clear",
|
||||
description: "Clears messages",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("clear")
|
||||
.setDescription("Clears messages")
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("amount")
|
||||
.setDescription("Amount of messages to clear")
|
||||
.setRequired(true))
|
||||
.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 embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (!amount || amount < 1 || amount > 100) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Please provide an amount of messages to clear",
|
||||
color: embedColor
|
||||
}],
|
||||
})
|
||||
}
|
||||
|
||||
channel.messages.fetch({ limit: amount }).then(async messages => {
|
||||
const messagesToDelete = messages.map(m => m)
|
||||
.filter(m =>
|
||||
m.pinned === false &&
|
||||
m.system === false &&
|
||||
m.createdTimestamp > Date.now() - 1209600000
|
||||
)
|
||||
|
||||
await channel.bulkDelete(messagesToDelete, true)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: `Deleted ${messages.size} messages`,
|
||||
color: embedColor
|
||||
}],
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
74
src/commands/config.js
Normal file
74
src/commands/config.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
const settings = require("../schemas/settingsSchema.js")
|
||||
const mongoose = require("mongoose")
|
||||
|
||||
module.exports = {
|
||||
name: "config",
|
||||
description: "Configure the bot",
|
||||
type: "slash",
|
||||
dev: true,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("config")
|
||||
.setDescription("Configure the bot")
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("setting")
|
||||
.setDescription("The setting to configure")
|
||||
.setChoices(
|
||||
{ name: "Staff Application status", value: "staffAppStatus" }
|
||||
)
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("value")
|
||||
.setDescription("The value to set")
|
||||
.setRequired(true)
|
||||
)
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const setting = interaction.options.getString("setting")
|
||||
const value = interaction.options.getString("value")
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
const settingsData = await settings.findOne({ name: setting })
|
||||
|
||||
if (!settingsData) {
|
||||
|
||||
const newSetting = new settings({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
name: setting,
|
||||
value: value
|
||||
})
|
||||
|
||||
await newSetting.save()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Successfully created `" + setting + "` with value `" + value + "`.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
} else {
|
||||
|
||||
await settings.findOneAndUpdate(
|
||||
{ name: setting },
|
||||
{ value: value }
|
||||
)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Successfully updated `" + setting + "` to value `" + value + "`.",
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
49
src/commands/devel.js
Normal file
49
src/commands/devel.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention, EmbedBuilder, ChannelType } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "admin",
|
||||
description: "Admin command.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("devel")
|
||||
.setDescription("Admin command.")
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("reload")
|
||||
.setDescription("Reload the bot."))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("listallverified")
|
||||
.setDescription("List all verified users."))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("purgereactions")
|
||||
.setDescription("Purge all reactions from a messages.")
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("count")
|
||||
.setDescription("Count of messages to purge reactions from.")))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const subcommand = interaction.options.getSubcommand()
|
||||
|
||||
if (subcommand === "reload") {
|
||||
|
||||
const { exec } = require("child_process")
|
||||
await interaction.reply({ content: "Reloading...", ephemeral: true })
|
||||
|
||||
exec("pm2 restart 0", async (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
await interaction.reply({ content: "Error while reloading: " + err, ephemeral: true })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
55
src/commands/forceunverify.js
Normal file
55
src/commands/forceunverify.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
const verify = require("../schemas/verifySchema.js")
|
||||
const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
|
||||
const removeThese = [gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember]
|
||||
|
||||
module.exports = {
|
||||
name: "forceunverify",
|
||||
description: "Force unverify a user",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("forceunverify")
|
||||
.setDescription("Force unverify a user")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user to force unverify")
|
||||
.setRequired(true))
|
||||
.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 embedColor = Number(color.replace("#", "0x"))
|
||||
const verifiedUser = await verify.findOne({ userID: member1.id })
|
||||
|
||||
if (!verifiedUser) {
|
||||
return interaction.reply({
|
||||
embeds: [{
|
||||
description: "This user is not verified",
|
||||
color: embedColor,
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
await verify.findOneAndDelete({ userID: member1.id })
|
||||
|
||||
await member.roles.remove(removeThese)
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [{
|
||||
description: "Successfully unverified " + userMention(member1.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
282
src/commands/forceupdate.js
Normal file
282
src/commands/forceupdate.js
Normal file
@@ -0,0 +1,282 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
const { getGuild, getHeadURL, getIGN } = require("../utils/utils.js")
|
||||
const { hypixelGuildID, color } = require("../../config/options.json")
|
||||
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
|
||||
const verify = require("../schemas/verifySchema.js")
|
||||
const removeThese = [gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff]
|
||||
|
||||
module.exports = {
|
||||
name: "forceupdate",
|
||||
description: "Force update the user",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("forceupdate")
|
||||
.setDescription("Force update the user")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user to force update")
|
||||
.setRequired(true))
|
||||
.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 embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const user1 = interaction.guild.members.cache.get(user.id)
|
||||
const roleManage = user1.roles
|
||||
|
||||
if (!verifyData) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "User is not verified.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const ign = await getIGN(verifyData.uuid)
|
||||
const head = await getHeadURL(ign)
|
||||
const guild = await getGuild(verifyData.uuid)
|
||||
|
||||
let responseGuildID = ""
|
||||
if (!guild) {
|
||||
responseGuildID = null
|
||||
} else {
|
||||
responseGuildID = guild._id
|
||||
}
|
||||
|
||||
if (responseGuildID !== hypixelGuildID) {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + " was given the the Default Member role.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
await roleManage.add(defaultMember)
|
||||
return
|
||||
}
|
||||
|
||||
if (responseGuildID === hypixelGuildID) {
|
||||
|
||||
const GuildMembers = guild.members
|
||||
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank
|
||||
|
||||
if (guildRank === "Guild Master") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User was force updated.")
|
||||
await roleManage.add(guildStaff, "User was force updated.")
|
||||
await roleManage.add(gm, "User was force updated.")
|
||||
await roleManage.add(defaultMember, "User was force updated.")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + "'s rank has been updated to `Guild Master`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
if (guildRank === "Manager") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User was force updated.")
|
||||
await roleManage.add(guildStaff, "User was force updated.")
|
||||
await roleManage.add(manager, "User was force updated.")
|
||||
await roleManage.add(defaultMember, "User was force updated.")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + "'s rank has been updated to `Manager`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
if (guildRank === "Moderator") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User was force updated.")
|
||||
await roleManage.add(guildStaff, "User was force updated.")
|
||||
await roleManage.add(moderator, "User was force updated.")
|
||||
await roleManage.add(defaultMember, "User was force updated.")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + "'s rank has been updated to `Moderator`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if (guildRank === "Beast") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User was force updated.")
|
||||
await roleManage.add(beast, "User was force updated.")
|
||||
await roleManage.add(defaultMember, "User was force updated.")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + "'s rank has been updated to `Beast`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (guildRank === "Elite") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User was force updated.")
|
||||
await roleManage.add(elite, "User was force updated.")
|
||||
await roleManage.add(defaultMember, "User was force updated.")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + "'s rank has been updated to `Elite`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (guildRank === "Member") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User was force updated.")
|
||||
await roleManage.add(member, "User was force updated.")
|
||||
await roleManage.add(defaultMember, "User was force updated.")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + "'s rank has been updated to `Member`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (guildRank === "Trial Member") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User was force updated.")
|
||||
await roleManage.add(trialmember, "User was force updated.")
|
||||
await roleManage.add(defaultMember, "User was force updated.")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: usermentioned + "'s rank has been updated to `Trial Member`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
170
src/commands/forceverify.js
Normal file
170
src/commands/forceverify.js
Normal file
@@ -0,0 +1,170 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
|
||||
const { getUUID, getPlayer, getGuild, getHeadURL } = require("../utils/utils.js")
|
||||
const { color, hypixelGuildID } = require("../../config/options.json")
|
||||
const verify = require("../schemas/verifySchema.js")
|
||||
const { mongoose } = require("mongoose")
|
||||
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: "forceverify",
|
||||
description: "Force verify a user.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("forceverify")
|
||||
.setDescription("Force verify a user.")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user to force verify."))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("ign")
|
||||
.setDescription("The user's in-game name."))
|
||||
.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 ign = interaction.options.getString("ign")
|
||||
const mod = interaction.user
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const verifyData = await verify.findOne({ userID: user.id })
|
||||
if (verifyData) {
|
||||
interaction.editReply("That user is already verified.")
|
||||
return
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
interaction.editReply("Please provide a user to force verify.\nThis can also mean the user is not in the server.")
|
||||
return
|
||||
}
|
||||
|
||||
if (!ign) {
|
||||
interaction.editReply("Please provide a player's IGN.")
|
||||
return
|
||||
}
|
||||
|
||||
let username = ""
|
||||
if (user1.discriminator == "0") {
|
||||
username = user1.username
|
||||
} else {
|
||||
username = user1.username + "#" + user1.discriminator
|
||||
}
|
||||
|
||||
let modName = ""
|
||||
if (mod.discriminator == "0") {
|
||||
modName = mod.username
|
||||
} else {
|
||||
modName = mod.username + "#" + mod.discriminator
|
||||
}
|
||||
|
||||
const uuid = await getUUID(ign)
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "<a:questionmark_pink:1130206038008803488> That player doesn't exist.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
let responseGuildID = ""
|
||||
if (!guild) {
|
||||
responseGuildID = null
|
||||
} else {
|
||||
responseGuildID = guild._id
|
||||
}
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
if (responseGuildID === hypixelGuildID) {
|
||||
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)
|
||||
await user.roles.add(guildRole, "User was force verified by " + modName)
|
||||
await user.roles.add(guildStaff, "User was force verified by " + modName)
|
||||
}
|
||||
|
||||
if (guildRank === "Manager") {
|
||||
await user.roles.add(manager, "User was force verified by " + modName)
|
||||
await user.roles.add(guildRole, "User was force verified by " + modName)
|
||||
await user.roles.add(guildStaff, "User was force verified by " + modName)
|
||||
}
|
||||
|
||||
if (guildRank === "Moderator") {
|
||||
await user.roles.add(moderator, "User was force verified by " + modName)
|
||||
await user.roles.add(guildRole, "User was force verified by " + modName)
|
||||
await user.roles.add(guildStaff, "User was force verified by " + modName)
|
||||
}
|
||||
|
||||
if (guildRank === "Beast") {
|
||||
await user.roles.add(beast, "User was force verified by " + modName)
|
||||
await user.roles.add(guildRole, "User was force verified by " + modName)
|
||||
}
|
||||
|
||||
if (guildRank === "Elite") {
|
||||
await user.roles.add(elite, "User was force verified by " + modName)
|
||||
await user.roles.add(guildRole, "User was force verified by " + modName)
|
||||
}
|
||||
|
||||
if (guildRank === "Member") {
|
||||
await user.roles.add(member, "User was force verified by " + modName)
|
||||
await user.roles.add(guildRole, "User was force verified by " + modName)
|
||||
}
|
||||
|
||||
if (guildRank === "Trial Member") {
|
||||
await user.roles.add(trialmember, "User was force verified by " + modName)
|
||||
await user.roles.add(guildRole, "User was force verified by " + modName)
|
||||
}
|
||||
}
|
||||
|
||||
await user.roles.add(defaultMember, "User was force verified by " + modName)
|
||||
|
||||
const newVerify = new verify({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: user.id,
|
||||
uuid: uuid
|
||||
})
|
||||
|
||||
await newVerify.save()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: interaction.guild.name,
|
||||
description: "You have successfully force verified `" + username + "` with the account `" + player.displayname + "`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
icon_url: interaction.guild.iconURL(),
|
||||
text: interaction.guild.name + " | Developed by Taken#0002"
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
68
src/commands/guild.js
Normal file
68
src/commands/guild.js
Normal file
@@ -0,0 +1,68 @@
|
||||
const { SlashCommandBuilder } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
const { guildMember } = require("./guild/member.js")
|
||||
const { guildInfo } = require("./guild/info.js")
|
||||
|
||||
module.exports = {
|
||||
name: "guild",
|
||||
description: "Subcommands for guilds",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("guild")
|
||||
.setDescription("Subcommands for guilds")
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("member")
|
||||
.setDescription("Get info about a guild memeber")
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("ign")
|
||||
.setDescription("The IGN of the player.")
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("info")
|
||||
.setDescription("Get info about a guild.")
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("ign")
|
||||
.setDescription("The IGN of a member.")
|
||||
.setRequired(true)
|
||||
)
|
||||
)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const subcommand = interaction.options.getSubcommand()
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (subcommand === "member") {
|
||||
await guildMember(interaction)
|
||||
return
|
||||
}
|
||||
|
||||
if (subcommand === "info") {
|
||||
await guildInfo(interaction)
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "This command is currently under development",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
103
src/commands/guild/info.js
Normal file
103
src/commands/guild/info.js
Normal file
@@ -0,0 +1,103 @@
|
||||
const { getUUID, getIGN, getPlayer, getGuild, guildLevel } = require("../../utils/utils.js")
|
||||
const { color } = require("../../../config/options.json")
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async function guildInfo(interaction) {
|
||||
|
||||
const ign = interaction.options.getString("ign")
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const uuid = await getUUID(ign)
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "That player doen't exist!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "That player has never joined the server!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
if (!guild) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "That player is not in a guild!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const guildName = guild.name
|
||||
const guildCreatedMS = guild.created
|
||||
const guildCreated = new Date(guildCreatedMS)
|
||||
const guildTag = guild.tag
|
||||
const guildExp = guild.exp
|
||||
const guildLvl = guildLevel(guildExp)
|
||||
const guildMembers = guild.members
|
||||
|
||||
const guildCreatedDate = guildCreated.getDate()
|
||||
const guildCreatedMonth = guildCreated.getMonth() + 1
|
||||
const guildCreatedYear = guildCreated.getFullYear()
|
||||
const guildCreatedHour = guildCreated.getHours()
|
||||
const guildCreatedMinute = guildCreated.getMinutes()
|
||||
const guildCreatedSecond = guildCreated.getSeconds()
|
||||
|
||||
const guildCreatedTime = guildCreatedDate + "." +
|
||||
guildCreatedMonth + "." +
|
||||
guildCreatedYear + " " +
|
||||
guildCreatedHour + ":" +
|
||||
guildCreatedMinute + ":" +
|
||||
guildCreatedSecond
|
||||
|
||||
const guildOwner = guildMembers.find((m) => m.rank === "Guild Master").uuid
|
||||
const guildOwnerName = await getIGN(guildOwner)
|
||||
const guildRanks = guild.ranks.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n")
|
||||
|
||||
const guildMembersDailyXP = Object.values(guildMembers).map((m) => m.expHistory[Object.keys(m.expHistory)[0]])
|
||||
const totalGuildMembersDailyXP = guildMembersDailyXP.reduce((a, b) => a + b, 0)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: "**Info on** " + guildName,
|
||||
description: "**Guild Name: **`" + guildName + "`\n" +
|
||||
"**Guild Tag: **`" + guildTag + "`\n" +
|
||||
"**Guild Level: **`" + guildLvl + "`\n" +
|
||||
"**Guild Owner: **`" + guildOwnerName + "`",
|
||||
fields: [
|
||||
{
|
||||
name: "**Guild Ranks**",
|
||||
value: guildRanks
|
||||
},
|
||||
{
|
||||
name: "**GEXP**",
|
||||
value: "**➺ Total weekly GEXP:** `" + totalGuildMembersDailyXP + "`"
|
||||
},
|
||||
{
|
||||
name: "**Guild Created**",
|
||||
value: "**➺ **`" + guildCreatedTime + "`"
|
||||
}
|
||||
],
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { guildInfo }
|
||||
148
src/commands/guild/member.js
Normal file
148
src/commands/guild/member.js
Normal file
@@ -0,0 +1,148 @@
|
||||
const { getUUID, getPlayer, getGuild, getHeadURL } = require("../../utils/utils.js")
|
||||
const { color } = require("../../../config/options.json")
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async function guildMember(interaction) {
|
||||
const ign = interaction.options.getString("ign")
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const uuid = await getUUID(ign)
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "This user does not exist",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "This user never logged on to hypixel",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head,
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
const serverRank = player.newPackageRank
|
||||
const monthlyRank = player.monthlyPackageRank
|
||||
const displayName = player.displayname
|
||||
|
||||
let rank = ""
|
||||
if (serverRank === "VIP") {
|
||||
rank = "[VIP] "
|
||||
} else if (serverRank === "VIP_PLUS") {
|
||||
rank = "[VIP+] "
|
||||
} else if (serverRank === "MVP") {
|
||||
rank = "[MVP] "
|
||||
} else if (serverRank === "MVP_PLUS" && monthlyRank === "NONE") {
|
||||
rank = "[MVP+] "
|
||||
} else if (serverRank === "MVP_PLUS" && monthlyRank === "SUPERSTAR") {
|
||||
rank = "[MVP++] "
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
if (!guild) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "This user is not in a guild",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head,
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
const guildName = guild.name
|
||||
const guildTag = " [" + guild.tag + "]" ?? ""
|
||||
|
||||
const guildMembers = guild.members
|
||||
const guildMember = guildMembers.find((member) => member.uuid === uuid)
|
||||
const guildRank = guildMember.rank
|
||||
const memberGexp = guildMember.expHistory
|
||||
const allDaysGexp = Object.keys(memberGexp).map((key) => {
|
||||
return "**➺ " + key + ":** " + "`" + memberGexp[key] + "`" + "\n"
|
||||
})
|
||||
const expValue = allDaysGexp.join("")
|
||||
const totalWeeklyGexp = Object.values(memberGexp).reduce((a, b) => a + b, 0)
|
||||
const averageWeeklyGexp = Math.round(totalWeeklyGexp / 7)
|
||||
|
||||
const guildMemberJoinMS = guildMember.joined
|
||||
const guildMemberJoinTime = new Date(guildMemberJoinMS)
|
||||
const guildMemberJoinDate = guildMemberJoinTime.getDate()
|
||||
const guildMemberJoinMonth = guildMemberJoinTime.getMonth() + 1
|
||||
const guildMemberJoinYear = guildMemberJoinTime.getFullYear()
|
||||
const guildMemberJoinHours = guildMemberJoinTime.getHours()
|
||||
const guildMemberJoinMinutes = guildMemberJoinTime.getMinutes()
|
||||
const guildMemberJoinSeconds = guildMemberJoinTime.getSeconds()
|
||||
|
||||
const guildMemberJoin =
|
||||
guildMemberJoinDate + "." +
|
||||
guildMemberJoinMonth + "." +
|
||||
guildMemberJoinYear + " " +
|
||||
guildMemberJoinHours + ":" +
|
||||
guildMemberJoinMinutes + ":" +
|
||||
guildMemberJoinSeconds
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
title: rank + displayName + guildTag,
|
||||
description: "**Guild Name:** `" + guildName + "`\n" +
|
||||
"**Guild Rank:** `" + guildRank + "`\n",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: "**Daily GEXP**",
|
||||
value: expValue,
|
||||
},
|
||||
{
|
||||
name: "**Weekly GEXP**",
|
||||
value: "**➺ Total:** `" + totalWeeklyGexp + "`\n" +
|
||||
"**➺ Daily avarage:** `" + averageWeeklyGexp + "`",
|
||||
},
|
||||
{
|
||||
name: "**Join date**",
|
||||
value: "**➺ **`" + guildMemberJoin + "`",
|
||||
},
|
||||
],
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
module.exports = { guildMember }
|
||||
56
src/commands/help.js
Normal file
56
src/commands/help.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const { SlashCommandBuilder, ChannelType } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "help",
|
||||
description: "Help command",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("help")
|
||||
.setDescription("Help command")
|
||||
.setDMPermission(true),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: "Commands",
|
||||
description: "List of commands",
|
||||
fields: [
|
||||
{
|
||||
name: "/check",
|
||||
value: "Check the stats of a player"
|
||||
},
|
||||
{
|
||||
name: "/reqs",
|
||||
value: "Check the requirements of the guild"
|
||||
},
|
||||
{
|
||||
name: "/update",
|
||||
value: "Update's your roles"
|
||||
},
|
||||
{
|
||||
name: "/help",
|
||||
value: "Shows this message"
|
||||
}
|
||||
],
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: interaction.guild.iconURL({ dynamic: true })
|
||||
},
|
||||
footer: {
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
text: interaction.guild.name + " | Developed by: @Taken#0001"
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
84
src/commands/kick.js
Normal file
84
src/commands/kick.js
Normal file
@@ -0,0 +1,84 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
const { admin, helper } = require("../../config/roles.json")
|
||||
const { color } = require("../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "kick",
|
||||
description: "Kick a member from the server.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("kick")
|
||||
.setDescription("Kick a member from the server.")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("member")
|
||||
.setDescription("Member to kick.")
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("reason")
|
||||
.setDescription("Reason for kicking the member."))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const member = interaction.options.getMember("member")
|
||||
const reason = interaction.options.getString("reason") ?? "No reason provided."
|
||||
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.")
|
||||
return
|
||||
}
|
||||
|
||||
if (member.id === interaction.applicationId) {
|
||||
await interaction.editReply("I cannot kick myself.")
|
||||
return
|
||||
}
|
||||
|
||||
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.")
|
||||
}
|
||||
|
||||
if (memberRoles.includes(helper) || memberRoles.includes(admin)) {
|
||||
await interaction.editReply("I cannot kick a moderator.")
|
||||
return
|
||||
}
|
||||
|
||||
if (!member.kickable) {
|
||||
await interaction.editReply("I cannot kick this member.")
|
||||
return
|
||||
}
|
||||
|
||||
await member.kick(reason + ` - ${mod.user.username}`)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: "Member Kicked",
|
||||
description: "**User:** " + userMention(member.user.id) + "\n" +
|
||||
"**Reason:** " + reason + "\n" +
|
||||
"**Moderator:** " + mod.user.username,
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: member.user.id,
|
||||
icon_url: member.user.avatarURL({ dynamic: true })
|
||||
},
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
62
src/commands/remove.js
Normal file
62
src/commands/remove.js
Normal file
@@ -0,0 +1,62 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
const { waitinglistSchema } = require("../schemas/waitinglistSchema.js")
|
||||
|
||||
module.exports = {
|
||||
name: "remove",
|
||||
description: "Remove a person on the waiting list.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("remove")
|
||||
.setDescription("Remove a person on the waiting list.")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user to remove.")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("reason")
|
||||
.setDescription("The reason for removing the user.")
|
||||
.setRequired(false)
|
||||
)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
interaction.deferReply()
|
||||
|
||||
const user = interaction.options.getUser("user")
|
||||
const reason = interaction.options.getString("reason") ?? "No reason provided."
|
||||
const mod = interaction.user
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const waitinglist = await waitinglistSchema.findOne({ UserID: user.id })
|
||||
|
||||
if (!waitinglist) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: userMention(user.id) + " is not on the waiting list.",
|
||||
color: color
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await waitinglistSchema.findOneAndDelete({ UserID: user.id })
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: userMention(user.id) + " has been removed from the waiting list.\n" +
|
||||
"**Reason:** `" + reason + "`\n" +
|
||||
"**Moderator:** " + userMention(mod.id),
|
||||
color: embedColor,
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
53
src/commands/reqs.js
Normal file
53
src/commands/reqs.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const { SlashCommandBuilder } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require("../../config/reqs.json")
|
||||
|
||||
module.exports = {
|
||||
name: "reqs",
|
||||
description: "Displays the requirements for the guild.",
|
||||
type: "slash",
|
||||
data: new SlashCommandBuilder()
|
||||
.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"))
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: "Requirements",
|
||||
description: "**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: interaction.guild.iconURL()
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: "**Bedwars**",
|
||||
value: "**Stars:** `" + bwstars.toString() +
|
||||
"`\n**Wins:** `" + bwwins.toString() +
|
||||
"`\n**FKDR:** `" + bwfkdr.toString() + "`"
|
||||
},
|
||||
{
|
||||
name: "**Skywars**",
|
||||
value: "**Stars:** `" + swstars.toString() + "`"
|
||||
},
|
||||
{
|
||||
name: "**Duels**",
|
||||
value: "**Wins:** `" + duelswins.toString() +
|
||||
"`\n**WLR:** `" + duelswlr.toString() + "`"
|
||||
}
|
||||
],
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by: @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL()
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
59
src/commands/send.js
Normal file
59
src/commands/send.js
Normal file
@@ -0,0 +1,59 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "send",
|
||||
description: "Send a message to a channel.",
|
||||
type: "slash",
|
||||
|
||||
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: "Developed by @Taken#0002"
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
41
src/commands/setnick.js
Normal file
41
src/commands/setnick.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "setnick",
|
||||
description: "Set your nickname",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("setnick")
|
||||
.setDescription("Set your nickname")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user to set the nickname for")
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("nickname")
|
||||
.setDescription("The nickname to set")
|
||||
.setRequired(true))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const user = interaction.options.getUser("user")
|
||||
const nickname = interaction.options.getString("nickname")
|
||||
const member = await interaction.guild.members.fetch(user.id)
|
||||
|
||||
if (!member.manageable) {
|
||||
return interaction.reply({ content: "I cannot set the nickname for this user!", ephemeral: true })
|
||||
}
|
||||
|
||||
await member.setNickname(nickname, `Set by ${interaction.user.tag}`)
|
||||
|
||||
await interaction.reply({ content: "Set the nickname of " + userMention(member.id) + " to " + nickname, ephemeral: true })
|
||||
|
||||
}
|
||||
}
|
||||
222
src/commands/setup.js
Normal file
222
src/commands/setup.js
Normal file
@@ -0,0 +1,222 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "setup",
|
||||
description: "Used for setup of the bot.",
|
||||
type: "slash",
|
||||
dev: true,
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("setup")
|
||||
.setDescription("Configure the bot.")
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName("sendguildapplication")
|
||||
.setDescription("Send the application message to a channel.")
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription("The channel to send the application to.")
|
||||
.setRequired(true))
|
||||
)
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName("sendstaffapplication")
|
||||
.setDescription("Send the application message to a channel.")
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription("The channel to send the application to.")
|
||||
.setRequired(true)))
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName("sendverfiymessage")
|
||||
.setDescription("Send the verfiy message to a channel.")
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription("The channel to send the verfiy message to.")
|
||||
.setRequired(true)))
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName("sendwaitinglistmessage")
|
||||
.setDescription("Send the waiting list message to a channel.")
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription("The channel to send the waiting list message to.")
|
||||
.setRequired(true)))
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName("sendinactivityapplication")
|
||||
.setDescription("Send the application message to a channel.")
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription("The channel to send the application to.")
|
||||
.setRequired(true)))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
const user = interaction.user
|
||||
const guild = interaction.guild
|
||||
const subcommand = interaction.options.getSubcommand()
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
|
||||
if (subcommand === "sendguildapplication") {
|
||||
const channel = interaction.options.getChannel("channel")
|
||||
|
||||
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 + " | Developed by @Taken#0002",
|
||||
iconURL: interaction.guild.iconURL({ dynamic: true })
|
||||
},
|
||||
thumbnail: {
|
||||
url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}
|
||||
],
|
||||
components: [
|
||||
new ActionRowBuilder()
|
||||
.addComponents(new ButtonBuilder()
|
||||
.setCustomId("guildapply")
|
||||
.setLabel("Apply")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setEmoji({ name: "✅" }))
|
||||
]
|
||||
})
|
||||
await interaction.reply({ content: "Message sent", ephemeral: true })
|
||||
}
|
||||
|
||||
if (subcommand === "sendstaffapplication") {
|
||||
const channel = interaction.options.getChannel("channel")
|
||||
|
||||
await channel.send({
|
||||
embeds: [
|
||||
{
|
||||
title: "Staff Application",
|
||||
description: "You can apply for the staff team by clicking the button below.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
iconURL: interaction.guild.iconURL({ dynamic: true })
|
||||
},
|
||||
thumbnail: {
|
||||
url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}
|
||||
],
|
||||
components: [
|
||||
new ActionRowBuilder()
|
||||
.addComponents(new ButtonBuilder()
|
||||
.setCustomId("staffapply")
|
||||
.setLabel("Apply")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setEmoji({ name: "✅" }))
|
||||
]
|
||||
})
|
||||
|
||||
await interaction.reply({ content: "Message sent", ephemeral: true })
|
||||
}
|
||||
|
||||
if (subcommand === "sendinactivityapplication") {
|
||||
const channel = interaction.options.getChannel("channel")
|
||||
|
||||
await channel.send({
|
||||
embeds: [
|
||||
{
|
||||
title: "Inactivity Log",
|
||||
description: "You can send an inactivity log by clicking the button below.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
iconURL: interaction.guild.iconURL({ dynamic: true })
|
||||
},
|
||||
thumbnail: {
|
||||
url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}
|
||||
],
|
||||
components: [
|
||||
new ActionRowBuilder()
|
||||
.addComponents(new ButtonBuilder()
|
||||
.setCustomId("guildinactivitylog")
|
||||
.setLabel("Submit")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setEmoji({ name: "✅" }))
|
||||
]
|
||||
})
|
||||
|
||||
await interaction.reply({ content: "Message sent", ephemeral: true })
|
||||
}
|
||||
|
||||
if (subcommand === "sendverfiymessage") {
|
||||
const channel = interaction.options.getChannel("channel")
|
||||
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
title: "Verification",
|
||||
description: "You can verify by clicking the button below.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
iconURL: interaction.guild.iconURL({ dynamic: true })
|
||||
},
|
||||
thumbnail: {
|
||||
url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}],
|
||||
components: [
|
||||
new ActionRowBuilder()
|
||||
.addComponents(new ButtonBuilder()
|
||||
.setCustomId("verifybutton")
|
||||
.setLabel("Verify")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setEmoji({ name: "✅" }))
|
||||
]
|
||||
})
|
||||
await interaction.reply({ content: "Message sent", ephemeral: true })
|
||||
|
||||
}
|
||||
|
||||
if (subcommand === "sendwaitinglistmessage") {
|
||||
const channel = interaction.options.getChannel("channel")
|
||||
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
title: "Waiting List",
|
||||
description: "The people below were accepted into the guild\n" +
|
||||
"Try to invite them in order.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
iconURL: interaction.guild.iconURL({ dynamic: true })
|
||||
},
|
||||
thumbnail: {
|
||||
url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}],
|
||||
components: [
|
||||
new ActionRowBuilder()
|
||||
.addComponents(new ButtonBuilder()
|
||||
.setCustomId("waitinglistupdate")
|
||||
.setLabel("Update")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setEmoji({ name: "🔄" }))
|
||||
]
|
||||
})
|
||||
await interaction.reply({ content: "Message sent", ephemeral: true })
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
61
src/commands/slowmode.js
Normal file
61
src/commands/slowmode.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "slowmode",
|
||||
description: "Set the slowmode of a channel.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("slowmode")
|
||||
.setDescription("Set the slowmode of a channel.")
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("seconds")
|
||||
.setDescription("The amount of seconds to set the slowmode to."))
|
||||
.addChannelOption(option =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription("The channel to set the slowmode of."))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply({ ephermeral: true })
|
||||
|
||||
const seconds = interaction.options.getInteger("seconds") ?? 5
|
||||
const channel = interaction.options.getChannel("channel") ?? interaction.channel
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (seconds > 21600) {
|
||||
await channel.setRateLimitPerUser(21600)
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: `Set the slowmode of ${channel} to 21600 seconds.`,
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by: @Taken#0001",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: `Set the slowmode of ${channel} to ${seconds} seconds.`,
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by: @Taken#0001",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
await channel.setRateLimitPerUser(seconds)
|
||||
|
||||
}
|
||||
}
|
||||
274
src/commands/update.js
Normal file
274
src/commands/update.js
Normal file
@@ -0,0 +1,274 @@
|
||||
const { SlashCommandBuilder } = require("discord.js")
|
||||
const { getGuild, getIGN, getHeadURL } = require("../utils/utils.js")
|
||||
const verify = require("../schemas/verifySchema.js")
|
||||
const { color, hypixelGuildID } = require("../../config/options.json")
|
||||
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
|
||||
const removeThese = [gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff]
|
||||
|
||||
module.exports = {
|
||||
name: "update",
|
||||
description: "Update your guild rank.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("update")
|
||||
.setDescription("Update your guild rank.")
|
||||
.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 roleManage = user.roles
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (!verifyData) {
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "You are not verified. Please run `/verify` to verify yourself",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const guild = await getGuild(verifyData.uuid)
|
||||
let guildID = ""
|
||||
if (!guild) {
|
||||
guildID = null
|
||||
} else {
|
||||
guildID = guild._id
|
||||
}
|
||||
|
||||
const ign = await getIGN(verifyData.uuid)
|
||||
const head = await getHeadURL(ign)
|
||||
if (guildID !== hypixelGuildID) {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Updated your roles to `Default Member`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (guildID === hypixelGuildID) {
|
||||
|
||||
const GuildMembers = guild.members
|
||||
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank
|
||||
|
||||
if (guildRank === "Guild Master") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User used the update command")
|
||||
await roleManage.add(guildStaff, "User used the update command")
|
||||
await roleManage.add(gm, "User used the update command")
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Your rank has been updated to `Guild Master`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
if (guildRank === "Manager") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User used the update command")
|
||||
await roleManage.add(guildStaff, "User used the update command")
|
||||
await roleManage.add(manager, "User used the update command")
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Your rank has been updated to `Manager`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
if (guildRank === "Moderator") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User used the update command")
|
||||
await roleManage.add(guildStaff, "User used the update command")
|
||||
await roleManage.add(moderator, "User used the update command")
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Your rank has been updated to `Moderator`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if (guildRank === "Beast") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User used the update command")
|
||||
await roleManage.add(beast, "User used the update command")
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Your rank has been updated to `Beast`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (guildRank === "Elite") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User used the update command")
|
||||
await roleManage.add(elite, "User used the update command")
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Your rank has been updated to `Elite`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (guildRank === "Member") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User used the update command")
|
||||
await roleManage.add(member, "User used the update command")
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Your rank has been updated to `Member`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (guildRank === "Trial Member") {
|
||||
|
||||
for (let i = 0; i < removeThese.length; i++) {
|
||||
await roleManage.remove(removeThese[i], "Auto role removal. (Update)")
|
||||
}
|
||||
|
||||
await roleManage.add(guildRole, "User used the update command")
|
||||
await roleManage.add(trialmember, "User used the update command")
|
||||
await roleManage.add(defaultMember, "User used the update command")
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
description: "Your rank has been updated to `Trial Member`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
src/commands/uuid.js
Normal file
56
src/commands/uuid.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const { SlashCommandBuilder } = require("discord.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
const { getUUID, getIGN, getHeadURL, formatUuid } = require("../utils/utils.js")
|
||||
|
||||
module.exports = {
|
||||
name: "uuid",
|
||||
description: "Get a player's UUID",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("uuid")
|
||||
.setDescription("Get a player's UUID")
|
||||
.addStringOption(option => option
|
||||
.setName("ign")
|
||||
.setDescription("Player's name")
|
||||
.setRequired(true)
|
||||
),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const ign = interaction.options.getString("ign")
|
||||
const uuid = await getUUID(ign)
|
||||
const formattedUuid = formatUuid(uuid)
|
||||
const newIgn = await getIGN(uuid)
|
||||
const head = await getHeadURL(ign)
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
description: "That player doesn't exist!",
|
||||
color: embedColor
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: newIgn,
|
||||
description: "**UUID:** `" + uuid + "`\n" +
|
||||
"**Formatted UUID:** `" + formattedUuid + "`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by taken.lua",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
197
src/commands/verify.js
Normal file
197
src/commands/verify.js
Normal file
@@ -0,0 +1,197 @@
|
||||
const { SlashCommandBuilder } = require("discord.js")
|
||||
const { getUUID, getPlayer, getGuild, getHeadURL } = require("../utils/utils.js")
|
||||
const { color, hypixelGuildID } = require("../../config/options.json")
|
||||
const verify = require("../schemas/verifySchema.js")
|
||||
const mongoose = require("mongoose")
|
||||
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require("../../config/roles.json")
|
||||
|
||||
module.exports = {
|
||||
name: "verify",
|
||||
description: "Verify yourself as a member of the server.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("verify")
|
||||
.setDescription("Verify yourself as a member of the server.")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("ign")
|
||||
.setDescription("Your in-game name."))
|
||||
.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 embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const verifyData = await verify.findOne({ userID: user.id })
|
||||
if (verifyData) {
|
||||
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.")
|
||||
return
|
||||
}
|
||||
|
||||
if (!ign) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "<a:cross_a:1087808606897983539> Please provide your in-game name.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const uuid = await getUUID(ign)
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "<a:questionmark_pink:1130206038008803488> That player does not exist.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const head = await getHeadURL(ign)
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let username = ""
|
||||
if (user1.discriminator === "0") {
|
||||
username = user1.username
|
||||
} else {
|
||||
username = user1.username + "#" + user1.discriminator
|
||||
}
|
||||
|
||||
if (!player.socialMedia) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + stats.data.player.displayname + "`.\n\n" +
|
||||
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!player.socialMedia.links.DISCORD) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + stats.data.player.displayname + "`.\n\n" +
|
||||
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const linkedDiscord = player.socialMedia.links.DISCORD
|
||||
|
||||
if (linkedDiscord !== username) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "<a:cross_a:1087808606897983539> The Discord account linked to `" + stats.data.player.displayname + "` is currently `" + linkedDiscord + "`\n\n" +
|
||||
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**",
|
||||
color: embedColor
|
||||
}
|
||||
]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
let guildID = ""
|
||||
if (!guild) {
|
||||
guildID = null
|
||||
} else {
|
||||
guildID = guild._id
|
||||
}
|
||||
|
||||
if (guildID === hypixelGuildID) {
|
||||
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")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
await user.roles.add(guildStaff, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Manager" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(manager, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
await user.roles.add(guildStaff, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Moderator" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(moderator, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
await user.roles.add(guildStaff, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Beast" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(beast, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Elite" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(elite, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Member" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(member, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
}
|
||||
|
||||
if (guildRank === "Trial Member" && guildID === hypixelGuildID) {
|
||||
await user.roles.add(trialmember, "Verification")
|
||||
await user.roles.add(guildRole, "Verification")
|
||||
}
|
||||
}
|
||||
|
||||
await user.roles.add(defaultMember, "Verification")
|
||||
|
||||
const newVerify = new verify({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: user.id,
|
||||
uuid: uuid
|
||||
})
|
||||
|
||||
await newVerify.save()
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
title: interaction.guild.name,
|
||||
description: "You have successfully verified `" + username + "` with the account `" + player.displayname + "`.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
icon_url: interaction.guild.iconURL(),
|
||||
text: interaction.guild.name + " | Developed by Taken#0002"
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
56
src/commands/whois.js
Normal file
56
src/commands/whois.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
const { getIGN, getHeadURL } = require("../utils/utils.js")
|
||||
const { color } = require("../../config/options.json")
|
||||
const verify = require("../schemas/verifySchema.js")
|
||||
|
||||
module.exports = {
|
||||
name: "whois",
|
||||
description: "Get's the ign of a user.",
|
||||
type: "slash",
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("whois")
|
||||
.setDescription("Get's the ign of a user.")
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user to get the ign of.")
|
||||
.setRequired(true))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.options.getUser("user")
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const verifiedUser = await verify.findOne({ userID: user.id })
|
||||
if (!verifiedUser) {
|
||||
interaction.editReply({ content: "This user has not verified their account." })
|
||||
return
|
||||
}
|
||||
|
||||
const ign = await getIGN(verifiedUser.uuid)
|
||||
const head = await getHeadURL(ign)
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: interaction.guild.name,
|
||||
description: "**User:** " + userMention(user.id) + "\n**IGN:** " + ign,
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: head
|
||||
},
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by: @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
173
src/events/buttons/checkstats.js
Normal file
173
src/events/buttons/checkstats.js
Normal file
@@ -0,0 +1,173 @@
|
||||
const { color } = require("../../../config/options.json")
|
||||
const guildapp = require("../../schemas/guildAppSchema.js")
|
||||
const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require("../../../config/reqs.json")
|
||||
const { hypixelLevel, bedwarsLevel, skywarsLevel, getPlayer, getGuild, getHeadURL } = require("../../utils/utils.js")
|
||||
|
||||
module.exports = {
|
||||
name: "checkstats",
|
||||
description: "Check your stats.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer.text.split(" ")[1]
|
||||
const guildappdata = await guildapp.findOne({ userID: applicantId })
|
||||
const uuid = guildappdata.uuid
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
if (!player) {
|
||||
interaction.editReply({
|
||||
embeds: [{
|
||||
description: "That player hasn't played Hypixel before.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const ign = player.playername
|
||||
const head = await getHeadURL(ign)
|
||||
const rank2 = player.newPackageRank
|
||||
const monthlyRank = player.monthlyPackageRank
|
||||
|
||||
let rank = ""
|
||||
if (rank2 === "VIP") {
|
||||
rank = "[VIP] "
|
||||
} else if (rank2 === "VIP_PLUS") {
|
||||
rank = "[VIP+] "
|
||||
} else if (rank2 === "MVP") {
|
||||
rank = "[MVP] "
|
||||
} else if (rank2 === "MVP_PLUS" && monthlyRank === "NONE") {
|
||||
rank = "[MVP+] "
|
||||
} else if (rank2 === "MVP_PLUS" && monthlyRank === "SUPERSTAR") {
|
||||
rank = "[MVP++] "
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
let guildName = ""
|
||||
if (!guild) {
|
||||
guildName = "None"
|
||||
} else {
|
||||
guildName = guild.name
|
||||
}
|
||||
|
||||
let guildTag = ""
|
||||
if (!guild) {
|
||||
guildTag = ""
|
||||
} else if (!guild.tag) {
|
||||
guildTag = ""
|
||||
} else {
|
||||
guildTag = " [" + guild.tag + "]"
|
||||
}
|
||||
|
||||
//bedwars level
|
||||
const hsbwexp = player.stats.Bedwars.Experience
|
||||
const hsbwstars = bedwarsLevel(hsbwexp)
|
||||
// bedwars fkdr
|
||||
const hsbwfk = player.stats.Bedwars.final_kills_bedwars
|
||||
const hsbwfd = player.stats.Bedwars.final_deaths_bedwars
|
||||
const hsbwfkdr = hsbwfk / hsbwfd
|
||||
// bedwars wins
|
||||
const hsbwwins = player.stats.Bedwars.wins_bedwars
|
||||
// skywars level
|
||||
const hsswexp = player.stats.SkyWars.skywars_experience
|
||||
const hsswstars = skywarsLevel(hsswexp)
|
||||
// skywars kdr
|
||||
const hsswkills = player.stats.SkyWars.kills
|
||||
const hsswdeaths = player.stats.SkyWars.deaths
|
||||
const hsswkd = hsswkills / hsswdeaths
|
||||
//skywars wins
|
||||
const hsswwins = player.stats.SkyWars.wins
|
||||
// dueks kdr
|
||||
const hsduelskills = player.stats.Duels.kills
|
||||
const hsduelsdeaths = player.stats.Duels.deaths
|
||||
const hsduelskd = hsduelskills / hsduelsdeaths
|
||||
// duels wins
|
||||
const hsduelswins = player.stats.Duels.wins
|
||||
// duels wlr
|
||||
const hsduelslosses = player.stats.Duels.losses
|
||||
const hsduelswlr = hsduelswins / hsduelslosses
|
||||
// network level
|
||||
const hypixelExp = player.networkExp
|
||||
const level = hypixelLevel(hypixelExp)
|
||||
|
||||
let bwtitle = ""
|
||||
let swtitle = ""
|
||||
let duelstitle = ""
|
||||
if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
|
||||
bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
|
||||
} else {
|
||||
bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements."
|
||||
}
|
||||
|
||||
if (hsswstars < swstars) {
|
||||
swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."
|
||||
} else {
|
||||
swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements."
|
||||
}
|
||||
|
||||
if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
|
||||
duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."
|
||||
} else {
|
||||
duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
|
||||
}
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: rank + player.displayname + guildTag,
|
||||
description: "**Network Level:** `" +
|
||||
level.toFixed(2).toString() + "`\n" +
|
||||
"**Current Guild:** `" + guildName + "`",
|
||||
color: embedColor,
|
||||
thumbnail: { url: head },
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL()
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: bwtitle,
|
||||
value: "**➺ Stars:** `" +
|
||||
hsbwstars.toFixed(2).toString() + " / " +
|
||||
bwstars.toString() + "`\n" +
|
||||
"**➺ FKDR:** `" +
|
||||
hsbwfkdr.toFixed(2).toString() +
|
||||
" / " + bwfkdr.toString() + "`\n" +
|
||||
"**➺ Wins:** `" +
|
||||
hsbwwins.toString() + " / " +
|
||||
bwwins.toString() + "`"
|
||||
},
|
||||
{
|
||||
name: swtitle,
|
||||
value:
|
||||
"**➺ Stars:** `" +
|
||||
hsswstars.toFixed(2).toString() +
|
||||
" / " + swstars.toString() + "`\n" +
|
||||
"**➺ KDR:** `" +
|
||||
hsswkd.toFixed(2).toString() + "`\n" +
|
||||
"**➺ Wins:** `" +
|
||||
hsswwins.toString() + "`"
|
||||
},
|
||||
{
|
||||
name: duelstitle,
|
||||
value: "**➺ Wins:** `" +
|
||||
hsduelswins.toString() +
|
||||
" / " + duelswins.toString() + "`\n" +
|
||||
"**➺ WLR:** `" +
|
||||
hsduelswlr.toFixed(2).toString() +
|
||||
" / " + duelswlr.toString() + "`\n" +
|
||||
"**➺ KDR:** `" +
|
||||
hsduelskd.toFixed(2).toString() + "`"
|
||||
}
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
95
src/events/buttons/guildapplicationaccept.js
Normal file
95
src/events/buttons/guildapplicationaccept.js
Normal file
@@ -0,0 +1,95 @@
|
||||
const { ActionRowBuilder, ButtonStyle, ButtonBuilder } = require("discord.js")
|
||||
const { color } = require("../../../config/options.json")
|
||||
const mongoose = require("mongoose")
|
||||
const guildapp = require("../../schemas/guildAppSchema.js")
|
||||
const waitingList = require("../../schemas/waitinglistSchema.js")
|
||||
const { waitingListRole } = require("../../../config/roles.json")
|
||||
|
||||
module.exports = {
|
||||
name: "guildapplicationaccept",
|
||||
description: "Accept a guild application.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply()
|
||||
|
||||
const user = interaction.user
|
||||
const guild = interaction.guild
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer.text.split(" ")[1]
|
||||
|
||||
const applicantIGN1 = embed.fields[0].value
|
||||
const applicantIGN = applicantIGN1.replaceAll("`", "")
|
||||
|
||||
const applicant = await guild.members.fetch(applicantId)
|
||||
const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("checkstats")
|
||||
.setLabel("Check Stats")
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
.setDisabled(true)
|
||||
)
|
||||
]
|
||||
})
|
||||
|
||||
await applicant.send({
|
||||
embeds: [{
|
||||
description: "Your application for the Illegitimate guild has been accepted.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const applicantEntry = await guildapp.findOne({ userID: applicantId })
|
||||
const applicantUUID = applicantEntry.uuid
|
||||
const time = Date.now()
|
||||
|
||||
const waitingListAdd = new waitingList({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: applicantId,
|
||||
uuid: applicantUUID,
|
||||
IGN: applicantIGN,
|
||||
timestamp: time
|
||||
})
|
||||
|
||||
await waitingListAdd.save()
|
||||
|
||||
await applicant.roles.add(waitingListRole)
|
||||
await guildapp.findOneAndDelete({ userID: applicantId })
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: applicantUsername + " - Guild Application",
|
||||
description: "Application has been accepted by <@" + user.id + ">.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: applicant.avatarURL()
|
||||
},
|
||||
footer: {
|
||||
iconURL: guild.iconURL(),
|
||||
text: "ID: " + applicant.id
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
27
src/events/buttons/guildapplicationdeny.js
Normal file
27
src/events/buttons/guildapplicationdeny.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "guildapplicationdeny",
|
||||
description: "Deny a guild application.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setTitle("Deny Reason")
|
||||
.setCustomId("denyreasonbox")
|
||||
.setComponents(
|
||||
new ActionRowBuilder().setComponents(
|
||||
new TextInputBuilder()
|
||||
.setLabel("Deny Reason")
|
||||
.setCustomId("denyreason")
|
||||
.setStyle(TextInputStyle.Paragraph)
|
||||
.setPlaceholder("Enter a reason for denying the application")
|
||||
.setRequired(false)
|
||||
)
|
||||
)
|
||||
await interaction.showModal(modal)
|
||||
}
|
||||
}
|
||||
523
src/events/buttons/guildapply.js
Normal file
523
src/events/buttons/guildapply.js
Normal file
@@ -0,0 +1,523 @@
|
||||
const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require("discord.js")
|
||||
const { color } = require("../../../config/options.json")
|
||||
const { largeM, smallM, ignM } = require("../../../config/limitmessages.json")
|
||||
const { applicationsChannel } = require("../../../config/options.json")
|
||||
const questions = require("../../../config/questions.json")
|
||||
const { guildRole } = require("../../../config/roles.json")
|
||||
const { getUUID } = require("../../utils/utils.js")
|
||||
const mongoose = require("mongoose")
|
||||
const guildapp = require("../../schemas/guildAppSchema.js")
|
||||
|
||||
module.exports = {
|
||||
name: "guildapply",
|
||||
description: "Guild application button.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const user = interaction.user
|
||||
const guild = interaction.guild
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
const userRoles = guild.members.cache.get(user.id).roles.cache.map(role => role.id)
|
||||
const guildQuestions = questions.guild
|
||||
|
||||
function qu(n) {
|
||||
return guildQuestions[n - 1].q
|
||||
}
|
||||
|
||||
function rq(n) {
|
||||
return guildQuestions[n - 1].r
|
||||
}
|
||||
|
||||
if (interaction.customId === "guildapply") {
|
||||
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
if (userRoles.includes(guildRole)) {
|
||||
await interaction.editReply({ content: "You are already a member of the guild.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
const application = await guildapp.findOne({ userID: user.id })
|
||||
|
||||
if (application) {
|
||||
await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
const tooLong = new EmbedBuilder()
|
||||
.setDescription("You took too long to respond.")
|
||||
.setColor(embedColor)
|
||||
const cancelled = new EmbedBuilder()
|
||||
.setDescription("You have cancelled your application.")
|
||||
.setColor(embedColor)
|
||||
const attachments = new EmbedBuilder()
|
||||
.setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
|
||||
.setColor(embedColor)
|
||||
|
||||
try {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "Guild Application",
|
||||
description: "Please answer the following questions to apply for the guild.\n" +
|
||||
"If you wish to cancel your application, please type `cancel` at any time.\n" +
|
||||
"If you wish to proceed with your application, please type `yes`.\n\n" +
|
||||
"**Do not upload images, videos, or GIFS.**\n" +
|
||||
"You have a minute to respond to this message.",
|
||||
color: embedColor,
|
||||
}]
|
||||
})
|
||||
} catch (error) {
|
||||
await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.editReply({ content: "Please check your DMs.", ephemeral: true })
|
||||
|
||||
|
||||
const input = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60
|
||||
})
|
||||
if (input.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (input.first().content.toLowerCase() !== "yes") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (input.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
|
||||
// first question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 1**",
|
||||
description: qu(1) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 5 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer1 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5,
|
||||
})
|
||||
if (answer1.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content > 16) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 16.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
const uuid = await getUUID(answer1.first().content)
|
||||
if (!uuid) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "That is not a valid Minecraft username.\n" +
|
||||
"Application cancelled.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
const answer1_1 = answer1.first().content
|
||||
|
||||
// second question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 2**",
|
||||
description: qu(2) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(8 characters max)`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer2 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer2.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer2.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer2.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer2.first().content.size > 8) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 8.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
const answer2_1 = answer2.first().content
|
||||
|
||||
// third question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 3**",
|
||||
description: qu(3) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer3 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer3.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer3.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer3.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer3.first().content > 128) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 128.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer3_1 = answer3.first().content
|
||||
|
||||
// fourth question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 4**",
|
||||
description: qu(4) + "\n\nPlease type your answer below or type `cancel` to cancel your application." +
|
||||
" `(We expect a longer answer.)`\n`" + largeM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer4 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer4.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer4.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer4.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer4.first().content > 256) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 256.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer4_1 = answer4.first().content
|
||||
|
||||
// fifth question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 5**",
|
||||
description: qu(5) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer5 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer5.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer5.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer5.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer5.first().content > 128) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 128.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer5_1 = answer5.first().content
|
||||
|
||||
// sixth question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 6**",
|
||||
description: qu(6) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer6 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer6.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer6.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer6.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer6.first().content > 256) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 256.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer6_1 = answer6.first().content
|
||||
|
||||
// seventh question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 7**",
|
||||
description: qu(7) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer7 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer7.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer7.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer7.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer7.first().content > 128) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 128.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer7_1 = answer7.first().content
|
||||
|
||||
// eighth question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 8**",
|
||||
description: qu(8) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(64 characters max)`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer8 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer8.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer8.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer8.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer8.first().content > 64) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 64.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer8_1 = answer8.first().content
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "If you want to submit your application, type `yes` if not, type `no`",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const final = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5
|
||||
})
|
||||
if (final.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (final.first().content.toLowerCase() !== "yes") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (final.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Your application has been submitted!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const newGuildApp = new guildapp({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: user.id,
|
||||
uuid: uuid,
|
||||
})
|
||||
|
||||
await newGuildApp.save()
|
||||
|
||||
const channel = guild.channels.cache.get(applicationsChannel)
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
title: user.username + "#" + user.discriminator + " - Guild Application",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: user.avatarURL()
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: rq(1),
|
||||
value: "```" + answer1_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(2),
|
||||
value: "```" + answer2_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(3),
|
||||
value: "```" + answer3_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(4),
|
||||
value: "```" + answer4_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(5),
|
||||
value: "```" + answer5_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(6),
|
||||
value: "```" + answer6_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(7),
|
||||
value: "```" + answer7_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(8),
|
||||
value: "```" + answer8_1 + "```"
|
||||
}
|
||||
],
|
||||
footer: {
|
||||
iconURL: guild.iconURL(),
|
||||
text: "ID: " + user.id
|
||||
}
|
||||
}],
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("checkstats")
|
||||
.setLabel("Check Stats")
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
)
|
||||
]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
273
src/events/buttons/guildinactivitylog.js
Normal file
273
src/events/buttons/guildinactivitylog.js
Normal file
@@ -0,0 +1,273 @@
|
||||
const { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder } = require("discord.js")
|
||||
const { gm, manager, moderator, beast, member, trialmember, guildStaff, guildRole } = require("../../../config/roles.json")
|
||||
const { ignM, smallM, largeM } = require("../../../config/limitmessages.json")
|
||||
const { ia1, ia2, ia3, ria1, ria2, ria3 } = require("../../../config/questions.json")
|
||||
const { color, inactivityLogChannel } = require("../../../config/options.json")
|
||||
const guildRoles = [gm, manager, moderator, beast, member, trialmember, guildStaff, guildRole]
|
||||
|
||||
module.exports = {
|
||||
name: "guildinactivitylog",
|
||||
description: "Configure the bot.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
const guild = interaction.guild
|
||||
const user = interaction.user
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
const userRoles = guild.members.cache.get(user.id).roles.cache
|
||||
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"
|
||||
|
||||
if (!userRoles.some((role) => guildRoles.includes(role.id))) {
|
||||
return await interaction.reply({
|
||||
content: "Only guild members can use this button.",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
|
||||
const tooLong = new EmbedBuilder()
|
||||
.setDescription("You took too long to respond.")
|
||||
.setColor(embedColor)
|
||||
const cancelled = new EmbedBuilder()
|
||||
.setDescription("You have cancelled your application.")
|
||||
.setColor(embedColor)
|
||||
const attachments = new EmbedBuilder()
|
||||
.setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
|
||||
.setColor(embedColor)
|
||||
|
||||
try {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "Guild Inactivity Log",
|
||||
description: "Please answer the following questions to submit an inactivity log for the guild.\n" +
|
||||
"If you wish to cancel your form, please press type `cancel` at any time.\n" +
|
||||
"If you wish to proceed with your form, please type `yes`.\n\n" + "**Do not upload images, videos, or GIFS.**\n" +
|
||||
"You have a minute to respond to this message.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
} catch (error) {
|
||||
return await interaction.reply({ content: "Please enable your DMs.", ephemeral: true })
|
||||
}
|
||||
|
||||
await interaction.reply({ content: "Please check your DMs.", ephemeral: true })
|
||||
|
||||
const input = await user.dmChannel.awaitMessages({
|
||||
filter: (m) => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60
|
||||
})
|
||||
if (input.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (input.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (input.first().content.toLowerCase() !== "yes") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 1**",
|
||||
description: ia1 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 5 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
const answer1 = await user.dmChannel.awaitMessages({
|
||||
filter: (m) => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5
|
||||
})
|
||||
if (answer1.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content > 16) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 16.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await fetch(mojangAPI + answer1.first().content)
|
||||
} catch (error) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "That is not a valid Minecraft username.\n" + "Application cancelled.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
if (answer1.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
const answer1_1 = answer1.first().content
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 2**",
|
||||
description: ia2 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 5 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer2 = await user.dmChannel.awaitMessages({
|
||||
filter: (m) => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5
|
||||
})
|
||||
if (answer2.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer2.first().content > 128) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 128.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
if (answer1.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
const answer2_1 = answer1.first().content
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 3**",
|
||||
description: ia3 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer3 = await user.dmChannel.awaitMessages({
|
||||
filter: (m) => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer3.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer3.first().content > 256) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 256",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
if (answer1.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
const answer3_1 = answer1.first().content
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "If you want to submit your application, type `yes` if not, type `no`",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
const final = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5
|
||||
})
|
||||
if (final.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (final.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (final.first().content.toLowerCase() !== "yes") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Your application has been submitted!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const appChannel = await guild.channels.cache.get(inactivityLogChannel)
|
||||
|
||||
await appChannel.send({
|
||||
embeds: [{
|
||||
title: user.username + "#" + user.discriminator + " - Inactivity Application",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: user.displayAvatarURL({ dynamic: true })
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: ria1,
|
||||
value: "`" + answer1_1 + "`"
|
||||
},
|
||||
{
|
||||
name: ria2,
|
||||
value: "`" + answer2_1 + "`"
|
||||
},
|
||||
{
|
||||
name: ria3,
|
||||
value: "`" + answer3_1 + "`"
|
||||
}
|
||||
],
|
||||
footer: {
|
||||
icon_url: user.displayAvatarURL({ dynamic: true }),
|
||||
text: "ID: " + user.id
|
||||
}
|
||||
}],
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("inactiveapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("inactiveapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
)
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
13
src/events/buttons/inactiveapplicationaccept.js
Normal file
13
src/events/buttons/inactiveapplicationaccept.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
name: "inactiveapplicationaccept",
|
||||
description: "Accept an inactivity application.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.reply({ content: "This button is currently disabled.", ephemeral: true })
|
||||
|
||||
}
|
||||
}
|
||||
13
src/events/buttons/inactiveapplicationdeny.js
Normal file
13
src/events/buttons/inactiveapplicationdeny.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
name: "inactiveapplicationdeny",
|
||||
description: "Denies an inactivity application.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.reply({ content: "This button is currently disabled.", ephemeral: true })
|
||||
|
||||
}
|
||||
}
|
||||
67
src/events/buttons/staffapplicationaccept.js
Normal file
67
src/events/buttons/staffapplicationaccept.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js")
|
||||
const { color } = require("../../../config/options.json")
|
||||
const staffapp = require("../../schemas/staffAppSchema.js")
|
||||
|
||||
module.exports = {
|
||||
name: "staffapplicationaccept",
|
||||
description: "Accept a staff application.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const user = interaction.user
|
||||
const guild = interaction.guild
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer.text.split(" ")[1]
|
||||
|
||||
const applicant = await guild.members.fetch(applicantId)
|
||||
const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator
|
||||
|
||||
await applicant.send({
|
||||
embeds: [{
|
||||
description: "Your application for the Illegitimate staff team has been accepted.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true)
|
||||
)
|
||||
]
|
||||
})
|
||||
|
||||
await staffapp.findOneAndDelete({ userId: applicantId })
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [{
|
||||
title: applicantUsername + " - Staff Application.",
|
||||
description: "Application accepted by <@" + user.id + ">.",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: applicant.avatarURL()
|
||||
},
|
||||
footer: {
|
||||
iconurl: guild.iconURL(),
|
||||
text: "ID: " + applicantId
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
27
src/events/buttons/staffapplicationdeny.js
Normal file
27
src/events/buttons/staffapplicationdeny.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "staffapplicationdeny",
|
||||
description: "Deny a guild application.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setTitle("Deny Reason")
|
||||
.setCustomId("staffdenyreasonbox")
|
||||
.setComponents(
|
||||
new ActionRowBuilder().setComponents(
|
||||
new TextInputBuilder()
|
||||
.setLabel("Deny Reason")
|
||||
.setCustomId("staffdenyreason")
|
||||
.setStyle(TextInputStyle.Paragraph)
|
||||
.setPlaceholder("Enter a reason for denying the application")
|
||||
.setRequired(false)
|
||||
)
|
||||
)
|
||||
await interaction.showModal(modal)
|
||||
}
|
||||
}
|
||||
451
src/events/buttons/staffapply.js
Normal file
451
src/events/buttons/staffapply.js
Normal file
@@ -0,0 +1,451 @@
|
||||
const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require("discord.js")
|
||||
const { color, staffApplicationsChannel } = require("../../../config/options.json")
|
||||
const { largeM, ignM } = require("../../../config/limitmessages.json")
|
||||
const questions = require("../../../config/questions.json")
|
||||
const { guildRole, guildStaff } = require("../../../config/roles.json")
|
||||
const mongoose = require("mongoose")
|
||||
const staffapp = require("../../schemas/staffAppSchema.js")
|
||||
const settings = require("../../schemas/settingsSchema.js")
|
||||
const { getUUID } = require("../../utils/utils.js")
|
||||
const dev = process.env.DEV
|
||||
|
||||
module.exports = {
|
||||
name: "staffapply",
|
||||
description: "Apply for the staff team.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const user = interaction.user
|
||||
const guild = interaction.guild
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
const userRoles = interaction.member.roles.cache
|
||||
const setting = await settings.findOne({ name: "staffAppStatus" })
|
||||
const status = setting.value
|
||||
const staffQuestions = questions.staff
|
||||
|
||||
function sq(n) {
|
||||
return staffQuestions[n - 1].q
|
||||
}
|
||||
|
||||
function rq(n) {
|
||||
return staffQuestions[n - 1].r
|
||||
}
|
||||
|
||||
if (interaction.customId === "staffapply") {
|
||||
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
if (user.id !== dev) {
|
||||
if (status === "0") {
|
||||
await interaction.editReply({ content: "Staff applications are currently closed.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (!userRoles.has(guildRole)) {
|
||||
await interaction.editReply({ content: "You must be a member of the guild to apply for staff.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
if (userRoles.has(guildStaff)) {
|
||||
await interaction.editReply({ content: "You are already a staff member.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
const application = await staffapp.findOne({ userID: user.id })
|
||||
|
||||
if (application) {
|
||||
await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
const tooLong = new EmbedBuilder()
|
||||
.setDescription("You took too long to respond.")
|
||||
.setColor(embedColor)
|
||||
const cancelled = new EmbedBuilder()
|
||||
.setDescription("You have cancelled your application.")
|
||||
.setColor(embedColor)
|
||||
const attachments = new EmbedBuilder()
|
||||
.setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
|
||||
.setColor(embedColor)
|
||||
|
||||
try {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "Staff Application",
|
||||
description: "Please answer the following questions to apply for staff.\n" +
|
||||
"If you wish to cancel your application, please press type `cancel` at any time.\n" +
|
||||
"If you wish to proceed with your application, please type `yes`.\n\n" +
|
||||
"**Do not upload images, videos, or GIFS.**\n" +
|
||||
"You have a minute to respond to this message.",
|
||||
color: embedColor,
|
||||
}]
|
||||
})
|
||||
} catch (error) {
|
||||
await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
await interaction.editReply({ content: "Please check your DMs.", ephemeral: true })
|
||||
|
||||
const input = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60
|
||||
})
|
||||
if (input.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (input.first().content.toLowerCase() !== "yes") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (input.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
|
||||
// first question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 1**",
|
||||
description: sq(1) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 5 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer1 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5,
|
||||
})
|
||||
if (answer1.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer1.first().content > 16) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 16.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
const uuid = await getUUID(answer1.first().content)
|
||||
if (!uuid) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "That is not a valid Minecraft username.\n" +
|
||||
"Application cancelled.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
const answer1_1 = answer1.first().content
|
||||
|
||||
// second question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 2**",
|
||||
description: sq(2) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(64 characters max)`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer2 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer2.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer2.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer2.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer2.first().content > 64) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 64.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
const answer2_1 = answer2.first().content
|
||||
|
||||
// third question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 3**",
|
||||
description: sq(3) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer3 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer3.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer3.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer3.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer3.first().content > 256) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 256.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer3_1 = answer3.first().content
|
||||
|
||||
// fourth question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 4**",
|
||||
description: sq(4) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer4 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer4.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer4.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer4.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer4.first().content > 256) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 256.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer4_1 = answer4.first().content
|
||||
|
||||
// fifth question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 5**",
|
||||
description: sq(5) + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer5 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer5.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer5.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer5.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer5.first().content > 256) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 256.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer5_1 = answer5.first().content
|
||||
|
||||
// sixth question
|
||||
await user.send({
|
||||
embeds: [{
|
||||
title: "**Question 6**",
|
||||
description: sq(6) + "\n\nPlease type your answer below or type `cancel` to cancel your application." +
|
||||
"`(We expect a longer answer here)`\n`" + largeM + "`",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "You have 15 minutes to respond to this message."
|
||||
}
|
||||
}]
|
||||
})
|
||||
const answer6 = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 15
|
||||
})
|
||||
if (answer6.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (answer6.first().content.toLowerCase() === "cancel") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (answer6.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
if (answer6.first().content > 256) {
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Max character limit is 256.",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
const answer6_1 = answer6.first().content
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "If you want to submit your application, type `yes` if not, type `no`",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const final = await user.dmChannel.awaitMessages({
|
||||
filter: m => m.author.id === user.id,
|
||||
max: 1,
|
||||
time: 1000 * 60 * 5
|
||||
})
|
||||
if (final.size === 0) {
|
||||
await user.send({ embeds: [tooLong] })
|
||||
return
|
||||
}
|
||||
if (final.first().content.toLowerCase() !== "yes") {
|
||||
await user.send({ embeds: [cancelled] })
|
||||
return
|
||||
}
|
||||
if (final.first().attachments.size > 0) {
|
||||
await user.send({ embeds: [attachments] })
|
||||
return
|
||||
}
|
||||
|
||||
await user.send({
|
||||
embeds: [{
|
||||
description: "Your application has been submitted!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
|
||||
const newStaffApp = new staffapp({
|
||||
_id: new mongoose.Types.ObjectId(),
|
||||
userID: user.id,
|
||||
uuid: uuid,
|
||||
})
|
||||
|
||||
await newStaffApp.save()
|
||||
await user.deleteDM()
|
||||
|
||||
const channel = guild.channels.cache.get(staffApplicationsChannel)
|
||||
|
||||
await channel.send({
|
||||
embeds: [{
|
||||
title: user.username + "#" + user.discriminator + " - Staff Application",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: user.avatarURL()
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: rq(1),
|
||||
value: "```" + answer1_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(2),
|
||||
value: "```" + answer2_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(3),
|
||||
value: "```" + answer3_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(4),
|
||||
value: "```" + answer4_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(5),
|
||||
value: "```" + answer5_1 + "```"
|
||||
},
|
||||
{
|
||||
name: rq(6),
|
||||
value: "```" + answer6_1 + "```"
|
||||
}
|
||||
|
||||
],
|
||||
footer: {
|
||||
iconURL: guild.iconURL(),
|
||||
text: "ID: " + user.id
|
||||
}
|
||||
}],
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
)
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/events/buttons/verify.js
Normal file
29
src/events/buttons/verify.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "verify",
|
||||
description: "Configure the bot.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const modal = new ModalBuilder()
|
||||
.setTitle("Verification")
|
||||
.setCustomId("verifybox")
|
||||
.setComponents(
|
||||
new ActionRowBuilder().setComponents(
|
||||
new TextInputBuilder()
|
||||
.setLabel("IGN")
|
||||
.setCustomId("verifyfield")
|
||||
.setStyle(TextInputStyle.Short)
|
||||
.setPlaceholder("Enter your ign.")
|
||||
.setRequired(true)
|
||||
.setMinLength(3)
|
||||
.setMaxLength(16)
|
||||
)
|
||||
)
|
||||
await interaction.showModal(modal)
|
||||
}
|
||||
}
|
||||
63
src/events/buttons/waitingListUpdate.js
Normal file
63
src/events/buttons/waitingListUpdate.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const waitinglist = require("../../schemas/waitinglistSchema.js")
|
||||
const { getGuild } = require("../../utils/utils.js")
|
||||
const { hypixelGuildID } = require("../../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "waitinglistupdate",
|
||||
description: "Update the waiting list.",
|
||||
type: "button",
|
||||
|
||||
/** @param {import('discord.js').ButtonInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
const user = interaction.user
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const accepted = await waitinglist.find()
|
||||
|
||||
for (let i = 0; i < accepted.length; i++) {
|
||||
|
||||
const uuid = accepted[i].uuid
|
||||
const guild = await getGuild(uuid)
|
||||
|
||||
if (guild && guild._id === hypixelGuildID) {
|
||||
await waitinglist.findOneAndDelete({ uuid: uuid })
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let fields = []
|
||||
|
||||
for (let i = 0; i < accepted.length; i++) {
|
||||
|
||||
const timestamp1 = accepted[i].timestamp / 1000
|
||||
const timestamp = Math.floor(timestamp1)
|
||||
|
||||
fields.push({
|
||||
name: `${i + 1}. ${accepted[i].IGN}`,
|
||||
value: `TS: <t:${timestamp}:R>`
|
||||
})
|
||||
}
|
||||
|
||||
await message.edit({
|
||||
embeds: [{
|
||||
title: embed.title,
|
||||
description: embed.description,
|
||||
color: embed.color,
|
||||
footer: {
|
||||
text: "Last updated by " + user.username,
|
||||
icon_url: user.avatarURL(),
|
||||
},
|
||||
thumbnail: embed.thumbnail,
|
||||
fields: fields,
|
||||
timestamp: new Date(),
|
||||
}],
|
||||
})
|
||||
|
||||
await interaction.editReply({ content: "Updated the waiting list", ephemeral: true })
|
||||
}
|
||||
}
|
||||
93
src/events/modals/denyreasonbox.js
Normal file
93
src/events/modals/denyreasonbox.js
Normal file
@@ -0,0 +1,93 @@
|
||||
const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js")
|
||||
const { color } = require("../../../config/options.json")
|
||||
const guildapp = require("../../schemas/guildAppSchema.js")
|
||||
|
||||
module.exports = {
|
||||
name: "denyreasonbox",
|
||||
description: "Deny reason box.",
|
||||
type: "modal",
|
||||
|
||||
/** @param {import('discord.js').ModalSubmitInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
if (interaction.type !== InteractionType.ModalSubmit) return
|
||||
if (interaction.customId !== "denyreasonbox") return
|
||||
|
||||
interaction.deferReply()
|
||||
|
||||
const guild = interaction.guild
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer.text.split(" ")[1]
|
||||
|
||||
let applicant = ""
|
||||
try {
|
||||
applicant = await guild.members.fetch(applicantId)
|
||||
} catch (error) {
|
||||
applicant = null
|
||||
}
|
||||
const reason = interaction.fields.fields.get("denyreason").value || "No reason provided"
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("checkstats")
|
||||
.setLabel("Check Stats")
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
.setDisabled(true)
|
||||
)
|
||||
]
|
||||
})
|
||||
|
||||
const dmMessage = new EmbedBuilder()
|
||||
.setDescription("Your application for the Illegitimate guild has been denied\n" +
|
||||
"**Reason:** `" + reason + "`")
|
||||
.setColor(embedColor)
|
||||
|
||||
const missingUser = new EmbedBuilder()
|
||||
.setDescription("[WARN] User has left the server and cannot be notified.")
|
||||
.setColor(embedColor)
|
||||
|
||||
const responseEmbed = new EmbedBuilder()
|
||||
.setTitle("Application Denied")
|
||||
.setDescription("The application has been denied by <@" + interaction.user.id + ">.\n" +
|
||||
"**Reason:** `" + reason + "`")
|
||||
.setColor(embedColor)
|
||||
.setThumbnail(guild.iconURL())
|
||||
.setFooter({
|
||||
iconURL: guild.iconURL(),
|
||||
text: "ID: " + applicant.id
|
||||
})
|
||||
|
||||
if (applicant !== null) {
|
||||
await applicant.send({ embeds: [dmMessage] })
|
||||
}
|
||||
|
||||
let responseEmbeds = ""
|
||||
if (applicant === null) {
|
||||
responseEmbeds = [responseEmbed, missingUser]
|
||||
} else {
|
||||
responseEmbeds = [responseEmbed]
|
||||
}
|
||||
|
||||
await guildapp.findOneAndDelete({ userID: applicantId })
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: responseEmbeds
|
||||
})
|
||||
}
|
||||
}
|
||||
70
src/events/modals/staffdenyreasonbox.js
Normal file
70
src/events/modals/staffdenyreasonbox.js
Normal file
@@ -0,0 +1,70 @@
|
||||
const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js")
|
||||
const { color } = require("../../../config/options.json")
|
||||
const staffapp = require("../../schemas/staffAppSchema.js")
|
||||
|
||||
module.exports = {
|
||||
name: "staffdenyreasonbox",
|
||||
description: "Deny reason box.",
|
||||
type: "modal",
|
||||
|
||||
/** @param {import('discord.js').ModalSubmitInteraction} interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
if (interaction.type !== InteractionType.ModalSubmit) return
|
||||
if (interaction.customId !== "staffdenyreasonbox") return
|
||||
|
||||
interaction.deferReply()
|
||||
|
||||
const guild = interaction.guild
|
||||
const reason = interaction.fields.fields.get("staffdenyreason").value || "No reason provided"
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = interaction.message
|
||||
const embed = message.embeds[0]
|
||||
const applicantId = embed.footer.text.split(" ")[1]
|
||||
const applicant = await guild.members.fetch(applicantId)
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true),
|
||||
new ButtonBuilder()
|
||||
.setCustomId("staffapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true),
|
||||
)
|
||||
]
|
||||
})
|
||||
|
||||
const dmMessage = new EmbedBuilder()
|
||||
.setDescription("Your application for the Illegitimate guild staff has been denied\n" +
|
||||
"**Reason:** `" + reason + "`")
|
||||
.setColor(embedColor)
|
||||
|
||||
await applicant.send({ embeds: [dmMessage] })
|
||||
|
||||
await staffapp.findOneAndDelete({ userID: applicantId })
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [{
|
||||
title: "Application Denied",
|
||||
description: "The application has been denied by <@" + interaction.user.id + ">.\n" +
|
||||
"**Reason:** `" + reason + "`",
|
||||
color: embedColor,
|
||||
thumbnail: {
|
||||
url: applicant.avatarURL()
|
||||
},
|
||||
footer: {
|
||||
iconURL: guild.iconURL(),
|
||||
text: "ID: " + applicant.id
|
||||
}
|
||||
}],
|
||||
})
|
||||
}
|
||||
}
|
||||
35
src/events/server/guildMemberAdd/logNewJoins.js
Normal file
35
src/events/server/guildMemberAdd/logNewJoins.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { userMention } = require("discord.js")
|
||||
const { color, botLogChannel } = require("../../../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "logNewJoins",
|
||||
description: "Logs new joins",
|
||||
type: "event",
|
||||
event: "guildMemberAdd",
|
||||
|
||||
/** @param { import('discord.js').GuildMember } member */
|
||||
execute(member) {
|
||||
|
||||
const channel = member.guild.channels.cache.get(botLogChannel)
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (!channel) {
|
||||
console.log("[ERROR] Could not find channel used for new join logging.")
|
||||
return
|
||||
}
|
||||
|
||||
channel.send({
|
||||
embeds: [{
|
||||
title: "New Member",
|
||||
description: userMention(member.id) + " has joined the server.\n" +
|
||||
"Account created: " + member.user.createdAt.toLocaleString(),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + member.id
|
||||
},
|
||||
timestamp: new Date()
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
22
src/events/server/interactions/logBtnsCmds.js
Normal file
22
src/events/server/interactions/logBtnsCmds.js
Normal file
@@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
name: "logBtnsCmds",
|
||||
description: "Logs all button and command interactions",
|
||||
type: "event",
|
||||
event: "interactionCreate",
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
execute(interaction) {
|
||||
if (interaction.isCommand()) {
|
||||
console.log(interaction.user.username + "#" +
|
||||
interaction.user.discriminator + " ran " +
|
||||
interaction.commandName
|
||||
)
|
||||
} else if (interaction.isButton()) {
|
||||
console.log(interaction.user.username + "#" +
|
||||
interaction.user.discriminator + " clicked " +
|
||||
interaction.customId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/events/server/messages/clown.js
Normal file
14
src/events/server/messages/clown.js
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
name: "ur mom",
|
||||
description: "ur moms someone",
|
||||
type: "event",
|
||||
event: "messageCreate",
|
||||
|
||||
/** @param { import('discord.js').Message } message */
|
||||
|
||||
async execute(message) {
|
||||
if (message.content.toLowerCase().includes("ur mom") && message.author.username === "taken.lua") {
|
||||
message.react("Woot:734345936347725885")
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/events/server/ready/consolelog.js
Normal file
11
src/events/server/ready/consolelog.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
name: "conolelog",
|
||||
description: "console log",
|
||||
type: "event",
|
||||
event: "ready",
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
execute(client) {
|
||||
console.log("Logged in as " + client.user.tag + "!")
|
||||
}
|
||||
}
|
||||
27
src/events/server/ready/sendOnlineMessage.js
Normal file
27
src/events/server/ready/sendOnlineMessage.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { onlineLogChannel, color } = require("../../../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "sendonlinemessage",
|
||||
description: "send an online message",
|
||||
type: "event",
|
||||
event: "ready",
|
||||
|
||||
execute(client) {
|
||||
if (process.env.NODE_ENV === "dev") return
|
||||
|
||||
const channel = client.channels.cache.get(onlineLogChannel)
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (!channel) {
|
||||
console.log("[ERROR] Could not find channel used for online message.")
|
||||
return
|
||||
}
|
||||
|
||||
channel.send({
|
||||
embeds: [{
|
||||
description: "Bot is online!",
|
||||
color: embedColor
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
34
src/events/server/ready/status.js
Normal file
34
src/events/server/ready/status.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const statuses = require("../../../../config/statuses.json")
|
||||
|
||||
module.exports = {
|
||||
name: "status",
|
||||
description: "Sets the status of the bot",
|
||||
type: "event",
|
||||
event: "ready",
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
execute(client) {
|
||||
|
||||
// Playing 0
|
||||
// Streaming 1
|
||||
// Listening 2
|
||||
// Watching 3
|
||||
// Custom 4
|
||||
// Competing 5
|
||||
|
||||
client.user.setActivity(
|
||||
{ name: statuses[0].name, type: 3}
|
||||
)
|
||||
|
||||
let i = 0
|
||||
setInterval(() =>
|
||||
client.user.setActivity(
|
||||
statuses[i = 1, i++ % statuses.length]
|
||||
),
|
||||
1000 * 60 * 10
|
||||
)
|
||||
|
||||
client.user.setStatus("dnd")
|
||||
}
|
||||
}
|
||||
86
src/events/server/voiceStateUpdate/vcJoinLeave.js
Normal file
86
src/events/server/voiceStateUpdate/vcJoinLeave.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const { userMention, channelMention } = require("discord.js")
|
||||
const { botLogChannel, color } = require("../../../../config/options.json")
|
||||
|
||||
module.exports = {
|
||||
name: "vcJoinLeave",
|
||||
description: "Logs when a user joins or leaves a voice channel.",
|
||||
type: "event",
|
||||
event: "voiceStateUpdate",
|
||||
|
||||
/**
|
||||
* @param { import('discord.js').VoiceState } oldState
|
||||
* @param { import('discord.js').VoiceState } newState
|
||||
*/
|
||||
|
||||
execute(oldState, newState) {
|
||||
|
||||
// if (process.env.NODE_ENV === 'dev') return
|
||||
|
||||
const guild = oldState.guild
|
||||
const channel = guild.channels.cache.get(botLogChannel)
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
if (!channel) {
|
||||
console.log("[ERROR] Could not find channel used for voice channel join/leave logging.")
|
||||
return
|
||||
}
|
||||
|
||||
const oldChannel = oldState.channel
|
||||
const newChannel = newState.channel
|
||||
|
||||
if (oldChannel === null && newChannel !== null) {
|
||||
|
||||
channel.send({
|
||||
embeds: [{
|
||||
title: "Voice Channel Join",
|
||||
description: userMention(oldState.member.id) +
|
||||
" joined " +
|
||||
channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member.id
|
||||
},
|
||||
timestamp: new Date()
|
||||
}]
|
||||
})
|
||||
|
||||
} else if (oldChannel !== null && newChannel === null) {
|
||||
|
||||
channel.send({
|
||||
embeds: [{
|
||||
title: "Voice Channel Leave",
|
||||
description: userMention(oldState.member.id) +
|
||||
" left " +
|
||||
channelMention(oldChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member.id
|
||||
},
|
||||
timestamp: new Date()
|
||||
}]
|
||||
})
|
||||
|
||||
} else if (oldChannel !== null && newChannel !== null) {
|
||||
|
||||
if (oldChannel.id === newChannel.id) return
|
||||
|
||||
channel.send({
|
||||
embeds: [{
|
||||
title: "Voice Channel Switch",
|
||||
description: userMention(oldState.member.id) +
|
||||
" switched from " +
|
||||
channelMention(oldChannel.id) +
|
||||
" to " +
|
||||
channelMention(newChannel.id),
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + oldState.member.id
|
||||
},
|
||||
timestamp: new Date()
|
||||
}]
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
49
src/index.js
Normal file
49
src/index.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const { Client, GatewayIntentBits, Partials, Collection } = require("discord.js")
|
||||
const { loadSlashCommandsEvents, loadContextMenuEvents, loadModalEvents, loadButtonEvents, loadEvents } = require("./utils/eventHandler.js")
|
||||
const { autoDeployCommands } = require("./utils/autodeploy.js")
|
||||
require("dotenv").config()
|
||||
const mongoURI = process.env.MONGOURI
|
||||
const { connect } = require("mongoose")
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.DirectMessages,
|
||||
GatewayIntentBits.GuildVoiceStates
|
||||
],
|
||||
partials: [
|
||||
Partials.GuildMember,
|
||||
Partials.User,
|
||||
Partials.Message,
|
||||
Partials.Channel
|
||||
]
|
||||
})
|
||||
|
||||
client.commands = new Collection()
|
||||
client.events = new Collection()
|
||||
client.modals = new Collection()
|
||||
|
||||
loadSlashCommandsEvents(client)
|
||||
loadContextMenuEvents(client)
|
||||
loadButtonEvents(client)
|
||||
loadModalEvents(client)
|
||||
loadEvents(client)
|
||||
|
||||
let token = ""
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
console.log("Running in development mode.")
|
||||
token = process.env.DEVTOKEN
|
||||
autoDeployCommands()
|
||||
} else {
|
||||
console.log("Running in production mode.")
|
||||
token = process.env.PRODTOKEN
|
||||
}
|
||||
|
||||
client.login(token)
|
||||
|
||||
connect(mongoURI, {}).then(() => {
|
||||
console.log("Connected to MongoDB")
|
||||
})
|
||||
9
src/schemas/guildAppSchema.js
Normal file
9
src/schemas/guildAppSchema.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const { Schema, model } = require("mongoose")
|
||||
|
||||
const guildAppSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true },
|
||||
})
|
||||
|
||||
module.exports = model("guildapp", guildAppSchema, "guildapp")
|
||||
9
src/schemas/settingsSchema.js
Normal file
9
src/schemas/settingsSchema.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const { Schema, model } = require("mongoose")
|
||||
|
||||
const settingsSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
name: { type: String, required: true },
|
||||
value: { type: String, required: true },
|
||||
})
|
||||
|
||||
module.exports = model("settings", settingsSchema, "settings")
|
||||
9
src/schemas/staffAppSchema.js
Normal file
9
src/schemas/staffAppSchema.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const { Schema, model } = require("mongoose")
|
||||
|
||||
const staffAppSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true },
|
||||
})
|
||||
|
||||
module.exports = model("staffapp", staffAppSchema, "staffapp")
|
||||
9
src/schemas/verifySchema.js
Normal file
9
src/schemas/verifySchema.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const { Schema, model } = require("mongoose")
|
||||
|
||||
const verifySchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true },
|
||||
})
|
||||
|
||||
module.exports = model("verify", verifySchema, "verify")
|
||||
11
src/schemas/waitinglistSchema.js
Normal file
11
src/schemas/waitinglistSchema.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const { Schema, model } = require("mongoose")
|
||||
|
||||
const waitinglistSchema = new Schema({
|
||||
_id: Schema.Types.ObjectId,
|
||||
userID: { type: String, required: true },
|
||||
uuid: { type: String, required: true },
|
||||
IGN: { type: String, required: true },
|
||||
timestamp: { type: String, required: true }
|
||||
})
|
||||
|
||||
module.exports = model("waitinglist", waitinglistSchema, "waitinglist")
|
||||
94
src/utils/autodeploy.js
Normal file
94
src/utils/autodeploy.js
Normal file
@@ -0,0 +1,94 @@
|
||||
const { REST, Routes } = require("discord.js")
|
||||
const log = require("log-beautify")
|
||||
const fs = require("fs")
|
||||
require("dotenv").config()
|
||||
const token = process.env.DEVTOKEN
|
||||
const clientId = process.env.DEVID
|
||||
const guildId = process.env.GUILDID
|
||||
|
||||
log.useSymbols = false
|
||||
log.setColors({
|
||||
newCmds: "#b4befe",
|
||||
currentCmds: "#f38ba8"
|
||||
})
|
||||
|
||||
async function autoDeployCommands() {
|
||||
const commands = []
|
||||
const commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsWith(".js"))
|
||||
const contentMenuCommands = fs.readdirSync("./src/commands-contextmenu/").filter(file => file.endsWith(".js"))
|
||||
const commandsTesting = fs.readdirSync("./src/commands-testing/").filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`)
|
||||
if (command.dev) {
|
||||
commands.push(command.data.toJSON())
|
||||
}
|
||||
}
|
||||
for (const file of contentMenuCommands) {
|
||||
const command = require(`../commands-contextmenu/${file}`)
|
||||
if (command.dev) {
|
||||
commands.push(command.data.toJSON())
|
||||
}
|
||||
}
|
||||
for (const file of commandsTesting) {
|
||||
const command = require(`../commands-testing/${file}`)
|
||||
if (command.dev) {
|
||||
commands.push(command.data.toJSON())
|
||||
}
|
||||
}
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(token)
|
||||
|
||||
const currentCommands = await rest.get(
|
||||
Routes.applicationGuildCommands(clientId, guildId),
|
||||
)
|
||||
|
||||
const currentCommandsInfo = currentCommands.map(command => {
|
||||
return {
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
}
|
||||
})
|
||||
const newCommandsInfo = commands.map(command => {
|
||||
return {
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
}
|
||||
})
|
||||
|
||||
const sortedCurrentCommandsInfo = currentCommandsInfo.sort((a, b) => a.name.localeCompare(b.name))
|
||||
const sortedNewCommandsInfo = newCommandsInfo.sort((a, b) => a.name.localeCompare(b.name))
|
||||
|
||||
const newCmds = sortedNewCommandsInfo.map(cmd => {
|
||||
return " " + cmd.name + " was registered."
|
||||
}).join("\n")
|
||||
const currentCmds = sortedCurrentCommandsInfo.map(cmd => {
|
||||
return " " + cmd.name + " was unregistered."
|
||||
}).join("\n")
|
||||
|
||||
if (JSON.stringify(sortedNewCommandsInfo) === JSON.stringify(sortedCurrentCommandsInfo)) {
|
||||
log.success("Commands are the same, skipping deploy.")
|
||||
log.newCmds(newCmds)
|
||||
return
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
log.warning("Commands are different, starting deploy.")
|
||||
log.currentCmds(currentCmds)
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
||||
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(clientId, guildId),
|
||||
{ body: commands },
|
||||
)
|
||||
|
||||
log.newCmds(newCmds)
|
||||
console.log(`Successfully reloaded ${data.length} application (/) commands.`)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
module.exports = { autoDeployCommands }
|
||||
13
src/utils/eventHandler.js
Normal file
13
src/utils/eventHandler.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const { loadButtonEvents } = require("./eventHandlers/button.js")
|
||||
const { loadSlashCommandsEvents } = require("./eventHandlers/command.js")
|
||||
const { loadContextMenuEvents } = require("./eventHandlers/contextmenu.js")
|
||||
const { loadModalEvents } = require("./eventHandlers/modal.js")
|
||||
const { loadEvents } = require("./eventHandlers/events.js")
|
||||
|
||||
module.exports = {
|
||||
loadSlashCommandsEvents,
|
||||
loadButtonEvents,
|
||||
loadContextMenuEvents,
|
||||
loadModalEvents,
|
||||
loadEvents
|
||||
}
|
||||
46
src/utils/eventHandlers/button.js
Normal file
46
src/utils/eventHandlers/button.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadButtonEvents(client) {
|
||||
const btnPath = path.join(__dirname, "..", "..", "events", "buttons")
|
||||
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of btnFiles) {
|
||||
|
||||
const filePath = path.join(btnPath, file)
|
||||
const btn = require(filePath)
|
||||
|
||||
if ("name" in btn && "execute" in btn && btn.type === "button") {
|
||||
client.events.set(btn.name, btn)
|
||||
} else {
|
||||
console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
client.on(Events.InteractionCreate, async event => {
|
||||
if (!event.isButton())
|
||||
return
|
||||
|
||||
const event2 = event.client.events.get(event.customId)
|
||||
|
||||
if (!event2) {
|
||||
console.error(`No event matching ${event.customId} was found.`)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await event2.execute(event)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
await event.reply({
|
||||
content: "There was an error while executing this event!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { loadButtonEvents }
|
||||
63
src/utils/eventHandlers/command.js
Normal file
63
src/utils/eventHandlers/command.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadSlashCommandsEvents(client) {
|
||||
const cmdPath = path.join(__dirname, "..", "..", "commands")
|
||||
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of cmdFiles) {
|
||||
|
||||
const filePath = path.join(cmdPath, file)
|
||||
const cmd = require(filePath)
|
||||
|
||||
if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
|
||||
client.commands.set(cmd.data.name, cmd)
|
||||
} else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
//! commands testing
|
||||
const cmdTestPath = path.join(__dirname, "..", "..", "commands-testing")
|
||||
const cmdTestFiles = fs.readdirSync(cmdTestPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of cmdTestFiles) {
|
||||
|
||||
const filePath = path.join(cmdTestPath, file)
|
||||
const cmd = require(filePath)
|
||||
|
||||
if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
|
||||
client.commands.set(cmd.data.name, cmd)
|
||||
} else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
//! command handler
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isChatInputCommand())
|
||||
return
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName)
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await command.execute(interaction)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
await interaction.reply({
|
||||
content: "There was an error while executing this command!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { loadSlashCommandsEvents }
|
||||
47
src/utils/eventHandlers/contextmenu.js
Normal file
47
src/utils/eventHandlers/contextmenu.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadContextMenuEvents(client) {
|
||||
const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu")
|
||||
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of contextMenuFiles) {
|
||||
|
||||
const filePath = path.join(contextMenuPath, file)
|
||||
const cmd = require(filePath)
|
||||
|
||||
if ("data" in cmd && "execute" in cmd && cmd.type === "contextmenu") {
|
||||
client.commands.set(cmd.data.name, cmd)
|
||||
} else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
//! context menu command handler
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isContextMenuCommand())
|
||||
return
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName)
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await command.execute(interaction)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
await interaction.reply({
|
||||
content: "There was an error while executing this command!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { loadContextMenuEvents }
|
||||
24
src/utils/eventHandlers/events.js
Normal file
24
src/utils/eventHandlers/events.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadEvents(client) {
|
||||
const serverDir = path.join(__dirname, "..", "..", "events", "server")
|
||||
const eventDirs = fs.readdirSync(serverDir)
|
||||
for (const eventDir of eventDirs) {
|
||||
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir))
|
||||
for (const eventFile of eventFiles) {
|
||||
const eventPath = path.join(serverDir, eventDir, eventFile)
|
||||
const event = require(eventPath)
|
||||
if ("name" in event && "execute" in event && "event" in event && event.type === "event") {
|
||||
client.on(event.event, event.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The event at ${eventPath} is missing a required "name", "execute", "type" or "event" property.`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = { loadEvents }
|
||||
24
src/utils/eventHandlers/modal.js
Normal file
24
src/utils/eventHandlers/modal.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadModalEvents(client) {
|
||||
const modalPath = path.join(__dirname, "..", "..", "events", "modals")
|
||||
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of modalFiles) {
|
||||
|
||||
const filePath = path.join(modalPath, file)
|
||||
const modal = require(filePath)
|
||||
|
||||
if ("name" in modal && "execute" in modal && modal.type === "modal") {
|
||||
client.on(Events.InteractionCreate, modal.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { loadModalEvents }
|
||||
67
src/utils/functions/account.js
Normal file
67
src/utils/functions/account.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const fetch = require("axios")
|
||||
const apikey = process.env.HYPIXELAPIKEY
|
||||
const mojang = "https://api.mojang.com/users/profiles/minecraft/"
|
||||
const mojanguuid = "https://sessionserver.mojang.com/session/minecraft/profile/"
|
||||
const hypixel = "https://api.hypixel.net/player"
|
||||
const guild = "https://api.hypixel.net/guild"
|
||||
const minotar = "https://minotar.net/helm/"
|
||||
|
||||
async function getUUID(ign) {
|
||||
try {
|
||||
const req = await fetch(mojang + ign)
|
||||
return req.data.id
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function getIGN(uuid) {
|
||||
try {
|
||||
const req = await fetch(mojanguuid + uuid)
|
||||
return req.data.name
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function getPlayer(uuid) {
|
||||
const playerReq = await fetch(hypixel, {
|
||||
params: {
|
||||
key: apikey,
|
||||
uuid: uuid
|
||||
}
|
||||
})
|
||||
|
||||
if (!playerReq.data.player) {
|
||||
return null
|
||||
}
|
||||
|
||||
return playerReq.data.player
|
||||
}
|
||||
|
||||
async function getGuild(uuid) {
|
||||
const guildReq = await fetch(guild, {
|
||||
params: {
|
||||
key: apikey,
|
||||
player: uuid
|
||||
}
|
||||
})
|
||||
|
||||
if (!guildReq.data.guild) {
|
||||
return null
|
||||
}
|
||||
|
||||
return guildReq.data.guild
|
||||
}
|
||||
|
||||
async function getHeadURL(ign) {
|
||||
return minotar + ign
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getUUID,
|
||||
getIGN,
|
||||
getPlayer,
|
||||
getGuild,
|
||||
getHeadURL
|
||||
}
|
||||
55
src/utils/functions/bedwars.js
Normal file
55
src/utils/functions/bedwars.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Code used from the slothpixel project https://github.com/slothpixel/core
|
||||
*/
|
||||
function getExpForLevel(level) {
|
||||
if (level == 0) return 0
|
||||
|
||||
let respectedLevel = getLevelRespectingPrestige(level)
|
||||
if (respectedLevel > EASY_LEVELS) {
|
||||
return 5000
|
||||
}
|
||||
|
||||
switch (respectedLevel) {
|
||||
case 1:
|
||||
return 500
|
||||
case 2:
|
||||
return 1000
|
||||
case 3:
|
||||
return 2000
|
||||
case 4:
|
||||
return 3500
|
||||
}
|
||||
return 5000
|
||||
}
|
||||
|
||||
function getLevelRespectingPrestige(level) {
|
||||
if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
|
||||
return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE
|
||||
}
|
||||
else {
|
||||
return level % LEVELS_PER_PRESTIGE
|
||||
}
|
||||
}
|
||||
|
||||
const EASY_LEVELS = 4
|
||||
const EASY_LEVELS_XP = 7000
|
||||
const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP
|
||||
const LEVELS_PER_PRESTIGE = 100
|
||||
const HIGHEST_PRESTIGE = 50
|
||||
function bedwarsLevel(exp) {
|
||||
let prestiges = Math.floor(exp / XP_PER_PRESTIGE)
|
||||
let level = prestiges * LEVELS_PER_PRESTIGE
|
||||
let expWithoutPrestiges = exp - (prestiges * XP_PER_PRESTIGE)
|
||||
|
||||
for (let i = 1; i <= EASY_LEVELS; ++i) {
|
||||
let expForEasyLevel = getExpForLevel(i)
|
||||
if (expWithoutPrestiges < expForEasyLevel) {
|
||||
break
|
||||
}
|
||||
level++
|
||||
expWithoutPrestiges -= expForEasyLevel
|
||||
}
|
||||
return level + expWithoutPrestiges / 5000
|
||||
}
|
||||
|
||||
module.exports = { bedwarsLevel }
|
||||
56
src/utils/functions/guild.js
Normal file
56
src/utils/functions/guild.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Code used from the slothpixel project https://github.com/slothpixel/core
|
||||
*/
|
||||
function guildLevel(exp) {
|
||||
const EXP_NEEDED = [
|
||||
100000,
|
||||
150000,
|
||||
250000,
|
||||
500000,
|
||||
750000,
|
||||
1000000,
|
||||
1250000,
|
||||
1500000,
|
||||
2000000,
|
||||
2500000,
|
||||
2500000,
|
||||
2500000,
|
||||
2500000,
|
||||
2500000,
|
||||
3000000,
|
||||
]
|
||||
|
||||
let level = 0
|
||||
|
||||
// Increments by one from zero to the level cap
|
||||
for (let i = 0; i <= 1000; i += 1) {
|
||||
// need is the required exp to get to the next level
|
||||
let need = 0
|
||||
if (i >= EXP_NEEDED.length) {
|
||||
need = EXP_NEEDED[EXP_NEEDED.length - 1]
|
||||
} else { need = EXP_NEEDED[i] }
|
||||
|
||||
// If the required exp to get to the next level isn't met returns
|
||||
// the current level plus progress towards the next (unused exp/need)
|
||||
// Otherwise increments the level and substracts the used exp from exp var
|
||||
if ((exp - need) < 0) {
|
||||
return Math.round((level + (exp / need)) * 100) / 100
|
||||
}
|
||||
level += 1
|
||||
exp -= need
|
||||
}
|
||||
|
||||
// Returns the level cap - currently 1000
|
||||
// If changed here, also change in for loop above
|
||||
return 1000
|
||||
}
|
||||
/*
|
||||
Code used from the hypixel-guild-bot project https://github.com/SimplyNo/hypixel-guild-bot
|
||||
*/
|
||||
function scaledGEXP(input) {
|
||||
if (input <= 200000) return Number(input)
|
||||
if (input <= 700000) return Number(Math.round(((input - 200000) / 10) + 200000))
|
||||
if (input > 700000) return Number(Math.round(((input - 700000) / 33) + 250000))
|
||||
}
|
||||
|
||||
module.exports = { guildLevel, scaledGEXP }
|
||||
37
src/utils/functions/hypixel.js
Normal file
37
src/utils/functions/hypixel.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Code used from the slothpixel project https://github.com/slothpixel/core
|
||||
*/
|
||||
const BASE = 10000
|
||||
const GROWTH = 2500
|
||||
const HALF_GROWTH = 0.5 * GROWTH
|
||||
const REVERSE_PQ_PREFIX = -(BASE - 0.5 * GROWTH) / GROWTH
|
||||
const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX
|
||||
const GROWTH_DIVIDES_2 = 2 / GROWTH
|
||||
|
||||
function getLevel(exp) {
|
||||
return exp <= 1 ? 1 : Math.floor(1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp))
|
||||
}
|
||||
|
||||
function hypixelLevel(exp) {
|
||||
return getLevel(exp) + getPercentageToNextLevel(exp)
|
||||
}
|
||||
|
||||
function getTotalExpToLevel(level) {
|
||||
const lv = Math.floor(level); const
|
||||
x0 = getTotalExpToFullLevel(lv)
|
||||
if (level === lv) return x0
|
||||
return (getTotalExpToFullLevel(lv + 1) - x0) * (level % 1) + x0
|
||||
}
|
||||
|
||||
function getTotalExpToFullLevel(level) {
|
||||
return (HALF_GROWTH * (level - 2) + BASE) * (level - 1)
|
||||
}
|
||||
|
||||
function getPercentageToNextLevel(exp) {
|
||||
const lv = getLevel(exp)
|
||||
const x0 = getTotalExpToLevel(lv)
|
||||
return (exp - x0) / (getTotalExpToLevel(lv + 1) - x0)
|
||||
}
|
||||
|
||||
|
||||
module.exports = { hypixelLevel }
|
||||
20
src/utils/functions/skywars.js
Normal file
20
src/utils/functions/skywars.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Code used from the slothpixel project https://github.com/slothpixel/core
|
||||
*/
|
||||
function skywarsLevel(xp) {
|
||||
let xps = [0, 20, 70, 150, 250, 500, 1000, 2000, 3500, 6000, 10000, 15000]
|
||||
let exactLevel = 0
|
||||
if (xp >= 15000) {
|
||||
exactLevel = (xp - 15000) / 10000 + 12
|
||||
return exactLevel
|
||||
} else {
|
||||
for (i = 0; i < xps.length; i++) {
|
||||
if (xp < xps[i]) {
|
||||
exactLevel = i + (xp - xps[i - 1]) / (xps[i] - xps[i - 1])
|
||||
return exactLevel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { skywarsLevel }
|
||||
5
src/utils/functions/uuid.js
Normal file
5
src/utils/functions/uuid.js
Normal file
@@ -0,0 +1,5 @@
|
||||
function formatUuid(uuid) {
|
||||
return uuid.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5")
|
||||
}
|
||||
|
||||
module.exports = { formatUuid }
|
||||
20
src/utils/utils.js
Normal file
20
src/utils/utils.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { skywarsLevel } = require("./functions/skywars.js")
|
||||
const { bedwarsLevel } = require("./functions/bedwars.js")
|
||||
const { hypixelLevel } = require("./functions/hypixel.js")
|
||||
const { formatUuid } = require("./functions/uuid.js")
|
||||
const { guildLevel, scaledGEXP } = require("./functions/guild.js")
|
||||
const { getUUID, getIGN, getPlayer, getGuild, getHeadURL } = require("./functions/account.js")
|
||||
|
||||
module.exports = {
|
||||
skywarsLevel,
|
||||
bedwarsLevel,
|
||||
hypixelLevel,
|
||||
guildLevel,
|
||||
scaledGEXP,
|
||||
getUUID,
|
||||
getIGN,
|
||||
getPlayer,
|
||||
getGuild,
|
||||
getHeadURL,
|
||||
formatUuid
|
||||
}
|
||||
Reference in New Issue
Block a user