Making all files use prettier

Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
2023-08-31 13:22:52 +02:00
parent 593f5544f7
commit 5aa85986cd
49 changed files with 4020 additions and 3779 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
node_modules/* node_modules/*
.env .env
.prettierrc
.editorconfig .editorconfig

View File

@@ -1,26 +1,25 @@
docker-build: docker-build:
image: docker:latest image: docker:latest
stage: build stage: build
services: services:
- docker:dind - docker:dind
before_script: before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# Default branch leaves tag empty (= latest tag) # Default branch leaves tag empty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug) # All other branches are tagged with the escaped branch name (commit ref slug)
script: script:
- | - |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag="" tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'" echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else else
tag=":$CI_COMMIT_REF_SLUG" tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi fi
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" . - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
- docker push "$CI_REGISTRY_IMAGE${tag}" - docker push "$CI_REGISTRY_IMAGE${tag}"
# Run this job in a branch where a Dockerfile exists # Run this job in a branch where a Dockerfile exists
rules: rules:
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH
exists: exists:
- Dockerfile - Dockerfile

View File

@@ -1,34 +1,35 @@
const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention} = require('discord.js'); const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention } = require("discord.js");
module.exports = { module.exports = {
name: 'congratsmessage', name: "congratsmessage",
description: 'Congratulate a user.', description: "Congratulate a user.",
type: 'contextmenu', type: "contextmenu",
data: new ContextMenuCommandBuilder() data: new ContextMenuCommandBuilder()
.setName('Congratulate') .setName("Congratulate")
.setType(ApplicationCommandType.Message) .setType(ApplicationCommandType.Message)
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages), .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
async execute(interaction) { async execute(interaction) {
const { targetId } = interaction;
const { targetId } = interaction
const message = await interaction.channel.messages.fetch(targetId); const message = await interaction.channel.messages.fetch(targetId);
if (!message) { if (!message) {
return interaction.reply({ content: 'That user does not exist.', ephemeral: true }); return interaction.reply({ content: "That user does not exist.", ephemeral: true });
} }
const target = message.author; const target = message.author;
await message.reply({ await message.reply({
embeds:[{ embeds: [
title: 'Congratulations!', {
description: `GG to ${userMention(target.id)}!`, title: "Congratulations!",
}] description: `GG to ${userMention(target.id)}!`,
},
],
}); });
await message.react('🎉'); await message.react("🎉");
await interaction.reply({ content: `Sent a congrats message`, ephemeral: true }); await interaction.reply({ content: `Sent a congrats message`, ephemeral: true });
} },
}; };

View File

@@ -1,34 +1,36 @@
const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } = require('discord.js'); const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } = require("discord.js");
module.exports = { module.exports = {
name: 'resetnick', name: "resetnick",
description: 'Reset your nickname.', description: "Reset your nickname.",
type: 'contextmenu', type: "contextmenu",
data: new ContextMenuCommandBuilder() data: new ContextMenuCommandBuilder()
.setName('Reset Nickname') .setName("Reset Nickname")
.setType(ApplicationCommandType.User) .setType(ApplicationCommandType.User)
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames), .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames),
async execute(interaction) { async execute(interaction) {
const { targetId } = interaction;
const { targetId } = interaction
const target = await interaction.guild.members.fetch(targetId); const target = await interaction.guild.members.fetch(targetId);
if (!target) { if (!target) {
return interaction.reply({ content: 'That user does not exist.', ephemeral: true }); return interaction.reply({ content: "That user does not exist.", ephemeral: true });
} }
if (target.id === interaction.user.id) { if (target.id === interaction.user.id) {
return interaction.reply({ content: 'You can\'t reset your own nickname.', ephemeral: true }); return interaction.reply({ content: "You can't reset your own nickname.", ephemeral: true });
} }
if (!target.manageable) { if (!target.manageable) {
return interaction.reply({ content: 'I cannot reset that user\'s nickname.', ephemeral: true }); 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); 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 }); return interaction.reply({ content: `Reset ${target.user.username}'s nickname.`, ephemeral: true });
} },
}; };

View File

@@ -1,34 +1,24 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const getuuid = require('../utils/functions'); const getuuid = require("../utils/functions");
module.exports = { module.exports = {
name: 'dev-info', name: "dev-info",
description: 'Test command for the bot.', description: "Test command for the bot.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('dev-info') .setName("dev-info")
.setDescription('Test command for the bot.') .setDescription("Test command for the bot.")
.addStringOption(option => .addStringOption((option) => option.setName("test").setDescription("Test option."))
option .addStringOption((option) => option.setName("test2").setDescription("Test option."))
.setName('test') .addStringOption((option) => option.setName("test3").setDescription("Test option."))
.setDescription('Test option.'))
.addStringOption(option =>
option
.setName('test2')
.setDescription('Test option.'))
.addStringOption(option =>
option
.setName('test3')
.setDescription('Test option.'))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
const test = interaction.options.getString("test");
const test = interaction.options.getString('test'); const test2 = interaction.options.getString("test2");
const test2 = interaction.options.getString('test2'); const test3 = interaction.options.getString("test3");
const test3 = interaction.options.getString('test3');
const message = await interaction.channel.messages.fetch(test); const message = await interaction.channel.messages.fetch(test);
const embed = message.embeds[0]; const embed = message.embeds[0];
@@ -37,6 +27,6 @@ module.exports = {
console.log(field1.value); console.log(field1.value);
await interaction.reply({ content: 'Test command.', ephemeral: true }); await interaction.reply({ content: "Test command.", ephemeral: true });
} },
}; };

View File

@@ -1,88 +1,87 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const dev = process.env.DEV; const dev = process.env.DEV;
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
const { admin, helper, muted } = require('../config/roles.json'); const { admin, helper, muted } = require("../config/roles.json");
const { staffOtherChannel } = require('../config/options.json'); const { staffOtherChannel } = require("../config/options.json");
module.exports = { module.exports = {
name: 'mute', name: "mute",
description: 'Mute a user', description: "Mute a user",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('mute') .setName("mute")
.setDescription('Mute a user') .setDescription("Mute a user")
.addUserOption(option => .addUserOption((option) => option.setName("user").setDescription("The user to mute").setRequired(true))
option .addStringOption((option) => option.setName("reason").setDescription("The reason for the mute"))
.setName('user') .addStringOption((option) => option.setName("duration").setDescription("The duration of the mute"))
.setDescription('The user to mute')
.setRequired(true))
.addStringOption(option =>
option
.setName('reason')
.setDescription('The reason for the mute'))
.addStringOption(option =>
option
.setName('duration')
.setDescription('The duration of the mute'))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
const member1 = interaction.options.getUser("user");
const member1 = interaction.options.getUser('user');
const member = interaction.guild.members.cache.get(member1.id); const member = interaction.guild.members.cache.get(member1.id);
const reason = interaction.options.getString('reason') ?? 'No reason provided'; const reason = interaction.options.getString("reason") ?? "No reason provided";
const duration = interaction.options.getString('duration'); const duration = interaction.options.getString("duration");
const guild = interaction.guild; const guild = interaction.guild;
const embedColor = Number(color.replace('#', '0x')); const embedColor = Number(color.replace("#", "0x"));
const userRoles = await guild.members.fetch(interaction.user.id).then(member => member.roles.cache.map(role => role.id)); const userRoles = await guild.members
const memberRoles = await guild.members.fetch(member1.id).then(member => member.roles.cache.map(role => role.id)); .fetch(interaction.user.id)
.then((member) => member.roles.cache.map((role) => role.id));
const memberRoles = await guild.members
.fetch(member1.id)
.then((member) => member.roles.cache.map((role) => role.id));
await interaction.deferReply({}); await interaction.deferReply({});
if (!userRoles.includes(admin || helper)) { if (!userRoles.includes(admin || helper)) {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "You don't have permission to use this command.", {
color: embedColor, description: "You don't have permission to use this command.",
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
},
],
}); });
return return;
} }
if (member.id === interaction.user.id) { if (member.id === interaction.user.id) {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "You can't mute yourself.", {
color: embedColor, description: "You can't mute yourself.",
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
},
],
}); });
return return;
} }
if (member.id === dev) { if (member.id === dev) {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "You can't mute my developer.", {
color: embedColor, description: "You can't mute my developer.",
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
},
],
}); });
return return;
} }
// if (memberRoles.includes(admin) || memberRoles.includes(helper)) { // if (memberRoles.includes(admin) || memberRoles.includes(helper)) {
@@ -102,25 +101,27 @@ module.exports = {
if (!duration) { if (!duration) {
await member.roles.add(muted, reason); await member.roles.add(muted, reason);
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Successfully muted " + userMention(member1.id) + " forever.", {
color: embedColor, description: "Successfully muted " + userMention(member1.id) + " forever.",
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
}) },
return ],
});
return;
} }
console.log(duration); console.log(duration);
const weeks = duration.replace(/[0-9][dhms]/g, '').replace(/w/g, '') const weeks = duration.replace(/[0-9][dhms]/g, "").replace(/w/g, "");
const days = duration.replace(/[0-9][whms]/g, '').replace(/d/g, '') const days = duration.replace(/[0-9][whms]/g, "").replace(/d/g, "");
const hours = duration.replace(/[0-9][wdms]/g, '').replace(/h/g, '') const hours = duration.replace(/[0-9][wdms]/g, "").replace(/h/g, "");
const minutes = duration.replace(/[0-9][wdhs]/g, '').replace(/m/g, '') const minutes = duration.replace(/[0-9][wdhs]/g, "").replace(/m/g, "");
const seconds = duration.replace(/[0-9][wdhm]/g, '').replace(/s/g, '') const seconds = duration.replace(/[0-9][wdhm]/g, "").replace(/s/g, "");
const nweeks = Number(weeks) ?? 0; const nweeks = Number(weeks) ?? 0;
const ndays = Number(days) ?? 0; const ndays = Number(days) ?? 0;
@@ -129,18 +130,25 @@ module.exports = {
const nseconds = Number(seconds) ?? 0; const nseconds = Number(seconds) ?? 0;
const time = nweeks * 604800000 + ndays * 86400000 + nhours * 3600000 + nminutes * 60000 + nseconds * 1000; const time = nweeks * 604800000 + ndays * 86400000 + nhours * 3600000 + nminutes * 60000 + nseconds * 1000;
const mutedTime = (nweeks > 0 ? nweeks + " week(s), " : "") + (ndays > 0 ? ndays + " day(s), " : "") + (nhours > 0 ? nhours + " hour(s), " : "") + (nminutes > 0 ? nminutes + " minute(s), " : "") + (nseconds > 0 ? nseconds + " second(s)" : ""); const mutedTime =
(nweeks > 0 ? nweeks + " week(s), " : "") +
(ndays > 0 ? ndays + " day(s), " : "") +
(nhours > 0 ? nhours + " hour(s), " : "") +
(nminutes > 0 ? nminutes + " minute(s), " : "") +
(nseconds > 0 ? nseconds + " second(s)" : "");
await member.roles.add(muted, reason); await member.roles.add(muted, reason);
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Successfully muted " + userMention(member1.id) + " for " + mutedTime + ".", {
color: embedColor, description: "Successfully muted " + userMention(member1.id) + " for " + mutedTime + ".",
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
},
],
}); });
const logChannel = interaction.guild.channels.cache.get(staffOtherChannel); const logChannel = interaction.guild.channels.cache.get(staffOtherChannel);
@@ -148,15 +156,17 @@ module.exports = {
setTimeout(async () => { setTimeout(async () => {
await member.roles.remove(muted, "Mute duration has ended."); await member.roles.remove(muted, "Mute duration has ended.");
await logChannel.send({ await logChannel.send({
embeds: [{ embeds: [
description: userMention(member1.id) + " has been unmuted.", {
color: embedColor, description: userMention(member1.id) + " has been unmuted.",
footer: { color: embedColor,
text: "ID: " + member1.id, footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: "ID: " + member1.id,
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
}) },
],
});
}, time); }, time);
} },
}; };

View File

@@ -7,198 +7,212 @@ const fetch = require("axios");
const { getExactLevel, skywarsLevel, getLevelForExp } = require("../utils/functions.js"); const { getExactLevel, skywarsLevel, getLevelForExp } = require("../utils/functions.js");
module.exports = { module.exports = {
name: "check", name: "check",
description: "Check a player's stats.", description: "Check a player's stats.",
type: "slash", type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("check") .setName("check")
.setDescription("Check a player's stats.") .setDescription("Check a player's stats.")
.addStringOption((option) => option.setName("ign") .addStringOption((option) => option.setName("ign").setDescription("The player's IGN.").setRequired(true))
.setDescription("The player's IGN.") .setDMPermission(false),
.setRequired(true))
.setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({}); await interaction.deferReply({});
const ign = interaction.options.getString("ign"); const ign = interaction.options.getString("ign");
const mojang = "https://api.mojang.com/users/profiles/minecraft/"; const mojang = "https://api.mojang.com/users/profiles/minecraft/";
const hypixel = "https://api.hypixel.net/player" const hypixel = "https://api.hypixel.net/player";
const guildAPI = "https://api.hypixel.net/guild" const guildAPI = "https://api.hypixel.net/guild";
const minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const head = minotar + ign; const head = minotar + ign;
if (!ign) { if (!ign) {
await interaction.editReply("Please provide a player's IGN."); await interaction.editReply("Please provide a player's IGN.");
return; return;
}
try {
await fetch(mojang + ign);
} catch (error) {
interaction.editReply({
embeds: [
{ description: "That player doesn't exist.", color: embedColor }
]
});
return;
}
const userCheck = await fetch(mojang + ign);
const uuid = userCheck.data.id;
const player = hypixel + "?key=" + hypixelApiKey + "&uuid=" + uuid
const stats = await fetch(player);
if (!stats.data.player) {
interaction.editReply({
embeds: [{
description: "That player hasn't played Hypixel before.",
color: embedColor
}]
});
return;
}
const rank2 = stats.data.player.newPackageRank;
const monthlyRank = stats.data.player.monthlyPackageRank;
if (rank2 === 'VIP') {
var rank = "[VIP] "
} else if (rank2 === 'VIP_PLUS') {
var rank = "[VIP+] "
} else if (rank2 === 'MVP') {
var rank = "[MVP] "
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'NONE') {
var rank = "[MVP+] "
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'SUPERSTAR') {
var rank = "[MVP++] "
} }
const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + uuid try {
const guildCheck = await fetch(guild); await fetch(mojang + ign);
} catch (error) {
interaction.editReply({
embeds: [{ description: "That player doesn't exist.", color: embedColor }],
});
return;
}
if (!guildCheck.data.guild) { const userCheck = await fetch(mojang + ign);
var guildName = "None"; const uuid = userCheck.data.id;
} else {
var guildName = guildCheck.data.guild.name;
}
if (!guildCheck.data.guild) { const player = hypixel + "?key=" + hypixelApiKey + "&uuid=" + uuid;
var guildTag = "" const stats = await fetch(player);
} else if (!guildCheck.data.guild.tag) {
var guildTag = ""
} else {
var guildTag = " [" + guildCheck.data.guild.tag + "]"
}
//bedwars level if (!stats.data.player) {
const hsbwexp = stats.data.player.stats.Bedwars.Experience; interaction.editReply({
const hsbwstars = getLevelForExp(hsbwexp); embeds: [
// bedwars fkdr {
const hsbwfk = stats.data.player.stats.Bedwars.final_kills_bedwars; description: "That player hasn't played Hypixel before.",
const hsbwfd = stats.data.player.stats.Bedwars.final_deaths_bedwars; color: embedColor,
const hsbwfkdr = hsbwfk / hsbwfd; },
// bedwars wins ],
const hsbwwins = stats.data.player.stats.Bedwars.wins_bedwars; });
// skywars level return;
const hsswexp = stats.data.player.stats.SkyWars.skywars_experience; }
const hsswstars = skywarsLevel(hsswexp);
// skywars kdr
const hsswkills = stats.data.player.stats.SkyWars.kills;
const hsswdeaths = stats.data.player.stats.SkyWars.deaths;
const hsswkd = hsswkills / hsswdeaths;
//skywars wins
const hsswwins = stats.data.player.stats.SkyWars.wins;
// dueks kdr
const hsduelskills = stats.data.player.stats.Duels.kills
const hsduelsdeaths = stats.data.player.stats.Duels.deaths
const hsduelskd = hsduelskills / hsduelsdeaths
// duels wins
const hsduelswins = stats.data.player.stats.Duels.wins;
// duels wlr
const hsduelslosses = stats.data.player.stats.Duels.losses;
const hsduelswlr = hsduelswins / hsduelslosses;
// network level
const hypixelExp = stats.data.player.networkExp;
const level = getExactLevel(hypixelExp);
if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) { const rank2 = stats.data.player.newPackageRank;
var bwtitle = const monthlyRank = stats.data.player.monthlyPackageRank;
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements.";
} else {
var bwtitle =
"<a:check_a:1087808632172847134> This player meets the BedWars requirements.";
}
if (hsswstars < swstars) { if (rank2 === "VIP") {
var swtitle = var rank = "[VIP] ";
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."; } else if (rank2 === "VIP_PLUS") {
} else { var rank = "[VIP+] ";
var swtitle = } else if (rank2 === "MVP") {
"<a:check_a:1087808632172847134> This player meets the SkyWars requirements."; var rank = "[MVP] ";
} } else if (rank2 === "MVP_PLUS" && monthlyRank === "NONE") {
var rank = "[MVP+] ";
} else if (rank2 === "MVP_PLUS" && monthlyRank === "SUPERSTAR") {
var rank = "[MVP++] ";
}
if (hsduelswins < duelswins || hsduelswlr < duelswlr) { const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + uuid;
var duelstitle = const guildCheck = await fetch(guild);
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements.";
} else {
var duelstitle =
"<a:check_a:1087808632172847134> This player meets the Duels requirements.";
}
await interaction.editReply({ if (!guildCheck.data.guild) {
embeds: [{ var guildName = "None";
title: rank + stats.data.player.displayname + guildTag, } else {
description: "**Network Level:** `" + var guildName = guildCheck.data.guild.name;
level.toFixed(2).toString() + "`\n" + }
"**Current Guild:** `" + guildName + "`",
color: embedColor, if (!guildCheck.data.guild) {
thumbnail: { url: head }, var guildTag = "";
footer: { } else if (!guildCheck.data.guild.tag) {
text: interaction.guild.name + " | Developed by @Taken#0002", var guildTag = "";
icon_url: interaction.guild.iconURL() } else {
}, var guildTag = " [" + guildCheck.data.guild.tag + "]";
fields: [ }
{
name: bwtitle, //bedwars level
value: "**➺ Stars:** `" + const hsbwexp = stats.data.player.stats.Bedwars.Experience;
hsbwstars.toFixed(2).toString() + " / " + const hsbwstars = getLevelForExp(hsbwexp);
bwstars.toString() + "`\n" + // bedwars fkdr
"**➺ FKDR:** `" + const hsbwfk = stats.data.player.stats.Bedwars.final_kills_bedwars;
hsbwfkdr.toFixed(2).toString() + const hsbwfd = stats.data.player.stats.Bedwars.final_deaths_bedwars;
" / " + bwfkdr.toString() + "`\n" + const hsbwfkdr = hsbwfk / hsbwfd;
"**➺ Wins:** `" + // bedwars wins
hsbwwins.toString() + " / " + const hsbwwins = stats.data.player.stats.Bedwars.wins_bedwars;
bwwins.toString() + "`" // skywars level
}, const hsswexp = stats.data.player.stats.SkyWars.skywars_experience;
{ const hsswstars = skywarsLevel(hsswexp);
name: swtitle, // skywars kdr
value: const hsswkills = stats.data.player.stats.SkyWars.kills;
"**➺ Stars:** `" + const hsswdeaths = stats.data.player.stats.SkyWars.deaths;
hsswstars.toFixed(2).toString() + const hsswkd = hsswkills / hsswdeaths;
" / " + swstars.toString() + "`\n" + //skywars wins
"**➺ KDR:** `" + const hsswwins = stats.data.player.stats.SkyWars.wins;
hsswkd.toFixed(2).toString() + // dueks kdr
"`\n" + const hsduelskills = stats.data.player.stats.Duels.kills;
"**➺ Wins:** `" + const hsduelsdeaths = stats.data.player.stats.Duels.deaths;
hsswwins.toString() + "`" const hsduelskd = hsduelskills / hsduelsdeaths;
}, // duels wins
{ const hsduelswins = stats.data.player.stats.Duels.wins;
name: duelstitle, // duels wlr
value: "**➺ Wins:** `" + const hsduelslosses = stats.data.player.stats.Duels.losses;
hsduelswins.toString() + const hsduelswlr = hsduelswins / hsduelslosses;
" / " + duelswins.toString() + "`\n" + // network level
"**➺ WLR:** `" + const hypixelExp = stats.data.player.networkExp;
hsduelswlr.toFixed(2).toString() + const level = getExactLevel(hypixelExp);
" / " + duelswlr.toString() + "`\n" +
"**➺ KDR:** `" + if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
hsduelskd.toFixed(2).toString() + "`" var bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements.";
} } else {
] var bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements.";
}] }
});
} if (hsswstars < swstars) {
var swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements.";
} else {
var swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements.";
}
if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
var duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements.";
} else {
var duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements.";
}
await interaction.editReply({
embeds: [
{
title: rank + stats.data.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() +
"`",
},
],
},
],
});
},
}; };

View File

@@ -1,219 +1,239 @@
const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, } = require("discord.js"); const {
SlashCommandBuilder,
PermissionFlagsBits,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
} = require("discord.js");
const { color } = require("../config/options.json"); const { color } = require("../config/options.json");
module.exports = { module.exports = {
name: "config", name: "config",
description: "Configure the bot.", description: "Configure the bot.",
type: "slash", type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("config") .setName("config")
.setDescription("Configure the bot.") .setDescription("Configure the bot.")
.addSubcommand((subcommand) => .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 subcommand
.setName("sendverfiymessage") .setName("sendguildapplication")
.setDescription("Send the verfiy message to a channel.") .setDescription("Send the application message to a channel.")
.addChannelOption((option) => .addChannelOption((option) =>
option option
.setName("channel") .setName("channel")
.setDescription("The channel to send the verfiy message to.") .setDescription("The channel to send the application to.")
.setRequired(true))) .setRequired(true),
.addSubcommand((subcommand) => ),
)
.addSubcommand((subcommand) =>
subcommand subcommand
.setName("sendwaitinglistmessage") .setName("sendstaffapplication")
.setDescription("Send the waiting list message to a channel.") .setDescription("Send the application message to a channel.")
.addChannelOption((option) => .addChannelOption((option) =>
option option
.setName("channel") .setName("channel")
.setDescription("The channel to send the waiting list message to.") .setDescription("The channel to send the application to.")
.setRequired(true))) .setRequired(true),
.addSubcommand((subcommand) => ),
subcommand )
.setName("sendinactivityapplication") .addSubcommand((subcommand) =>
.setDescription("Send the application message to a channel.") subcommand
.addChannelOption((option) => .setName("sendverfiymessage")
option .setDescription("Send the verfiy message to a channel.")
.setName("channel") .addChannelOption((option) =>
.setDescription("The channel to send the application to.") option
.setRequired(true))) .setName("channel")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDescription("The channel to send the verfiy message to.")
.setDMPermission(false), .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),
async execute(interaction) { async execute(interaction) {
const user = interaction.user; const user = interaction.user;
const guild = interaction.guild; const guild = interaction.guild;
const subcommand = interaction.options.getSubcommand(); const subcommand = interaction.options.getSubcommand();
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
if (subcommand === "sendguildapplication") {
const channel = interaction.options.getChannel("channel");
if (subcommand === "sendguildapplication") { await channel.send({
const channel = interaction.options.getChannel("channel"); 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 });
}
await channel.send({ if (subcommand === "sendstaffapplication") {
embeds: [ const channel = interaction.options.getChannel("channel");
{
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") { await channel.send({
const channel = interaction.options.getChannel("channel"); 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 channel.send({ await interaction.reply({ content: "Message sent", ephemeral: true });
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");
if (subcommand === "sendinactivityapplication") { await channel.send({
const channel = interaction.options.getChannel("channel"); 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 channel.send({ await interaction.reply({ content: "Message sent", ephemeral: true });
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") { if (subcommand === "sendverfiymessage") {
const channel = interaction.options.getChannel("channel"); const channel = interaction.options.getChannel("channel");
await channel.send({ await channel.send({
embeds: [{ embeds: [
title: "Verification", {
description: "You can verify by clicking the button below.", title: "Verification",
color: embedColor, description: "You can verify by clicking the button below.",
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
iconURL: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
}, iconURL: interaction.guild.iconURL({ dynamic: true }),
thumbnail: { },
url: interaction.guild.iconURL({ dynamic: true }) thumbnail: {
} url: interaction.guild.iconURL({ dynamic: true }),
}], },
components: [ },
new ActionRowBuilder() ],
.addComponents(new ButtonBuilder() components: [
.setCustomId("verifybutton") new ActionRowBuilder().addComponents(
.setLabel("Verify") new ButtonBuilder()
.setStyle(ButtonStyle.Primary) .setCustomId("verifybutton")
.setEmoji({ name: "✅" })) .setLabel("Verify")
] .setStyle(ButtonStyle.Primary)
}); .setEmoji({ name: "✅" }),
await interaction.reply({ content: "Message sent", ephemeral: true }); ),
],
});
await interaction.reply({ content: "Message sent", ephemeral: true });
} }
if (subcommand === "sendwaitinglistmessage") { if (subcommand === "sendwaitinglistmessage") {
const channel = interaction.options.getChannel("channel"); const channel = interaction.options.getChannel("channel");
await channel.send({ await channel.send({
embeds: [{ embeds: [
title: "Waiting List", {
description: "The people below were accepted into the guild\n" + title: "Waiting List",
"Try to invite them in order.", description: "The people below were accepted into the guild\n" + "Try to invite them in order.",
color: embedColor, color: embedColor,
footer: { footer: {
text: interaction.guild.name + " | Developed by @Taken#0002", text: interaction.guild.name + " | Developed by @Taken#0002",
iconURL: interaction.guild.iconURL({ dynamic: true }) iconURL: interaction.guild.iconURL({ dynamic: true }),
}, },
thumbnail: { thumbnail: {
url: interaction.guild.iconURL({ dynamic: true }) url: interaction.guild.iconURL({ dynamic: true }),
} },
}], },
components: [ ],
new ActionRowBuilder() components: [
.addComponents(new ButtonBuilder() new ActionRowBuilder().addComponents(
.setCustomId("waitinglistupdate") new ButtonBuilder()
.setLabel("Update") .setCustomId("waitinglistupdate")
.setStyle(ButtonStyle.Primary) .setLabel("Update")
.setEmoji({ name: "🔄" })) .setStyle(ButtonStyle.Primary)
] .setEmoji({ name: "🔄" }),
}); ),
await interaction.reply({ content: "Message sent", ephemeral: true }); ],
} });
await interaction.reply({ content: "Message sent", ephemeral: true });
} }
},
}; };

View File

@@ -1,70 +1,60 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention, EmbedBuilder, ChannelType } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits, userMention, EmbedBuilder, ChannelType } = require("discord.js");
const { hypixelGuildID, color } = require('../config/options.json'); const { hypixelGuildID, color } = require("../config/options.json");
const { muted } = require('../config/roles.json'); const { muted } = require("../config/roles.json");
const verify = require('../schemas/verifySchema.js'); const verify = require("../schemas/verifySchema.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const dev = process.env.DEV; const dev = process.env.DEV;
const fetch = require('axios'); const fetch = require("axios");
module.exports = { module.exports = {
name: 'admin', name: "admin",
description: 'Admin command.', description: "Admin command.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('devel') .setName("devel")
.setDescription('Admin command.') .setDescription("Admin command.")
.addSubcommand(subcommand => .addSubcommand((subcommand) => subcommand.setName("reload").setDescription("Reload the bot."))
.addSubcommand((subcommand) => subcommand.setName("listallverified").setDescription("List all verified users."))
.addSubcommand((subcommand) =>
subcommand subcommand
.setName('reload') .setName("purgereactions")
.setDescription('Reload the bot.')) .setDescription("Purge all reactions from a messages.")
.addSubcommand(subcommand => .addIntegerOption((option) =>
subcommand option.setName("count").setDescription("Count of messages to purge reactions from."),
.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) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
const subcommand = interaction.options.getSubcommand(); const subcommand = interaction.options.getSubcommand();
const user = interaction.user; const user = interaction.user;
const userMentioned = userMention(user.id); const userMentioned = userMention(user.id);
const guild = interaction.guild; const guild = interaction.guild;
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
if (subcommand === 'reload') { if (subcommand === "reload") {
const { exec } = require("child_process");
await interaction.reply({ content: "Reloading...", ephemeral: true });
const { exec } = require('child_process'); exec("pm2 restart 0", async (err, stdout, stderr) => {
await interaction.reply({ content: 'Reloading...', ephemeral: true })
exec('pm2 restart 0', async (err, stdout, stderr) => {
if (err) { if (err) {
await interaction.reply({ content: 'Error while reloading: ' + err, ephemeral: true }) await interaction.reply({ content: "Error while reloading: " + err, ephemeral: true });
} }
}) });
} }
if (subcommand === 'listallverified') { if (subcommand === "listallverified") {
const verifiedUsers = await verify.find();
const verifiedUsers = await verify.find() const mojang = "https://api.mojang.com/user/profile/";
const mojang = "https://api.mojang.com/user/profile/"
let embed = new EmbedBuilder() let embed = new EmbedBuilder()
.setTitle(guild.name) .setTitle(guild.name)
.setColor(embedColor) .setColor(embedColor)
.setDescription('List of all verified users') .setDescription("List of all verified users");
for (let i = 0; i < verifiedUsers.length; i++) { for (let i = 0; i < verifiedUsers.length; i++) {
const user = verifiedUsers[i]; const user = verifiedUsers[i];
const userCheck = await fetch(mojang + user.uuid); const userCheck = await fetch(mojang + user.uuid);
@@ -74,34 +64,34 @@ module.exports = {
embed.addFields({ embed.addFields({
name: "**IGN:** " + ign, name: "**IGN:** " + ign,
value: "**Discord:** " + mentionedUser value: "**Discord:** " + mentionedUser,
}) });
} }
await interaction.reply({ await interaction.reply({
embeds: [embed] embeds: [embed],
}) });
} }
if (subcommand === 'purgereactions') { if (subcommand === "purgereactions") {
const count = interaction.options.getInteger("count");
const count = interaction.options.getInteger('count'); await interaction.deferReply({});
await interaction.deferReply({})
if (user.id !== dev) { if (user.id !== dev) {
interaction.editReply({ content: 'Due to you not screwing something up this command is restricted to only ' + userMentioned, ephemeral: true }) interaction.editReply({
return content: "Due to you not screwing something up this command is restricted to only " + userMentioned,
ephemeral: true,
});
return;
} }
const messages = await interaction.channel.messages.fetch({ limit: count }); const messages = await interaction.channel.messages.fetch({ limit: count });
messages.forEach(async (message) => { messages.forEach(async (message) => {
await message.reactions.removeAll(); await message.reactions.removeAll();
}) });
await interaction.editReply(`Purged reactions from ${count} message(s).`)
await interaction.editReply(`Purged reactions from ${count} message(s).`);
} }
} },
}; };

View File

@@ -1,55 +1,67 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js");
const { color } = require("../config/options.json"); const { color } = require("../config/options.json");
const verify = require("../schemas/verifySchema.js"); const verify = require("../schemas/verifySchema.js");
const mongoose = require("mongoose"); const mongoose = require("mongoose");
const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require("../config/roles.json"); const {
const removeThese = [ gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember ] 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 = { module.exports = {
name: "forceunverify", name: "forceunverify",
description: "Force unverify a user", description: "Force unverify a user",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('forceunverify') .setName("forceunverify")
.setDescription('Force unverify a user') .setDescription("Force unverify a user")
.addUserOption(option => .addUserOption((option) =>
option option.setName("user").setDescription("The user to force unverify").setRequired(true),
.setName('user') )
.setDescription('The user to force unverify')
.setRequired(true))
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator), .setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) { async execute(interaction) {
const member1 = interaction.options.getUser('user'); const member1 = interaction.options.getUser("user");
const member = interaction.guild.members.cache.get(member1.id) const member = interaction.guild.members.cache.get(member1.id);
const embedColor = Number(color.replace('#', '0x')) const embedColor = Number(color.replace("#", "0x"));
const verifiedUser = await verify.findOne({ userID: member1.id }) const verifiedUser = await verify.findOne({ userID: member1.id });
const user = interaction.user const user = interaction.user;
if (!verifiedUser) { if (!verifiedUser) {
return interaction.reply({ return interaction.reply({
embeds: [{ embeds: [
description: "This user is not verified", {
color: embedColor, description: "This user is not verified",
}] color: embedColor,
}) },
],
});
} }
await verify.findOneAndDelete({ userID: member1.id }) await verify.findOneAndDelete({ userID: member1.id });
await member.roles.remove(removeThese) await member.roles.remove(removeThese);
await interaction.reply({ await interaction.reply({
embeds: [{ embeds: [
description: "Successfully unverified" + userMention(member1.id), {
color: embedColor, description: "Successfully unverified" + userMention(member1.id),
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by taken.lua", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by taken.lua",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
}) },
} ],
} });
},
};

View File

@@ -1,35 +1,41 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const hypixelAPIKey = process.env.HYPIXELAPIKEY; const hypixelAPIKey = process.env.HYPIXELAPIKEY;
const { hypixelGuildID, color } = require('../config/options.json'); const { hypixelGuildID, color } = require("../config/options.json");
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); const {
const verify = require('../schemas/verifySchema.js') gm,
const fetch = require('axios'); manager,
const removeThese = [gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff] moderator,
beast,
elite,
member,
trialmember,
guildRole,
guildStaff,
defaultMember,
} = require("../config/roles.json");
const verify = require("../schemas/verifySchema.js");
const fetch = require("axios");
const removeThese = [gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff];
module.exports = { module.exports = {
name: 'forceupdate', name: "forceupdate",
description: 'Force update the user', description: "Force update the user",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('forceupdate') .setName("forceupdate")
.setDescription('Force update the user') .setDescription("Force update the user")
.addUserOption(option => .addUserOption((option) => option.setName("user").setDescription("The user to force update").setRequired(true))
option
.setName('user')
.setDescription('The user to force update')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const user = interaction.options.getUser('user'); const user = interaction.options.getUser("user");
const usermentioned = userMention(user.id); const usermentioned = userMention(user.id);
const verifyData = await verify.findOne({ userID: user.id }) const verifyData = await verify.findOne({ userID: user.id });
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const user1 = interaction.guild.members.cache.get(user.id); const user1 = interaction.guild.members.cache.get(user.id);
@@ -37,252 +43,253 @@ module.exports = {
if (!verifyData) { if (!verifyData) {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "You are not verified. Please run `/verify` to verify yourself", {
color: embedColor, description: "You are not verified. Please run `/verify` to verify yourself",
thumbnail: { color: embedColor,
url: head thumbnail: {
url: head,
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
}, },
footer: { ],
text: interaction.guild.name + " | Developed by @Taken#0002", });
icon_url: interaction.guild.iconURL({ dynamic: true }) return;
}
}]
})
return
} }
const mojangAPI = "https://api.mojang.com/user/profile/" const mojangAPI = "https://api.mojang.com/user/profile/";
const guildlAPI = "https://api.hypixel.net/guild" const guildlAPI = "https://api.hypixel.net/guild";
const minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const guild = guildlAPI + "?key=" + hypixelAPIKey + "&player=" + verifyData.uuid; const guild = guildlAPI + "?key=" + hypixelAPIKey + "&player=" + verifyData.uuid;
const userCheck = await fetch(mojangAPI + verifyData.uuid); const userCheck = await fetch(mojangAPI + verifyData.uuid);
const guildCheck = await fetch(guild); const guildCheck = await fetch(guild);
const head = minotar + userCheck.data.name; const head = minotar + userCheck.data.name;
if (!guildCheck.data.guild) { if (!guildCheck.data.guild) {
var responseGuildID = null var responseGuildID = null;
} else { } else {
var responseGuildID = guildCheck.data.guild._id var responseGuildID = guildCheck.data.guild._id;
} }
if (responseGuildID !== hypixelGuildID) { if (responseGuildID !== hypixelGuildID) {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)");
}
for (let i = 0; i < removeThese.length; i++) { await interaction.editReply({
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") 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;
}
await interaction.editReply({ if (responseGuildID === hypixelGuildID) {
embeds: [{ const GuildMembers = guildCheck.data.guild.members;
description: usermentioned + " was given the the Default Member role.", const guildRank = GuildMembers.find((member) => member.uuid === verifyData.uuid).rank;
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) { if (guildRank === "Guild Master") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)");
}
const GuildMembers = guildCheck.data.guild.members; await roleManage.add(guildRole, "User was force updated.");
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank; await roleManage.add(guildStaff, "User was force updated.");
await roleManage.add(gm, "User was force updated.");
await roleManage.add(defaultMember, "User was force updated.");
if (guildRank === 'Guild Master') { 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 }),
},
},
],
});
}
for (let i = 0; i < removeThese.length; i++) { if (guildRank === "Manager") {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") 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(guildRole, "User was force updated.");
await roleManage.add(guildStaff, "User was force updated.") await roleManage.add(guildStaff, "User was force updated.");
await roleManage.add(gm, "User was force updated.") await roleManage.add(manager, "User was force updated.");
await roleManage.add(defaultMember, "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 }),
},
},
],
});
}
await interaction.editReply({ if (guildRank === "Moderator") {
embeds: [{ for (let i = 0; i < removeThese.length; i++) {
description: usermentioned + "'s rank has been updated to `Guild Master`", await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)");
color: embedColor, }
thumbnail: {
url: head
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true })
}
}]
})
}
if (guildRank === 'Manager') { 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.");
for (let i = 0; i < removeThese.length; i++) { await interaction.editReply({
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") 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 }),
},
},
],
});
}
await roleManage.add(guildRole, "User was force updated.") if (guildRank === "Beast") {
await roleManage.add(guildStaff, "User was force updated.") for (let i = 0; i < removeThese.length; i++) {
await roleManage.add(manager, "User was force updated.") await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)");
await roleManage.add(defaultMember, "User was force updated.") }
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({ await interaction.editReply({
embeds: [{ embeds: [
description: usermentioned + "'s rank has been updated to `Manager`", {
color: embedColor, description: usermentioned + "'s rank has been updated to `Beast`.",
thumbnail: { color: embedColor,
url: head thumbnail: {
}, url: head,
footer: { },
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
}) },
} ],
});
return;
}
if (guildRank === 'Moderator') { if (guildRank === "Elite") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)");
}
for (let i = 0; i < removeThese.length; i++) { await roleManage.add(guildRole, "User was force updated.");
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") await roleManage.add(elite, "User was force updated.");
} await roleManage.add(defaultMember, "User was force updated.");
await roleManage.add(guildRole, "User was force updated.") await interaction.editReply({
await roleManage.add(guildStaff, "User was force updated.") embeds: [
await roleManage.add(moderator, "User was force updated.") {
await roleManage.add(defaultMember, "User was force updated.") 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 interaction.editReply({ await roleManage.add(guildRole, "User was force updated.");
embeds: [{ await roleManage.add(member, "User was force updated.");
description: usermentioned + "'s rank has been updated to `Moderator`", await roleManage.add(defaultMember, "User was force updated.");
color: embedColor,
thumbnail: {
url: head
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true })
}
}]
})
} 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 === 'Beast') { if (guildRank === "Trial Member") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)");
}
for (let i = 0; i < removeThese.length; i++) { await roleManage.add(guildRole, "User was force updated.");
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") await roleManage.add(trialmember, "User was force updated.");
} await roleManage.add(defaultMember, "User was force updated.");
await roleManage.add(guildRole, "User was force updated.") await interaction.editReply({
await roleManage.add(beast, "User was force updated.") embeds: [
await roleManage.add(defaultMember, "User was force updated.") {
description: usermentioned + "'s rank has been updated to `Trial Member`.",
color: embedColor,
await interaction.editReply({ thumbnail: {
embeds: [{ url: head,
description: usermentioned + "'s rank has been updated to `Beast`.", },
color: embedColor, footer: {
thumbnail: { text: interaction.guild.name + " | Developed by @Taken#0002",
url: head icon_url: interaction.guild.iconURL({ dynamic: true }),
}, },
footer: { },
text: interaction.guild.name + " | Developed by @Taken#0002", ],
icon_url: interaction.guild.iconURL({ dynamic: true }) });
} return;
}] }
}) }
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
}
}
}
}

View File

@@ -1,180 +1,194 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const hypixelApiKey = process.env.HYPIXELAPIKEY; const hypixelApiKey = process.env.HYPIXELAPIKEY;
const fetch = require('axios'); const fetch = require("axios");
const { color, hypixelGuildID } = require('../config/options.json'); const { color, hypixelGuildID } = require("../config/options.json");
const verify = require('../schemas/verifySchema.js') const verify = require("../schemas/verifySchema.js");
const {mongoose} = require('mongoose'); const { mongoose } = require("mongoose");
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); const {
gm,
manager,
moderator,
beast,
elite,
member,
trialmember,
guildRole,
guildStaff,
defaultMember,
} = require("../config/roles.json");
module.exports = { module.exports = {
name: 'forceverify', name: "forceverify",
description: 'Force verify a user.', description: "Force verify a user.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('forceverify') .setName("forceverify")
.setDescription('Force verify a user.') .setDescription("Force verify a user.")
.addUserOption(option => .addUserOption((option) => option.setName("user").setDescription("The user to force verify."))
option .addStringOption((option) => option.setName("ign").setDescription("The user's in-game name."))
.setName('user')
.setDescription('The user to force verify.'))
.addStringOption(option =>
option
.setName('ign')
.setDescription('The user\'s in-game name.'))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const user1 = interaction.options.getUser('user'); const user1 = interaction.options.getUser("user");
const user = interaction.guild.members.cache.get(user1.id); const user = interaction.guild.members.cache.get(user1.id);
const ign = interaction.options.getString('ign'); const ign = interaction.options.getString("ign");
const mod = interaction.user const mod = interaction.user;
// const slothPixel = "https://api.slothpixel.me/api/players/"; // const slothPixel = "https://api.slothpixel.me/api/players/";
// const guildAPI = "https://api.slothpixel.me/api/guilds/" // const guildAPI = "https://api.slothpixel.me/api/guilds/"
const mojang = "https://api.mojang.com/users/profiles/minecraft/" const mojang = "https://api.mojang.com/users/profiles/minecraft/";
const hypixelApi = "https://api.hypixel.net/player" const hypixelApi = "https://api.hypixel.net/player";
const guildApi = "https://api.hypixel.net/guild" const guildApi = "https://api.hypixel.net/guild";
const minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
if (!user) { if (!user) {
interaction.editReply('Please provide a user to force verify.\nThis can also mean the user is not in the server.') interaction.editReply(
return "Please provide a user to force verify.\nThis can also mean the user is not in the server.",
);
return;
} }
const verifyData = await verify.findOne({ userID: user.id }) const verifyData = await verify.findOne({ userID: user.id });
if (verifyData) { if (verifyData) {
interaction.editReply('That user is already verified.') interaction.editReply("That user is already verified.");
return return;
} }
if (!ign) { if (!ign) {
interaction.editReply('Please provide a player\'s IGN.') interaction.editReply("Please provide a player's IGN.");
return return;
} }
if (user1.discriminator == "0") { if (user1.discriminator == "0") {
var username = user1.username var username = user1.username;
} else { } else {
var username = user1.username + "#" + user1.discriminator var username = user1.username + "#" + user1.discriminator;
} }
if (mod.discriminator == "0") { if (mod.discriminator == "0") {
var modName = mod.username var modName = mod.username;
} else { } else {
var modName = mod.username + "#" + mod.discriminator var modName = mod.username + "#" + mod.discriminator;
} }
try { try {
await fetch(mojang + ign); await fetch(mojang + ign);
} catch (err) { } catch (err) {
interaction.editReply('That player doesn\'t exist. [Mojang]') interaction.editReply("That player doesn't exist. [Mojang]");
return return;
} }
const userCheck = await fetch(mojang + ign); const userCheck = await fetch(mojang + ign);
const userUUID = userCheck.data.id; const userUUID = userCheck.data.id;
const player = hypixelApi + "?key=" + hypixelApiKey + "&uuid=" + userUUID const player = hypixelApi + "?key=" + hypixelApiKey + "&uuid=" + userUUID;
const guild = guildApi + "?key=" + hypixelApiKey + "&player=" + userUUID const guild = guildApi + "?key=" + hypixelApiKey + "&player=" + userUUID;
const head = minotar + ign; const head = minotar + ign;
const hypixelCheck = await fetch(player); const hypixelCheck = await fetch(player);
if (!hypixelCheck.data.player) { if (!hypixelCheck.data.player) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds: [
description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.", {
color: embedColor description:
}] "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor,
},
],
}); });
return; return;
} }
const guildCheck = await fetch(guild) const guildCheck = await fetch(guild);
if (!guildCheck.data.guild) { if (!guildCheck.data.guild) {
var responseGuildID = null var responseGuildID = null;
} else { } else {
var responseGuildID = guildCheck.data.guild._id var responseGuildID = guildCheck.data.guild._id;
} }
if (responseGuildID === hypixelGuildID) { if (responseGuildID === hypixelGuildID) {
const GuildMembers = guildCheck.data.guild.members; const GuildMembers = guildCheck.data.guild.members;
const guildRank = GuildMembers.find(member => member.uuid === hypixelCheck.data.player.uuid).rank; const guildRank = GuildMembers.find((member) => member.uuid === hypixelCheck.data.player.uuid).rank;
if (guildRank === "Guild Master") { if (guildRank === "Guild Master") {
await user.roles.add(gm, "User was force verified by " + modName); 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(guildRole, "User was force verified by " + modName);
await user.roles.add(guildStaff, "User was force verified by " + modName) await user.roles.add(guildStaff, "User was force verified by " + modName);
} }
if (guildRank === "Manager") { if (guildRank === "Manager") {
await user.roles.add(manager, "User was force verified by " + modName); 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(guildRole, "User was force verified by " + modName);
await user.roles.add(guildStaff, "User was force verified by " + modName) await user.roles.add(guildStaff, "User was force verified by " + modName);
} }
if (guildRank === "Moderator") { if (guildRank === "Moderator") {
await user.roles.add(moderator, "User was force verified by " + modName); 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(guildRole, "User was force verified by " + modName);
await user.roles.add(guildStaff, "User was force verified by " + modName) await user.roles.add(guildStaff, "User was force verified by " + modName);
} }
if (guildRank === "Beast") { if (guildRank === "Beast") {
await user.roles.add(beast, "User was force verified by " + modName); await user.roles.add(beast, "User was force verified by " + modName);
await user.roles.add(guildRole, "User was force verified by " + modName) await user.roles.add(guildRole, "User was force verified by " + modName);
} }
if (guildRank === "Elite") { if (guildRank === "Elite") {
await user.roles.add(elite, "User was force verified by " + modName); await user.roles.add(elite, "User was force verified by " + modName);
await user.roles.add(guildRole, "User was force verified by " + modName) await user.roles.add(guildRole, "User was force verified by " + modName);
} }
if (guildRank === "Member") { if (guildRank === "Member") {
await user.roles.add(member, "User was force verified by " + modName); await user.roles.add(member, "User was force verified by " + modName);
await user.roles.add(guildRole, "User was force verified by " + modName) await user.roles.add(guildRole, "User was force verified by " + modName);
} }
if (guildRank === "Trial Member") { if (guildRank === "Trial Member") {
await user.roles.add(trialmember, "User was force verified by " + modName); 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(guildRole, "User was force verified by " + modName);
} }
} }
await user.roles.add(defaultMember, "User was force verified by " + modName); await user.roles.add(defaultMember, "User was force verified by " + modName);
const newVerify = new verify({ const newVerify = new verify({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.id, userID: user.id,
uuid: userUUID uuid: userUUID,
}) });
await newVerify.save(); await newVerify.save();
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: interaction.guild.name, {
description: "You have successfully force verified `" + username + "` with the account `" + hypixelCheck.data.player.displayname + "`.", title: interaction.guild.name,
color: embedColor, description:
thumbnail: { "You have successfully force verified `" +
url: head username +
"` with the account `" +
hypixelCheck.data.player.displayname +
"`.",
color: embedColor,
thumbnail: {
url: head,
},
footer: {
icon_url: interaction.guild.iconURL(),
text: interaction.guild.name + " | Developed by Taken#0002",
},
}, },
footer: { ],
icon_url: interaction.guild.iconURL(),
text: interaction.guild.name + " | Developed by Taken#0002"
}
}]
}); });
},
}
}; };

View File

@@ -1,54 +1,51 @@
const { SlashCommandBuilder, ChannelType } = require('discord.js'); const { SlashCommandBuilder, ChannelType } = require("discord.js");
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
module.exports = { module.exports = {
name: 'help', name: "help",
description: 'Help command', description: "Help command",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder().setName("help").setDescription("Help command").setDMPermission(true),
.setName('help')
.setDescription('Help command')
.setDMPermission(true),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const embedColor = Number(color.replace('#', '0x')); const embedColor = Number(color.replace("#", "0x"));
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: 'Commands', {
description: "List of commands", title: "Commands",
fields: [ description: "List of commands",
{ fields: [
name: '/check', {
value: 'Check the stats of a player' 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: {
name: '/reqs', icon_url: interaction.guild.iconURL({ dynamic: true }),
value: 'Check the requirements of the guild' text: interaction.guild.name + " | Developed by: @Taken#0001",
}, },
{
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'
}
}]
}); });
},
}
}; };

View File

@@ -1,51 +1,54 @@
const { SlashCommandBuilder } = require('discord.js'); const { SlashCommandBuilder } = require("discord.js");
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require('../config/reqs.json'); const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require("../config/reqs.json");
module.exports = { module.exports = {
name: 'reqs', name: "reqs",
description: 'Displays the requirements for the guild.', description: "Displays the requirements for the guild.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder().setName("reqs").setDescription("Displays the requirements for the guild."),
.setName('reqs')
.setDescription('Displays the requirements for the guild.'),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: 'Requirements', {
description: '**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**', title: "Requirements",
color: embedColor, description: "**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**",
thumbnail: { color: embedColor,
url: interaction.guild.iconURL() 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(),
},
}, },
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()
}
}]
})
}
}

View File

@@ -1,41 +1,34 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
module.exports = { module.exports = {
name: 'send', name: "send",
description: 'Send a message to a channel.', description: "Send a message to a channel.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('send') .setName("send")
.setDescription('Send a message to a channel.') .setDescription("Send a message to a channel.")
.addStringOption(option => .addStringOption((option) => option.setName("message").setDescription("The message to send."))
option .addChannelOption((option) => option.setName("channel").setDescription("The channel to send the message to."))
.setName('message')
.setDescription('The message to send.'))
.addChannelOption(option =>
option
.setName('channel')
.setDescription('The channel to send the message to.'))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const message = interaction.options.getString('message'); const message = interaction.options.getString("message");
const channel = interaction.options.getChannel('channel'); const channel = interaction.options.getChannel("channel");
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
if (!message) { if (!message) {
interaction.editReply({ content: 'Please provide a message to send.', ephemeral: true }) interaction.editReply({ content: "Please provide a message to send.", ephemeral: true });
return return;
} }
if (!channel) { if (!channel) {
interaction.editReply({ content: 'Please provide a channel to send the message to.', ephemeral: true }) interaction.editReply({ content: "Please provide a channel to send the message to.", ephemeral: true });
return return;
} }
channel.send({ channel.send({
@@ -45,13 +38,13 @@ module.exports = {
description: message, description: message,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: interaction.guild.iconURL({ dynamic: true }) url: interaction.guild.iconURL({ dynamic: true }),
}, },
footer: { footer: {
text: "Developed by @Taken#0002" text: "Developed by @Taken#0002",
} },
} },
] ],
}); });
} },
}; };

View File

@@ -1,39 +1,34 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js') const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js");
module.exports = { module.exports = {
name: 'setnick', name: "setnick",
description: 'Set your nickname', description: "Set your nickname",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('setnick') .setName("setnick")
.setDescription('Set your nickname') .setDescription("Set your nickname")
.addUserOption(option => .addUserOption((option) =>
option option.setName("user").setDescription("The user to set the nickname for").setRequired(true),
.setName('user') )
.setDescription('The user to set the nickname for') .addStringOption((option) => option.setName("nickname").setDescription("The nickname to set").setRequired(true))
.setRequired(true))
.addStringOption(option =>
option
.setName('nickname')
.setDescription('The nickname to set')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames) .setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
const user = interaction.options.getUser("user");
const user = interaction.options.getUser('user'); const nickname = interaction.options.getString("nickname");
const nickname = interaction.options.getString('nickname');
const member = await interaction.guild.members.fetch(user.id); const member = await interaction.guild.members.fetch(user.id);
if (!member.manageable) { if (!member.manageable) {
return interaction.reply({ content: 'I cannot set the nickname for this user!', ephemeral: true }); return interaction.reply({ content: "I cannot set the nickname for this user!", ephemeral: true });
} }
await member.setNickname(nickname, `Set by ${interaction.user.tag}`); await member.setNickname(nickname, `Set by ${interaction.user.tag}`);
await interaction.reply({ content: "Set the nickname of " + userMention(member.id) + " to " + nickname, ephemeral: true }); await interaction.reply({
content: "Set the nickname of " + userMention(member.id) + " to " + nickname,
} ephemeral: true,
} });
},
};

View File

@@ -1,59 +1,57 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
module.exports = { module.exports = {
name: 'slowmode', name: "slowmode",
description: 'Set the slowmode of a channel.', description: "Set the slowmode of a channel.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('slowmode') .setName("slowmode")
.setDescription('Set the slowmode of a channel.') .setDescription("Set the slowmode of a channel.")
.addIntegerOption(option => .addIntegerOption((option) =>
option option.setName("seconds").setDescription("The amount of seconds to set the slowmode to."),
.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."))
.addChannelOption(option =>
option
.setName('channel')
.setDescription('The channel to set the slowmode of.'))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({ ephermeral: true }); await interaction.deferReply({ ephermeral: true });
const seconds = interaction.options.getInteger('seconds') ?? 5 const seconds = interaction.options.getInteger("seconds") ?? 5;
const channel = interaction.options.getChannel('channel') ?? interaction.channel const channel = interaction.options.getChannel("channel") ?? interaction.channel;
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
if (seconds > 21600) { if (seconds > 21600) {
await channel.setRateLimitPerUser(21600) await channel.setRateLimitPerUser(21600);
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: `Set the slowmode of ${channel} to 21600 seconds.`, {
color: embedColor, description: `Set the slowmode of ${channel} to 21600 seconds.`,
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by: @Taken#0001", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by: @Taken#0001",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
}) },
return ],
});
return;
} }
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: `Set the slowmode of ${channel} to ${seconds} seconds.`, {
color: embedColor, description: `Set the slowmode of ${channel} to ${seconds} seconds.`,
footer: { color: embedColor,
text: interaction.guild.name + " | Developed by: @Taken#0001", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by: @Taken#0001",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
}) },
await channel.setRateLimitPerUser(seconds) ],
});
} await channel.setRateLimitPerUser(seconds);
} },
};

View File

@@ -1,281 +1,289 @@
const { SlashCommandBuilder } = require('discord.js'); const { SlashCommandBuilder } = require("discord.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const hypixelApiKey = process.env.HYPIXELAPIKEY; const hypixelApiKey = process.env.HYPIXELAPIKEY;
const fetch = require('axios'); const fetch = require("axios");
const verify = require('../schemas/verifySchema.js') const verify = require("../schemas/verifySchema.js");
const { color, hypixelGuildID } = require('../config/options.json'); const { color, hypixelGuildID } = require("../config/options.json");
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.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]; const removeThese = [gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff];
module.exports = { module.exports = {
name: 'update', name: "update",
description: 'Update your guild rank.', description: "Update your guild rank.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder().setName("update").setDescription("Update your guild rank.").setDMPermission(false),
.setName('update')
.setDescription('Update your guild rank.')
.setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const user1 = interaction.user; const user1 = interaction.user;
const user = interaction.guild.members.cache.get(user1.id); const user = interaction.guild.members.cache.get(user1.id);
const verifyData = await verify.findOne({ userID: user.id }) const verifyData = await verify.findOne({ userID: user.id });
const roleManage = user.roles; const roleManage = user.roles;
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
if (!verifyData) { if (!verifyData) {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "You are not verified. Please run `/verify` to verify yourself", {
color: embedColor, description: "You are not verified. Please run `/verify` to verify yourself",
thumbnail: { color: embedColor,
url: head thumbnail: {
url: head,
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
}, },
footer: { ],
text: interaction.guild.name + " | Developed by @Taken#0002", });
icon_url: interaction.guild.iconURL({ dynamic: true }) return;
}
}]
})
return
} }
const mojangAPI = "https://api.mojang.com/user/profile/" const mojangAPI = "https://api.mojang.com/user/profile/";
const guildAPI = "https://api.hypixel.net/guild" const guildAPI = "https://api.hypixel.net/guild";
const minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const userCheck = await fetch(mojangAPI + verifyData.uuid); const userCheck = await fetch(mojangAPI + verifyData.uuid);
const head = minotar + userCheck.data.name; const head = minotar + userCheck.data.name;
const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + verifyData.uuid const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + verifyData.uuid;
const guildCheck = await fetch(guild); const guildCheck = await fetch(guild);
if (!guildCheck.data.guild) { if (!guildCheck.data.guild) {
var guildID = null var guildID = null;
} else { } else {
var guildID = guildCheck.data.guild._id var guildID = guildCheck.data.guild._id;
} }
if (guildID !== hypixelGuildID) { if (guildID !== hypixelGuildID) {
for (let i = 0; i < removeThese.length; i++) { for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)") await roleManage.remove(removeThese[i], "Auto role removal. (Update)");
} }
await roleManage.add(defaultMember, "User used the update command") await roleManage.add(defaultMember, "User used the update command");
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: "Updated your roles to `Default Member`", {
color: embedColor, description: "Updated your roles to `Default Member`",
thumbnail: { color: embedColor,
url: head thumbnail: {
url: head,
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
}, },
footer: { ],
text: interaction.guild.name + " | Developed by @Taken#0002", });
icon_url: interaction.guild.iconURL({ dynamic: true }) return;
}
}]
})
return
} }
if (guildID === hypixelGuildID) { if (guildID === hypixelGuildID) {
const GuildMembers = guildCheck.data.guild.members;
const guildRank = GuildMembers.find((member) => member.uuid === verifyData.uuid).rank;
const GuildMembers = guildCheck.data.guild.members; if (guildRank === "Guild Master") {
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank; for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)");
}
if (guildRank === 'Guild Master') { 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");
for (let i = 0; i < removeThese.length; i++) { await interaction.editReply({
await roleManage.remove(removeThese[i], "Auto role removal. (Update)") 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 }),
},
},
],
});
}
await roleManage.add(guildRole, "User used the update command") if (guildRank === "Manager") {
await roleManage.add(guildStaff, "User used the update command") for (let i = 0; i < removeThese.length; i++) {
await roleManage.add(gm, "User used the update command") await roleManage.remove(removeThese[i], "Auto role removal. (Update)");
await roleManage.add(defaultMember, "User used the update command") }
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({ await interaction.editReply({
embeds: [{ embeds: [
description: "Your rank has been updated to `Guild Master`", {
color: embedColor, description: "Your rank has been updated to `Manager`",
thumbnail: { color: embedColor,
url: head thumbnail: {
}, url: head,
footer: { },
text: interaction.guild.name + " | Developed by @Taken#0002", footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }) text: interaction.guild.name + " | Developed by @Taken#0002",
} icon_url: interaction.guild.iconURL({ dynamic: true }),
}] },
}) },
} ],
});
}
if (guildRank === 'Manager') { if (guildRank === "Moderator") {
for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)");
}
for (let i = 0; i < removeThese.length; i++) { await roleManage.add(guildRole, "User used the update command");
await roleManage.remove(removeThese[i], "Auto role removal. (Update)") 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 roleManage.add(guildRole, "User used the update command") await interaction.editReply({
await roleManage.add(guildStaff, "User used the update command") embeds: [
await roleManage.add(manager, "User used the update command") {
await roleManage.add(defaultMember, "User used the update command") 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 interaction.editReply({ await roleManage.add(guildRole, "User used the update command");
embeds: [{ await roleManage.add(beast, "User used the update command");
description: "Your rank has been updated to `Manager`", await roleManage.add(defaultMember, "User used the update command");
color: embedColor,
thumbnail: {
url: head
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true })
}
}]
})
}
if (guildRank === 'Moderator') { 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;
}
for (let i = 0; i < removeThese.length; i++) { if (guildRank === "Elite") {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)") 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(guildRole, "User used the update command");
await roleManage.add(guildStaff, "User used the update command") await roleManage.add(elite, "User used the update command");
await roleManage.add(moderator, "User used the update command") await roleManage.add(defaultMember, "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;
}
await interaction.editReply({ if (guildRank === "Member") {
embeds: [{ for (let i = 0; i < removeThese.length; i++) {
description: "Your rank has been updated to `Moderator`", await roleManage.remove(removeThese[i], "Auto role removal. (Update)");
color: embedColor, }
thumbnail: {
url: head
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true })
}
}]
})
} 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");
if (guildRank === 'Beast') { 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;
}
for (let i = 0; i < removeThese.length; i++) { if (guildRank === "Trial Member") {
await roleManage.remove(removeThese[i], "Auto role removal. (Update)") 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(guildRole, "User used the update command");
await roleManage.add(beast, "User used the update command") await roleManage.add(trialmember, "User used the update command");
await roleManage.add(defaultMember, "User used the update command") await roleManage.add(defaultMember, "User used the update command");
await interaction.editReply({
await interaction.editReply({ embeds: [
embeds: [{ {
description: "Your rank has been updated to `Beast`.", description: "Your rank has been updated to `Trial Member`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head,
}, },
footer: { footer: {
text: interaction.guild.name + " | Developed by @Taken#0002", text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true }) icon_url: interaction.guild.iconURL({ dynamic: true }),
} },
}] },
}) ],
return });
} 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
}
}
}
}; };

View File

@@ -5,7 +5,18 @@ const fetch = require("axios");
const { color, hypixelGuildID } = require("../config/options.json"); const { color, hypixelGuildID } = require("../config/options.json");
const verify = require("../schemas/verifySchema.js"); const verify = require("../schemas/verifySchema.js");
const mongoose = require("mongoose"); const mongoose = require("mongoose");
const { gm, manager, moderator, beast, elite, member, trialmember, guildRole, guildStaff, defaultMember } = require("../config/roles.json"); const {
gm,
manager,
moderator,
beast,
elite,
member,
trialmember,
guildRole,
guildStaff,
defaultMember,
} = require("../config/roles.json");
module.exports = { module.exports = {
name: "verify", name: "verify",
@@ -15,21 +26,18 @@ module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("verify") .setName("verify")
.setDescription("Verify yourself as a member of the server.") .setDescription("Verify yourself as a member of the server.")
.addStringOption((option) => .addStringOption((option) => option.setName("ign").setDescription("Your in-game name."))
option
.setName("ign")
.setDescription("Your in-game name."))
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const user1 = interaction.user const user1 = interaction.user;
const user = interaction.guild.members.cache.get(user1.id); const user = interaction.guild.members.cache.get(user1.id);
const ign = interaction.options.getString("ign"); const ign = interaction.options.getString("ign");
const mojang = "https://api.mojang.com/users/profiles/minecraft/"; const mojang = "https://api.mojang.com/users/profiles/minecraft/";
const hypixel = "https://api.hypixel.net/player" const hypixel = "https://api.hypixel.net/player";
const guildAPI = "https://api.hypixel.net/guild" const guildAPI = "https://api.hypixel.net/guild";
const minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const head = minotar + ign; const head = minotar + ign;
@@ -37,17 +45,19 @@ module.exports = {
const verifyData = await verify.findOne({ userID: user.id }); const verifyData = await verify.findOne({ userID: user.id });
if (verifyData) { if (verifyData) {
interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.") interaction.editReply("You are already verified.\n" + "Try running /update to update your roles.");
return; return;
} }
if (!ign) { if (!ign) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds: [
description: "<a:cross_a:1087808606897983539> Please provide your in-game name.", {
color: embedColor description: "<a:cross_a:1087808606897983539> Please provide your in-game name.",
}] color: embedColor,
}) },
],
});
return; return;
} }
@@ -55,10 +65,12 @@ module.exports = {
await fetch(mojang + ign); await fetch(mojang + ign);
} catch (err) { } catch (err) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds: [
description: "<a:questionmark_pink:1130206038008803488> That player does not exist.", {
color: embedColor description: "<a:questionmark_pink:1130206038008803488> That player does not exist.",
}] color: embedColor,
},
],
}); });
return; return;
} }
@@ -66,111 +78,126 @@ module.exports = {
const userCheck = await fetch(mojang + ign); const userCheck = await fetch(mojang + ign);
const userUUID = userCheck.data.id; const userUUID = userCheck.data.id;
const player = hypixel + "?key=" + hypixelApiKey + "&uuid=" + userUUID const player = hypixel + "?key=" + hypixelApiKey + "&uuid=" + userUUID;
const stats = await fetch(player); const stats = await fetch(player);
if (!stats.data.player) { if (!stats.data.player) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds: [
description: "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.", {
color: embedColor description:
}] "<a:questionmark_pink:1130206038008803488> That player hasn't played Hypixel before.",
color: embedColor,
},
],
}); });
return; return;
} }
if (user1.discriminator === "0") { if (user1.discriminator === "0") {
var username = user1.username var username = user1.username;
} else { } else {
var username = user1.username + "#" + user1.discriminator var username = user1.username + "#" + user1.discriminator;
} }
if (!stats.data.player.socialMedia.links.DISCORD) { if (!stats.data.player.socialMedia.links.DISCORD) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [
{ {
description: "<a:cross_a:1087808606897983539> There is no Discord account linked to `" + stats.data.player.displayname + "`.\n\n" + description:
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**", "<a:cross_a:1087808606897983539> There is no Discord account linked to `" +
color: embedColor stats.data.player.displayname +
} "`.\n\n" +
] "**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
}); });
return; return;
} }
const linkedDiscord = stats.data.player.socialMedia.links.DISCORD const linkedDiscord = stats.data.player.socialMedia.links.DISCORD;
if (linkedDiscord !== username) { if (linkedDiscord !== username) {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [
{ {
description: "<a:cross_a:1087808606897983539> The Discord account linked to `" + stats.data.player.displayname + "` is currently `" + linkedDiscord + "`\n\n" + description:
"**Please set your Discord tag on hypixel to `" + username + "` and try again.**", "<a:cross_a:1087808606897983539> The Discord account linked to `" +
color: embedColor stats.data.player.displayname +
} "` is currently `" +
] linkedDiscord +
"`\n\n" +
"**Please set your Discord tag on hypixel to `" +
username +
"` and try again.**",
color: embedColor,
},
],
}); });
return; return;
} }
const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + userUUID const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + userUUID;
const guildCheck = await fetch(guild); const guildCheck = await fetch(guild);
if (!guildCheck.data.guild) { if (!guildCheck.data.guild) {
var guildID = null var guildID = null;
} else { } else {
var guildID = guildCheck.data.guild._id var guildID = guildCheck.data.guild._id;
} }
if (guildID === hypixelGuildID) { if (guildID === hypixelGuildID) {
const GuildMembers = guildCheck.data.guild.members const GuildMembers = guildCheck.data.guild.members;
const guildRank = GuildMembers.find((member) => member.uuid === stats.data.player.uuid).rank; const guildRank = GuildMembers.find((member) => member.uuid === stats.data.player.uuid).rank;
if (guildRank === "Guild Master" && guildID === hypixelGuildID) { if (guildRank === "Guild Master" && guildID === hypixelGuildID) {
await user.roles.add(gm, "Verification"); await user.roles.add(gm, "Verification");
await user.roles.add(guildRole, "Verification"); await user.roles.add(guildRole, "Verification");
await user.roles.add(guildStaff, "Verification"); await user.roles.add(guildStaff, "Verification");
} }
if (guildRank === "Manager" && guildID === hypixelGuildID) { if (guildRank === "Manager" && guildID === hypixelGuildID) {
await user.roles.add(manager, "Verification"); await user.roles.add(manager, "Verification");
await user.roles.add(guildRole, "Verification"); await user.roles.add(guildRole, "Verification");
await user.roles.add(guildStaff, "Verification"); await user.roles.add(guildStaff, "Verification");
} }
if (guildRank === "Moderator" && guildID === hypixelGuildID) { if (guildRank === "Moderator" && guildID === hypixelGuildID) {
await user.roles.add(moderator, "Verification"); await user.roles.add(moderator, "Verification");
await user.roles.add(guildRole, "Verification"); await user.roles.add(guildRole, "Verification");
await user.roles.add(guildStaff, "Verification"); await user.roles.add(guildStaff, "Verification");
} }
if (guildRank === "Beast" && guildID === hypixelGuildID) { if (guildRank === "Beast" && guildID === hypixelGuildID) {
await user.roles.add(beast, "Verification"); await user.roles.add(beast, "Verification");
await user.roles.add(guildRole, "Verification"); await user.roles.add(guildRole, "Verification");
} }
if (guildRank === "Elite" && guildID === hypixelGuildID) { if (guildRank === "Elite" && guildID === hypixelGuildID) {
await user.roles.add(elite, "Verification"); await user.roles.add(elite, "Verification");
await user.roles.add(guildRole, "Verification"); await user.roles.add(guildRole, "Verification");
} }
if (guildRank === "Member" && guildID === hypixelGuildID) { if (guildRank === "Member" && guildID === hypixelGuildID) {
await user.roles.add(member, "Verification"); await user.roles.add(member, "Verification");
await user.roles.add(guildRole, "Verification"); await user.roles.add(guildRole, "Verification");
} }
if (guildRank === "Trial Member" && guildID === hypixelGuildID) { if (guildRank === "Trial Member" && guildID === hypixelGuildID) {
await user.roles.add(trialmember, "Verification"); await user.roles.add(trialmember, "Verification");
await user.roles.add(guildRole, "Verification"); await user.roles.add(guildRole, "Verification");
} }
} }
await user.roles.add(defaultMember, "Verification"); await user.roles.add(defaultMember, "Verification");
const newVerify = new verify({ const newVerify = new verify({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.id, userID: user.id,
uuid: userUUID uuid: userUUID,
}); });
await newVerify.save(); await newVerify.save();
@@ -179,17 +206,22 @@ module.exports = {
embeds: [ embeds: [
{ {
title: interaction.guild.name, title: interaction.guild.name,
description: "You have successfully verified `" + username + "` with the account `" + stats.data.player.displayname + "`.", description:
"You have successfully verified `" +
username +
"` with the account `" +
stats.data.player.displayname +
"`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head,
}, },
footer: { footer: {
icon_url: interaction.guild.iconURL(), icon_url: interaction.guild.iconURL(),
text: interaction.guild.name + " | Developed by Taken#0002" text: interaction.guild.name + " | Developed by Taken#0002",
} },
} },
] ],
}); });
} },
}; };

View File

@@ -1,38 +1,35 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js");
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
const verify = require('../schemas/verifySchema.js'); const verify = require("../schemas/verifySchema.js");
const fetch = require('axios'); const fetch = require("axios");
module.exports = { module.exports = {
name: 'whois', name: "whois",
description: 'Get\'s the ign of a user.', description: "Get's the ign of a user.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('whois') .setName("whois")
.setDescription('Get\'s the ign of a user.') .setDescription("Get's the ign of a user.")
.addUserOption(option => .addUserOption((option) =>
option option.setName("user").setDescription("The user to get the ign of.").setRequired(true),
.setName('user') )
.setDescription('The user to get the ign of.')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const user = interaction.options.getUser('user'); const user = interaction.options.getUser("user");
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const mojang = "https://api.mojang.com/user/profile/" const mojang = "https://api.mojang.com/user/profile/";
const minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const verifiedUser = await verify.findOne({ userID: user.id }); const verifiedUser = await verify.findOne({ userID: user.id });
if (!verifiedUser) { if (!verifiedUser) {
interaction.editReply({ content: 'This user has not verified their account.' }); interaction.editReply({ content: "This user has not verified their account." });
return return;
} }
const userCheck = await fetch(mojang + verifiedUser.uuid); const userCheck = await fetch(mojang + verifiedUser.uuid);
@@ -40,19 +37,20 @@ module.exports = {
const head = minotar + ign; const head = minotar + ign;
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: interaction.guild.name, {
description: "**User:** " + userMention(user.id) + "\n**IGN:** " + ign, title: interaction.guild.name,
color: embedColor, description: "**User:** " + userMention(user.id) + "\n**IGN:** " + ign,
thumbnail: { color: embedColor,
url: head thumbnail: {
url: head,
},
footer: {
text: interaction.guild.name + " | Developed by: @Taken#0002",
icon_url: interaction.guild.iconURL({ dynamic: true }),
},
}, },
footer: { ],
text: interaction.guild.name + " | Developed by: @Taken#0002", });
icon_url: interaction.guild.iconURL({ dynamic: true }) },
}
}]
})
}
}; };

View File

@@ -2,7 +2,7 @@
"color": "#eeaadb", "color": "#eeaadb",
"applicationsChannel": "776705352456470550", "applicationsChannel": "776705352456470550",
"staffApplicationsChannel": "1039258641393520700", "staffApplicationsChannel": "1039258641393520700",
"inactivityLogChannel": "829742524796239882", "inactivityLogChannel": "829742524796239882",
"staffOtherChannel": "1082036748558803104", "staffOtherChannel": "1082036748558803104",
"hypixelGuildID": "5a353a170cf2e529044f2935", "hypixelGuildID": "5a353a170cf2e529044f2935",
"botLogChannel": "1101144489306886226" "botLogChannel": "1101144489306886226"

View File

@@ -27,10 +27,10 @@
"rsq4": "Are you an active guild member?", "rsq4": "Are you an active guild member?",
"rsq5": "Do you have any experience as a staff member (guild moderator) at all?", "rsq5": "Do you have any experience as a staff member (guild moderator) at all?",
"rsq6": "Why should we choose you as a Guild Moderator?", "rsq6": "Why should we choose you as a Guild Moderator?",
"ia1": "What is your IGN?", "ia1": "What is your IGN?",
"ia2": "Duration of the absence?", "ia2": "Duration of the absence?",
"ia3": "Reason of the absence?", "ia3": "Reason of the absence?",
"ria1": "What is your IGN?", "ria1": "What is your IGN?",
"ria2": "Duration of the absence?", "ria2": "Duration of the absence?",
"ria3": "Reason of the absence?" "ria3": "Reason of the absence?"
} }

View File

@@ -1,14 +1,14 @@
version: '1.0' version: "1.0"
services: services:
illegitimate: illegitimate:
image: "illegitimate-bot:latest" image: "illegitimate-bot:latest"
environment: environment:
- TOKEN=${TOKEN} - TOKEN=${TOKEN}
- MONGOURI=${MONGOURI} - MONGOURI=${MONGOURI}
- DEV=${DEV} - DEV=${DEV}
- CLIENTID=${CLIENTID} - CLIENTID=${CLIENTID}
- GUILDID=${GUILDID} - GUILDID=${GUILDID}
- HYPIXELKEY=${HYPIXELKEY} - HYPIXELKEY=${HYPIXELKEY}
- GUILDINFO=${GUILDINFO} - GUILDINFO=${GUILDINFO}
- REQUIREMENTS=${REQUIREMENTS} - REQUIREMENTS=${REQUIREMENTS}
- RULESINFO=${RULESINFO} - RULESINFO=${RULESINFO}

View File

@@ -1,30 +1,29 @@
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
const fetch = require('axios'); const fetch = require("axios");
const guildapp = require('../../schemas/guildAppSchema.js'); const guildapp = require("../../schemas/guildAppSchema.js");
const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require('../../config/reqs.json'); const { bwfkdr, bwstars, bwwins, swstars, duelswins, duelswlr } = require("../../config/reqs.json");
const env = require("dotenv").config(); const env = require("dotenv").config();
const hypixelApiKey = process.env.HYPIXELAPIKEY; const hypixelApiKey = process.env.HYPIXELAPIKEY;
const { getExactLevel, skywarsLevel, getLevelForExp } = require("../../utils/functions.js"); const { getExactLevel, skywarsLevel, getLevelForExp } = require("../../utils/functions.js");
module.exports = { module.exports = {
name: 'checkstats', name: "checkstats",
description: 'Check your stats.', description: "Check your stats.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const message = interaction.message; const message = interaction.message;
const embed = message.embeds[0]; const embed = message.embeds[0];
const applicantId = embed.footer.text.split(" ")[1] const applicantId = embed.footer.text.split(" ")[1];
const guildappdata = await guildapp.findOne({ userID: applicantId }) const guildappdata = await guildapp.findOne({ userID: applicantId });
const uuid = guildappdata.uuid; const uuid = guildappdata.uuid;
const mojang = "https://api.mojang.com/user/profile/" const mojang = "https://api.mojang.com/user/profile/";
const hypixel = "https://api.hypixel.net/player" const hypixel = "https://api.hypixel.net/player";
const guildAPI = "https://api.hypixel.net/guild" const guildAPI = "https://api.hypixel.net/guild";
const minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
@@ -32,15 +31,17 @@ module.exports = {
const ign = userCheck.data.name; const ign = userCheck.data.name;
const head = minotar + ign; const head = minotar + ign;
const player = hypixel + "?key=" + hypixelApiKey + "&uuid=" + uuid const player = hypixel + "?key=" + hypixelApiKey + "&uuid=" + uuid;
const stats = await fetch(player); const stats = await fetch(player);
if (!stats.data.player) { if (!stats.data.player) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds: [
description: "That player hasn't played Hypixel before.", {
color: embedColor description: "That player hasn't played Hypixel before.",
}] color: embedColor,
},
],
}); });
return; return;
} }
@@ -48,19 +49,19 @@ module.exports = {
const rank2 = stats.data.player.newPackageRank; const rank2 = stats.data.player.newPackageRank;
const monthlyRank = stats.data.player.monthlyPackageRank; const monthlyRank = stats.data.player.monthlyPackageRank;
if (rank2 === 'VIP') { if (rank2 === "VIP") {
var rank = "[VIP] " var rank = "[VIP] ";
} else if (rank2 === 'VIP_PLUS') { } else if (rank2 === "VIP_PLUS") {
var rank = "[VIP+] " var rank = "[VIP+] ";
} else if (rank2 === 'MVP') { } else if (rank2 === "MVP") {
var rank = "[MVP] " var rank = "[MVP] ";
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'NONE') { } else if (rank2 === "MVP_PLUS" && monthlyRank === "NONE") {
var rank = "[MVP+] " var rank = "[MVP+] ";
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'SUPERSTAR') { } else if (rank2 === "MVP_PLUS" && monthlyRank === "SUPERSTAR") {
var rank = "[MVP++] " var rank = "[MVP++] ";
} }
const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + uuid const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + uuid;
const guildCheck = await fetch(guild); const guildCheck = await fetch(guild);
if (!guildCheck.data.guild) { if (!guildCheck.data.guild) {
@@ -70,11 +71,11 @@ module.exports = {
} }
if (!guildCheck.data.guild) { if (!guildCheck.data.guild) {
var guildTag = "" var guildTag = "";
} else if (!guildCheck.data.guild.tag) { } else if (!guildCheck.data.guild.tag) {
var guildTag = "" var guildTag = "";
} else { } else {
var guildTag = " [" + guildCheck.data.guild.tag + "]" var guildTag = " [" + guildCheck.data.guild.tag + "]";
} }
//bedwars level //bedwars level
@@ -96,9 +97,9 @@ module.exports = {
//skywars wins //skywars wins
const hsswwins = stats.data.player.stats.SkyWars.wins; const hsswwins = stats.data.player.stats.SkyWars.wins;
// dueks kdr // dueks kdr
const hsduelskills = stats.data.player.stats.Duels.kills const hsduelskills = stats.data.player.stats.Duels.kills;
const hsduelsdeaths = stats.data.player.stats.Duels.deaths const hsduelsdeaths = stats.data.player.stats.Duels.deaths;
const hsduelskd = hsduelskills / hsduelsdeaths const hsduelskd = hsduelskills / hsduelsdeaths;
// duels wins // duels wins
const hsduelswins = stats.data.player.stats.Duels.wins; const hsduelswins = stats.data.player.stats.Duels.wins;
// duels wlr // duels wlr
@@ -109,72 +110,95 @@ module.exports = {
const level = getExactLevel(hypixelExp); const level = getExactLevel(hypixelExp);
if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) { if (hsbwstars < bwstars || hsbwfkdr < bwfkdr || hsbwwins < bwwins) {
var bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements." var bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements.";
} else { } else {
var bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements." var bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements.";
} }
if (hsswstars < swstars) { if (hsswstars < swstars) {
var swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements." var swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements.";
} else { } else {
var swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements." var swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements.";
} }
if (hsduelswins < duelswins || hsduelswlr < duelswlr) { if (hsduelswins < duelswins || hsduelswlr < duelswlr) {
var duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements." var duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements.";
} else { } else {
var duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements." var duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements.";
} }
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: rank + stats.data.player.displayname + guildTag, {
description: "**Network Level:** `" + title: rank + stats.data.player.displayname + guildTag,
level.toFixed(2).toString() + "`\n" + description:
"**Current Guild:** `" + guildName + "`", "**Network Level:** `" +
color: embedColor, level.toFixed(2).toString() +
thumbnail: { url: head }, "`\n" +
footer: { "**Current Guild:** `" +
text: interaction.guild.name + " | Developed by @Taken#0002", guildName +
icon_url: interaction.guild.iconURL() "`",
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() +
"`",
},
],
}, },
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() + "`"
}
]
}]
}); });
} },
}; };

View File

@@ -1,502 +1,572 @@
const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js'); const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require("discord.js");
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
const { largeM, smallM, ignM } = require('../../config/limitmessages.json') const { largeM, smallM, ignM } = require("../../config/limitmessages.json");
const { applicationsChannel } = require('../../config/options.json'); const { applicationsChannel } = require("../../config/options.json");
const { qu1, qu2, qu3, qu4, qu5, qu6, qu7, qu8 } = require('../../config/questions.json'); const { qu1, qu2, qu3, qu4, qu5, qu6, qu7, qu8 } = require("../../config/questions.json");
const { rq1, rq2, rq3, rq4, rq5, rq6, rq7, rq8 } = require('../../config/questions.json'); const { rq1, rq2, rq3, rq4, rq5, rq6, rq7, rq8 } = require("../../config/questions.json");
const { guildRole } = require('../../config/roles.json') const { guildRole } = require("../../config/roles.json");
const mongoose = require('mongoose'); const mongoose = require("mongoose");
const guildapp = require('../../schemas/guildAppSchema.js'); const guildapp = require("../../schemas/guildAppSchema.js");
const fetch = require('axios'); const fetch = require("axios");
module.exports = { module.exports = {
name: 'guildapply', name: "guildapply",
description: 'Guild application button.', description: "Guild application button.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
const user = interaction.user; const user = interaction.user;
const guild = interaction.guild; const guild = interaction.guild;
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/";
const userRoles = guild.members.cache.get(user.id).roles.cache.map(role => role.id); const userRoles = guild.members.cache.get(user.id).roles.cache.map((role) => role.id);
if (interaction.customId === 'guildapply') {
if (interaction.customId === "guildapply") {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
if (userRoles.includes(guildRole)) { if (userRoles.includes(guildRole)) {
await interaction.editReply({ content: "You are already a member of the guild.", ephemeral: true }); await interaction.editReply({ content: "You are already a member of the guild.", ephemeral: true });
return return;
} }
const application = await guildapp.findOne({ userID: user.id }); const application = await guildapp.findOne({ userID: user.id });
if (application) { if (application) {
await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true }); await interaction.editReply({
return content: "You already have an application in progress.",
ephemeral: true,
});
return;
} }
const tooLong = new EmbedBuilder() const tooLong = new EmbedBuilder().setDescription("You took too long to respond.").setColor(embedColor);
.setDescription("You took too long to respond.")
.setColor(embedColor)
const cancelled = new EmbedBuilder() const cancelled = new EmbedBuilder()
.setDescription("You have cancelled your application.") .setDescription("You have cancelled your application.")
.setColor(embedColor) .setColor(embedColor);
const attachments = new EmbedBuilder() const attachments = new EmbedBuilder()
.setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
.setColor(embedColor) .setColor(embedColor);
try { try {
await user.send({ await user.send({
embeds: [{ embeds: [
title: 'Guild Application', {
description: "Please answer the following questions to apply for the guild.\n" + title: "Guild Application",
"If you wish to cancel your application, please press type `cancel` at any time.\n" + description:
"If you wish to proceed with your application, please type `yes`.\n\n" + "Please answer the following questions to apply for the guild.\n" +
"**Do not upload images, videos, or GIFS.**\n" + "If you wish to cancel your application, please press type `cancel` at any time.\n" +
"You have a minute to respond to this message.", "If you wish to proceed with your application, please type `yes`.\n\n" +
color: embedColor, "**Do not upload images, videos, or GIFS.**\n" +
}] "You have a minute to respond to this message.",
}) color: embedColor,
},
],
});
} catch (error) { } catch (error) {
await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true }); await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true });
return return;
} }
await interaction.editReply({ content: "Please check your DMs.", ephemeral: true}) await interaction.editReply({ content: "Please check your DMs.", ephemeral: true });
const input = await user.dmChannel.awaitMessages({ const input = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 time: 1000 * 60,
}); });
if (input.first().attachments.size > 0) { if (input.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (input.size === 0) { if (input.size === 0) {
await user.send({ embeds: [tooLong] }); await user.send({ embeds: [tooLong] });
return return;
} }
if (input.first().content.toLowerCase() !== 'yes') { if (input.first().content.toLowerCase() !== "yes") {
await user.send({ embeds: [cancelled]} ); await user.send({ embeds: [cancelled] });
return return;
} }
// first question // first question
const question1 = await user.send({ const question1 = await user.send({
embeds: [{ embeds: [
title : "**Question 1**", {
description: qu1 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`", title: "**Question 1**",
color: embedColor, description:
footer:{ qu1 +
text: "You have 5 minutes to respond to this message." "\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({ const answer1 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 5, time: 1000 * 60 * 5,
}); });
if (answer1.first().attachments.size > 0) { if (answer1.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer1.first().content > 16) { if (answer1.first().content > 16) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 16.", {
color: embedColor description: "Max character limit is 16.",
}] color: embedColor,
}) },
return ],
});
return;
} }
try { try {
await fetch(mojangAPI + answer1.first().content) await fetch(mojangAPI + answer1.first().content);
} catch (error) { } catch (error) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "That is not a valid Minecraft username.\n" + {
"Application cancelled.", description: "That is not a valid Minecraft username.\n" + "Application cancelled.",
color: embedColor color: embedColor,
}] },
}) ],
return });
return;
} }
if (answer1.size === 0) { if (answer1.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer1.first().content.toLowerCase() === 'cancel') { if (answer1.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer1_1 = answer1.first().content const answer1_1 = answer1.first().content;
// second question // second question
const question2 = await user.send({ const question2 = await user.send({
embeds: [{ embeds: [
title : "**Question 2**", {
description: qu2 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(8 characters max)`", title: "**Question 2**",
color: embedColor, description:
footer:{ qu2 +
text: "You have 15 minutes to respond to this message." "\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({ const answer2 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15,
}); });
if (answer2.first().attachments.size > 0) { if (answer2.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer2.first().content.size > 8) { if (answer2.first().content.size > 8) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 8.", {
color: embedColor description: "Max character limit is 8.",
}] color: embedColor,
}) },
return ],
});
return;
} }
if (answer2.size === 0) { if (answer2.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer2.first().content.toLowerCase() === 'cancel') { if (answer2.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer2_1 = answer2.first().content const answer2_1 = answer2.first().content;
// third question // third question
const question3 = await user.send({ const question3 = await user.send({
embeds: [{ embeds: [
title : "**Question 3**", {
description: qu3 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", title: "**Question 3**",
color: embedColor, description:
footer:{ qu3 +
text: "You have 15 minutes to respond to this message." "\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({ const answer3 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15,
}); });
if (answer3.first().attachments.size > 0) { if (answer3.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer3.first().content > 128) { if (answer3.first().content > 128) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 128.", {
color: embedColor description: "Max character limit is 128.",
}] color: embedColor,
}) },
],
});
} }
if (answer3.size === 0) { if (answer3.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer3.first().content.toLowerCase() === 'cancel') { if (answer3.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer3_1 = answer3.first().content const answer3_1 = answer3.first().content;
// fourth question // fourth question
const question4 = await user.send({ const question4 = await user.send({
embeds: [{ embeds: [
title : "**Question 4**", {
description: qu4 + "\n\nPlease type your answer below or type `cancel` to cancel your application." + title: "**Question 4**",
" `(We expect a longer answer.)`\n`" + largeM + "`", description:
color: embedColor, qu4 +
footer:{ "\n\nPlease type your answer below or type `cancel` to cancel your application." +
text: "You have 15 minutes to respond to this message." " `(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({ const answer4 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15,
}); });
if (answer4.first().attachments.size > 0) { if (answer4.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer4.first().content > 256) { if (answer4.first().content > 256) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 256.", {
color: embedColor description: "Max character limit is 256.",
}] color: embedColor,
}) },
],
});
} }
if (answer4.size === 0) { if (answer4.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer4.first().content.toLowerCase() === 'cancel') { if (answer4.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer4_1 = answer4.first().content const answer4_1 = answer4.first().content;
// fifth question // fifth question
const question5 = await user.send({ const question5 = await user.send({
embeds: [{ embeds: [
title : "**Question 5**", {
description: qu5 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", title: "**Question 5**",
color: embedColor, description:
footer:{ qu5 +
text: "You have 15 minutes to respond to this message." "\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({ const answer5 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15,
}); });
if (answer5.first().attachments.size > 0) { if (answer5.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer5.first().content > 128) { if (answer5.first().content > 128) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 128.", {
color: embedColor description: "Max character limit is 128.",
}] color: embedColor,
}) },
],
});
} }
if (answer5.size === 0) { if (answer5.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer5.first().content.toLowerCase() === 'cancel') { if (answer5.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer5_1 = answer5.first().content const answer5_1 = answer5.first().content;
// sixth question // sixth question
const question6 = await user.send({ const question6 = await user.send({
embeds: [{ embeds: [
title : "**Question 6**", {
description: qu6 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", title: "**Question 6**",
color: embedColor, description:
footer:{ qu6 +
text: "You have 15 minutes to respond to this message." "\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({ const answer6 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15,
}); });
if (answer6.first().attachments.size > 0) { if (answer6.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer6.first().content > 256) { if (answer6.first().content > 256) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 256.", {
color: embedColor description: "Max character limit is 256.",
}] color: embedColor,
}) },
],
});
} }
if (answer6.size === 0) { if (answer6.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer6.first().content.toLowerCase() === 'cancel') { if (answer6.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer6_1 = answer6.first().content const answer6_1 = answer6.first().content;
// seventh question // seventh question
const question7 = await user.send({ const question7 = await user.send({
embeds: [{ embeds: [
title : "**Question 7**", {
description: qu7 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", title: "**Question 7**",
color: embedColor, description:
footer:{ qu7 +
text: "You have 15 minutes to respond to this message." "\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({ const answer7 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15,
}); });
if (answer7.first().attachments.size > 0) { if (answer7.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer7.first().content > 128) { if (answer7.first().content > 128) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 128.", {
color: embedColor description: "Max character limit is 128.",
}] color: embedColor,
}) },
],
});
} }
if (answer7.size === 0) { if (answer7.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer7.first().content.toLowerCase() === 'cancel') { if (answer7.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer7_1 = answer7.first().content const answer7_1 = answer7.first().content;
// eighth question // eighth question
const question8 = await user.send({ const question8 = await user.send({
embeds: [{ embeds: [
title : "**Question 8**", {
description: qu8 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(64 characters max)`", title: "**Question 8**",
color: embedColor, description:
footer:{ qu8 +
text: "You have 15 minutes to respond to this message." "\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({ const answer8 = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 15 time: 1000 * 60 * 15,
}); });
if (answer8.first().attachments.size > 0) { if (answer8.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (answer8.first().content > 64) { if (answer8.first().content > 64) {
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Max character limit is 64.", {
color: embedColor description: "Max character limit is 64.",
}] color: embedColor,
}) },
],
});
} }
if (answer8.size === 0) { if (answer8.size === 0) {
await user.send({ embeds: [tooLong] }) await user.send({ embeds: [tooLong] });
return return;
} }
if (answer8.first().content.toLowerCase() === 'cancel') { if (answer8.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }) await user.send({ embeds: [cancelled] });
return return;
} }
const answer8_1 = answer8.first().content const answer8_1 = answer8.first().content;
await user.send({ await user.send({
embeds: [{ embeds: [
description: "If you want to submit your application, type `yes` if not, type `no`", {
color: embedColor description: "If you want to submit your application, type `yes` if not, type `no`",
}] color: embedColor,
}) },
],
});
const final = await user.dmChannel.awaitMessages({ const final = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5,
}); });
if (final.first().attachments.size > 0) { if (final.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (final.size === 0) { if (final.size === 0) {
await user.send({ embeds: [tooLong] }); await user.send({ embeds: [tooLong] });
return return;
} }
if (final.first().content.toLowerCase() !== 'yes') { if (final.first().content.toLowerCase() !== "yes") {
await user.send({ embeds: [cancelled]} ); await user.send({ embeds: [cancelled] });
return return;
} }
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Your application has been submitted!", {
color: embedColor description: "Your application has been submitted!",
}] color: embedColor,
}) },
],
});
const userCheck = await fetch(mojangAPI + answer1_1) const userCheck = await fetch(mojangAPI + answer1_1);
const uuid = userCheck.data.id const uuid = userCheck.data.id;
const newGuildApp = new guildapp({ const newGuildApp = new guildapp({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.id, userID: user.id,
uuid: uuid, uuid: uuid,
}) });
await newGuildApp.save() await newGuildApp.save();
const channel = guild.channels.cache.get(applicationsChannel); const channel = guild.channels.cache.get(applicationsChannel);
await channel.send({ await channel.send({
embeds: [{ embeds: [
title: user.username + "#" + user.discriminator + " - Guild Application", {
color: embedColor, title: user.username + "#" + user.discriminator + " - Guild Application",
thumbnail: { color: embedColor,
url: user.avatarURL() thumbnail: {
url: user.avatarURL(),
},
fields: [
{
name: rq1,
value: "```" + answer1_1 + "```",
},
{
name: rq2,
value: "```" + answer2_1 + "```",
},
{
name: rq3,
value: "```" + answer3_1 + "```",
},
{
name: rq4,
value: "```" + answer4_1 + "```",
},
{
name: rq5,
value: "```" + answer5_1 + "```",
},
{
name: rq6,
value: "```" + answer6_1 + "```",
},
{
name: rq7,
value: "```" + answer7_1 + "```",
},
{
name: rq8,
value: "```" + answer8_1 + "```",
},
],
footer: {
iconURL: guild.iconURL(),
text: "ID: " + user.id,
},
}, },
fields: [ ],
{
name: rq1,
value: "```" + answer1_1 + "```"
},
{
name: rq2,
value: "```" + answer2_1 + "```"
},
{
name: rq3,
value: "```" + answer3_1 + "```"
},
{
name: rq4,
value: "```" + answer4_1 + "```"
},
{
name: rq5,
value: "```" + answer5_1 + "```"
},
{
name: rq6,
value: "```" + answer6_1 + "```"
},
{
name: rq7,
value: "```" + answer7_1 + "```"
},
{
name: rq8,
value: "```" + answer8_1 + "```"
}
],
footer: {
iconURL: guild.iconURL(),
text: "ID: " + user.id
}
}],
components: [ components: [
new ActionRowBuilder().addComponents( new ActionRowBuilder().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -510,11 +580,10 @@ module.exports = {
new ButtonBuilder() new ButtonBuilder()
.setCustomId("checkstats") .setCustomId("checkstats")
.setLabel("Check Stats") .setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary) .setStyle(ButtonStyle.Secondary),
) ),
] ],
}); });
} }
} },
} };

View File

@@ -1,17 +1,16 @@
const { ActionRowBuilder, ButtonStyle, ButtonBuilder } = require('discord.js'); const { ActionRowBuilder, ButtonStyle, ButtonBuilder } = require("discord.js");
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
const mongoose = require("mongoose"); const mongoose = require("mongoose");
const guildapp = require('../../schemas/guildAppSchema.js'); const guildapp = require("../../schemas/guildAppSchema.js");
const waitingList = require('../../schemas/waitinglistSchema.js'); const waitingList = require("../../schemas/waitinglistSchema.js");
const { waitingListRole } = require('../../config/roles.json'); const { waitingListRole } = require("../../config/roles.json");
module.exports = { module.exports = {
name: 'guildapplicationaccept', name: "guildapplicationaccept",
description: 'Accept a guild application.', description: "Accept a guild application.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const user = interaction.user; const user = interaction.user;
@@ -20,12 +19,12 @@ module.exports = {
const message = interaction.message; const message = interaction.message;
const embed = message.embeds[0]; const embed = message.embeds[0];
const applicantId = embed.footer.text.split(" ")[1] const applicantId = embed.footer.text.split(" ")[1];
const applicantIGN1 = embed.fields[0].value; const applicantIGN1 = embed.fields[0].value;
const applicantIGN = applicantIGN1.replaceAll("`", ""); const applicantIGN = applicantIGN1.replaceAll("`", "");
const applicant = await guild.members.fetch(applicantId) const applicant = await guild.members.fetch(applicantId);
const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator; const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator;
await message.edit({ await message.edit({
@@ -45,19 +44,21 @@ module.exports = {
.setCustomId("checkstats") .setCustomId("checkstats")
.setLabel("Check Stats") .setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary) .setStyle(ButtonStyle.Secondary)
.setDisabled(true) .setDisabled(true),
) ),
] ],
}); });
await applicant.send({ await applicant.send({
embeds: [{ embeds: [
description: `Your application for the Illegitimate guild has been accepted.`, {
color: embedColor description: `Your application for the Illegitimate guild has been accepted.`,
}] color: embedColor,
},
],
}); });
const applicantEntry = await guildapp.findOne({ userID: applicantId }) const applicantEntry = await guildapp.findOne({ userID: applicantId });
const applicantUUID = applicantEntry.uuid; const applicantUUID = applicantEntry.uuid;
const time = Date.now(); const time = Date.now();
@@ -66,7 +67,7 @@ module.exports = {
userID: applicantId, userID: applicantId,
uuid: applicantUUID, uuid: applicantUUID,
IGN: applicantIGN, IGN: applicantIGN,
timestamp: time timestamp: time,
}); });
await waitingListAdd.save(); await waitingListAdd.save();
@@ -74,20 +75,21 @@ module.exports = {
await applicant.roles.add(waitingListRole); await applicant.roles.add(waitingListRole);
await guildapp.findOneAndDelete({ userID: applicantId }); await guildapp.findOneAndDelete({ userID: applicantId });
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: applicantUsername + " - Guild Application", {
description: "Application has been accepted by <@" + user.id + ">.", title: applicantUsername + " - Guild Application",
color: embedColor, description: "Application has been accepted by <@" + user.id + ">.",
thumbnail: { color: embedColor,
url: applicant.avatarURL() thumbnail: {
url: applicant.avatarURL(),
},
footer: {
iconURL: guild.iconURL(),
text: "ID: " + applicant.id,
},
}, },
footer: { ],
iconURL: guild.iconURL(),
text: "ID: " + applicant.id
}
}]
}); });
} },
}; };

View File

@@ -1,13 +1,12 @@
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require('discord.js'); const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require("discord.js");
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
module.exports = { module.exports = {
name: 'guildapplicationdeny', name: "guildapplicationdeny",
description: 'Deny a guild application.', description: "Deny a guild application.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
const channel = interaction.channel; const channel = interaction.channel;
const guild = interaction.guild; const guild = interaction.guild;
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
@@ -15,18 +14,18 @@ module.exports = {
const message = interaction.message; const message = interaction.message;
const modal = new ModalBuilder() const modal = new ModalBuilder()
.setTitle('Deny Reason') .setTitle("Deny Reason")
.setCustomId('denyreasonbox') .setCustomId("denyreasonbox")
.setComponents( .setComponents(
new ActionRowBuilder().setComponents( new ActionRowBuilder().setComponents(
new TextInputBuilder() new TextInputBuilder()
.setLabel('Deny Reason') .setLabel("Deny Reason")
.setCustomId('denyreason') .setCustomId("denyreason")
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setPlaceholder('Enter a reason for denying the application') .setPlaceholder("Enter a reason for denying the application")
.setRequired(false) .setRequired(false),
) ),
) );
await interaction.showModal(modal); await interaction.showModal(modal);
} },
}; };

View File

@@ -1,283 +1,314 @@
const { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder } = require("discord.js"); const { ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder } = require("discord.js");
const { gm, manager, moderator, beast, member, trialmember, guildStaff, guildRole } = require("../../config/roles.json"); const {
gm,
manager,
moderator,
beast,
member,
trialmember,
guildStaff,
guildRole,
} = require("../../config/roles.json");
const { ignM, smallM, largeM } = require("../../config/limitmessages.json"); const { ignM, smallM, largeM } = require("../../config/limitmessages.json");
const { ia1, ia2, ia3, ria1, ria2, ria3 } = require("../../config/questions.json"); const { ia1, ia2, ia3, ria1, ria2, ria3 } = require("../../config/questions.json");
const { color, inactivityLogChannel } = require("../../config/options.json"); const { color, inactivityLogChannel } = require("../../config/options.json");
const guildRoles = [gm, manager, moderator, beast, member, trialmember, guildStaff, guildRole]; const guildRoles = [gm, manager, moderator, beast, member, trialmember, guildStaff, guildRole];
module.exports = { module.exports = {
name: "guildinactivitylog", name: "guildinactivitylog",
description: "Configure the bot.", description: "Configure the bot.",
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
const guild = interaction.guild; const guild = interaction.guild;
const user = interaction.user; const user = interaction.user;
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const userRoles = guild.members.cache.get(user.id).roles.cache; const userRoles = guild.members.cache.get(user.id).roles.cache;
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/"; const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/";
if (!userRoles.some((role) => guildRoles.includes(role.id))) { if (!userRoles.some((role) => guildRoles.includes(role.id))) {
return await interaction.reply({ return await interaction.reply({
content: "Only guild members can use this button.", content: "Only guild members can use this button.",
ephemeral: true ephemeral: true,
}); });
} }
const tooLong = new EmbedBuilder() const tooLong = new EmbedBuilder().setDescription("You took too long to respond.").setColor(embedColor);
.setDescription("You took too long to respond.") const cancelled = new EmbedBuilder()
.setColor(embedColor); .setDescription("You have cancelled your application.")
const cancelled = new EmbedBuilder() .setColor(embedColor);
.setDescription("You have cancelled your application.") const attachments = new EmbedBuilder()
.setColor(embedColor); .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
const attachments = new EmbedBuilder() .setColor(embedColor);
.setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
.setColor(embedColor);
try { try {
await user.send({ await user.send({
embeds: [ embeds: [
{ {
title: "Guild Inactivity Log", title: "Guild Inactivity Log",
description: "Please answer the following questions to submit an inactivity log for the guild.\n" + description:
"If you wish to cancel your form, please press type `cancel` at any time.\n" + "Please answer the following questions to submit an inactivity log for the guild.\n" +
"If you wish to proceed with your form, please type `yes`.\n\n" + "**Do not upload images, videos, or GIFS.**\n" + "If you wish to cancel your form, please press type `cancel` at any time.\n" +
"You have a minute to respond to this message.", "If you wish to proceed with your form, please type `yes`.\n\n" +
color: embedColor "**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 }); });
} } catch (error) {
return await interaction.reply({ content: "Please enable your DMs.", ephemeral: true });
}
await interaction.reply({ content: "Please check your DMs.", ephemeral: true }); await interaction.reply({ content: "Please check your DMs.", ephemeral: true });
const input = await user.dmChannel.awaitMessages({ const input = await user.dmChannel.awaitMessages({
filter: (m) => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 time: 1000 * 60,
}); });
if (input.first().attachments.size > 0) { if (input.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return; return;
} }
if (input.size === 0) { if (input.size === 0) {
await user.send({ embeds: [tooLong] }); await user.send({ embeds: [tooLong] });
return; return;
} }
if (input.first().content.toLowerCase() !== "yes") { if (input.first().content.toLowerCase() !== "yes") {
await user.send({ embeds: [cancelled] }); await user.send({ embeds: [cancelled] });
return; return;
} }
await user.send({ await user.send({
embeds: [ embeds: [
{ {
title: "**Question 1**", title: "**Question 1**",
description: ia1 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`", description:
color: embedColor, ia1 +
footer: { "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
text: "You have 5 minutes to respond to this message." ignM +
} "`",
} color: embedColor,
] footer: {
}); text: "You have 5 minutes to respond to this message.",
},
},
],
});
const answer1 = await user.dmChannel.awaitMessages({ const answer1 = await user.dmChannel.awaitMessages({
filter: (m) => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5,
}); });
if (answer1.first().attachments.size > 0) { if (answer1.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return; return;
} }
if (answer1.first().content > 16) { if (answer1.first().content > 16) {
await user.send({ await user.send({
embeds: [ embeds: [
{ {
description: "Max character limit is 16.", description: "Max character limit is 16.",
color: embedColor color: embedColor,
} },
] ],
}); });
return; return;
} }
try { try {
await fetch(mojangAPI + answer1.first().content); await fetch(mojangAPI + answer1.first().content);
} catch (error) { } catch (error) {
await user.send({ await user.send({
embeds: [ embeds: [
{ {
description: "That is not a valid Minecraft username.\n" + "Application cancelled.", description: "That is not a valid Minecraft username.\n" + "Application cancelled.",
color: embedColor color: embedColor,
} },
] ],
}); });
return; return;
} }
if (answer1.size === 0) { if (answer1.size === 0) {
await user.send({ embeds: [tooLong] }); await user.send({ embeds: [tooLong] });
return; return;
} }
if (answer1.first().content.toLowerCase() === "cancel") { if (answer1.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] }); await user.send({ embeds: [cancelled] });
return; return;
} }
const answer1_1 = answer1.first().content; const answer1_1 = answer1.first().content;
await user.send({ await user.send({
embeds: [{ embeds: [
title: "**Question 2**", {
description: ia2 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + smallM + "`", title: "**Question 2**",
color: embedColor, description:
footer: { ia2 +
text: "You have 5 minutes to respond to this message." "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
} smallM +
}] "`",
}); color: embedColor,
const answer2 = await user.dmChannel.awaitMessages({ footer: {
filter: (m) => m.author.id === user.id, text: "You have 5 minutes to respond to this message.",
max: 1, },
time: 1000 * 60 * 5 },
}); ],
if (answer2.first().attachments.size > 0) { });
await user.send({ embeds: [attachments] }); const answer2 = await user.dmChannel.awaitMessages({
return; filter: (m) => m.author.id === user.id,
} max: 1,
if (answer2.first().content > 128) { time: 1000 * 60 * 5,
await user.send({ });
embeds: [ if (answer2.first().attachments.size > 0) {
{ await user.send({ embeds: [attachments] });
description: "Max character limit is 128.", return;
color: embedColor }
} if (answer2.first().content > 128) {
] await user.send({
}); embeds: [
return; {
} description: "Max character limit is 128.",
if (answer1.size === 0) { color: embedColor,
await user.send({ embeds: [tooLong] }); },
return; ],
} });
if (answer1.first().content.toLowerCase() === "cancel") { return;
await user.send({ embeds: [cancelled] }); }
return; if (answer1.size === 0) {
} await user.send({ embeds: [tooLong] });
const answer2_1 = answer1.first().content; return;
}
if (answer1.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] });
return;
}
const answer2_1 = answer1.first().content;
await user.send({ await user.send({
embeds: [{ embeds: [
title: "**Question 3**", {
description: ia3 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", title: "**Question 3**",
color: embedColor, description:
footer: { ia3 +
text: "You have 15 minutes to respond to this message." "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
} largeM +
}] "`",
}); color: embedColor,
const answer3 = await user.dmChannel.awaitMessages({ footer: {
filter: (m) => m.author.id === user.id, text: "You have 15 minutes to respond to this message.",
max: 1, },
time: 1000 * 60 * 15 },
}); ],
if (answer3.first().attachments.size > 0) { });
await user.send({ embeds: [attachments] }); const answer3 = await user.dmChannel.awaitMessages({
return; filter: (m) => m.author.id === user.id,
} max: 1,
if (answer3.first().content > 256) { time: 1000 * 60 * 15,
await user.send({ });
embeds: [ if (answer3.first().attachments.size > 0) {
{ await user.send({ embeds: [attachments] });
description: "Max character limit is 256", return;
color: embedColor }
} if (answer3.first().content > 256) {
] await user.send({
}); embeds: [
return; {
} description: "Max character limit is 256",
if (answer1.size === 0) { color: embedColor,
await user.send({ embeds: [tooLong] }); },
return; ],
} });
if (answer1.first().content.toLowerCase() === "cancel") { return;
await user.send({ embeds: [cancelled] }); }
return; if (answer1.size === 0) {
} await user.send({ embeds: [tooLong] });
const answer3_1 = answer1.first().content; return;
}
if (answer1.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] });
return;
}
const answer3_1 = answer1.first().content;
await user.send({ await user.send({
embeds: [{ embeds: [
description: "If you want to submit your application, type `yes` if not, type `no`", {
color: embedColor 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, const final = await user.dmChannel.awaitMessages({
time: 1000 * 60 * 5 filter: (m) => m.author.id === user.id,
}); max: 1,
if (final.first().attachments.size > 0) { time: 1000 * 60 * 5,
await user.send({ embeds: [attachments] }); });
return if (final.first().attachments.size > 0) {
} await user.send({ embeds: [attachments] });
if (final.size === 0) { return;
await user.send({ embeds: [tooLong] }); }
return if (final.size === 0) {
} await user.send({ embeds: [tooLong] });
if (final.first().content.toLowerCase() !== 'yes') { return;
await user.send({ embeds: [cancelled]} ); }
return if (final.first().content.toLowerCase() !== "yes") {
} await user.send({ embeds: [cancelled] });
return;
}
await user.send({ await user.send({
embeds: [{ embeds: [
description: "Your application has been submitted!", {
color: embedColor description: "Your application has been submitted!",
}] color: embedColor,
}) },
],
});
const appChannel = await guild.channels.cache.get(inactivityLogChannel); const appChannel = await guild.channels.cache.get(inactivityLogChannel);
await appChannel.send({ await appChannel.send({
embeds: [{ embeds: [
title: user.username + "#" + user.discriminator + " - Inactivity Application", {
color: embedColor, title: user.username + "#" + user.discriminator + " - Inactivity Application",
thumbnail: { color: embedColor,
url: user.displayAvatarURL({ dynamic: true }) thumbnail: {
}, url: user.displayAvatarURL({ dynamic: true }),
fields: [ },
{ fields: [
name: ria1, {
value: "`" + answer1_1 + "`" name: ria1,
}, value: "`" + answer1_1 + "`",
{ },
name: ria2, {
value: "`" + answer2_1 + "`" name: ria2,
}, value: "`" + answer2_1 + "`",
{ },
name: ria3, {
value: "`" + answer3_1 + "`" name: ria3,
} value: "`" + answer3_1 + "`",
], },
footer: { ],
icon_url: user.displayAvatarURL({ dynamic: true }), footer: {
text: "ID: " + user.id icon_url: user.displayAvatarURL({ dynamic: true }),
} text: "ID: " + user.id,
}], },
components: [ },
new ActionRowBuilder().addComponents( ],
new ButtonBuilder() components: [
.setCustomId("inactiveapplicationaccept") new ActionRowBuilder().addComponents(
.setLabel("Accept") new ButtonBuilder()
.setStyle(ButtonStyle.Primary), .setCustomId("inactiveapplicationaccept")
new ButtonBuilder() .setLabel("Accept")
.setCustomId("inactiveapplicationdeny") .setStyle(ButtonStyle.Primary),
.setLabel("Deny") new ButtonBuilder()
.setStyle(ButtonStyle.Danger), .setCustomId("inactiveapplicationdeny")
) .setLabel("Deny")
] .setStyle(ButtonStyle.Danger),
}); ),
} ],
});
},
}; };

View File

@@ -1,11 +1,9 @@
module.exports = { module.exports = {
name: "inactiveapplicationaccept", name: "inactiveapplicationaccept",
description: "Accept an inactivity application.", description: "Accept an inactivity application.",
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: "This button is currently disabled.", ephemeral: true });
await interaction.reply({ content: "This button is currently disabled.", ephemeral: true }); },
};
}
}

View File

@@ -1,11 +1,9 @@
module.exports = { module.exports = {
name: "inactiveapplicationdeny", name: "inactiveapplicationdeny",
description: "Denies an inactivity application.", description: "Denies an inactivity application.",
type: "button", type: "button",
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: "This button is currently disabled.", ephemeral: true });
await interaction.reply({ content: "This button is currently disabled.", ephemeral: true }); },
};
}
}

View File

@@ -1,14 +1,13 @@
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
const staffapp = require('../../schemas/staffAppSchema.js'); const staffapp = require("../../schemas/staffAppSchema.js");
module.exports = { module.exports = {
name: 'staffapplicationaccept', name: "staffapplicationaccept",
description: 'Accept a staff application.', description: "Accept a staff application.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
const user = interaction.user; const user = interaction.user;
const channel = interaction.channel; const channel = interaction.channel;
const guild = interaction.guild; const guild = interaction.guild;
@@ -16,16 +15,18 @@ module.exports = {
const message = interaction.message; const message = interaction.message;
const embed = message.embeds[0]; const embed = message.embeds[0];
const applicantId = embed.footer.text.split(" ")[1] const applicantId = embed.footer.text.split(" ")[1];
const applicant = await guild.members.fetch(applicantId) const applicant = await guild.members.fetch(applicantId);
const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator; const applicantUsername = applicant.user.username + "#" + applicant.user.discriminator;
await applicant.send({ await applicant.send({
embeds: [{ embeds: [
description: `Your application for the Illegitimate staff team has been accepted.`, {
color: embedColor description: `Your application for the Illegitimate staff team has been accepted.`,
}] color: embedColor,
},
],
}); });
await message.edit({ await message.edit({
@@ -40,27 +41,28 @@ module.exports = {
.setCustomId("staffapplicationdeny") .setCustomId("staffapplicationdeny")
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger) .setStyle(ButtonStyle.Danger)
.setDisabled(true) .setDisabled(true),
) ),
] ],
}); });
await staffapp.findOneAndDelete({ userId: applicantId }); await staffapp.findOneAndDelete({ userId: applicantId });
await interaction.reply({ await interaction.reply({
embeds: [{ embeds: [
title: applicantUsername + " - Staff Application.", {
description: "Application accepted by <@" + user.id + ">.", title: applicantUsername + " - Staff Application.",
color: embedColor, description: "Application accepted by <@" + user.id + ">.",
thumbnail: { color: embedColor,
url: applicant.avatarURL() thumbnail: {
url: applicant.avatarURL(),
},
footer: {
iconurl: guild.iconURL(),
text: "ID: " + applicantId,
},
}, },
footer: { ],
iconurl: guild.iconURL(),
text: "ID: " + applicantId
}
}]
}); });
},
} };
}

View File

@@ -1,25 +1,24 @@
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require('discord.js'); const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require("discord.js");
module.exports = { module.exports = {
name: 'staffapplicationdeny', name: "staffapplicationdeny",
description: 'Deny a guild application.', description: "Deny a guild application.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
const modal = new ModalBuilder() const modal = new ModalBuilder()
.setTitle('Deny Reason') .setTitle("Deny Reason")
.setCustomId('staffdenyreasonbox') .setCustomId("staffdenyreasonbox")
.setComponents( .setComponents(
new ActionRowBuilder().setComponents( new ActionRowBuilder().setComponents(
new TextInputBuilder() new TextInputBuilder()
.setLabel('Deny Reason') .setLabel("Deny Reason")
.setCustomId('staffdenyreason') .setCustomId("staffdenyreason")
.setStyle(TextInputStyle.Paragraph) .setStyle(TextInputStyle.Paragraph)
.setPlaceholder('Enter a reason for denying the application') .setPlaceholder("Enter a reason for denying the application")
.setRequired(false) .setRequired(false),
) ),
) );
await interaction.showModal(modal); await interaction.showModal(modal);
} },
}; };

View File

@@ -1,437 +1,494 @@
const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js'); const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require("discord.js");
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
const { largeM, smallM, ignM } = require('../../config/limitmessages.json') const { largeM, smallM, ignM } = require("../../config/limitmessages.json");
const { staffApplicationsChannel } = require('../../config/options.json'); const { staffApplicationsChannel } = require("../../config/options.json");
const { sq1, sq2, sq3, sq4, sq5, sq6 } = require('../../config/questions.json'); const { sq1, sq2, sq3, sq4, sq5, sq6 } = require("../../config/questions.json");
const { rsq1, rsq2, rsq3, rsq4, rsq5, rsq6 } = require('../../config/questions.json'); const { rsq1, rsq2, rsq3, rsq4, rsq5, rsq6 } = require("../../config/questions.json");
const { guildRole, guildStaff } = require('../../config/roles.json') const { guildRole, guildStaff } = require("../../config/roles.json");
const mongoose = require('mongoose'); const mongoose = require("mongoose");
const staffapp = require('../../schemas/staffAppSchema.js'); const staffapp = require("../../schemas/staffAppSchema.js");
const fetch = require('axios'); const fetch = require("axios");
module.exports = { module.exports = {
name: 'staffapply', name: "staffapply",
description: 'Apply for the staff team.', description: "Apply for the staff team.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
const user = interaction.user; const user = interaction.user;
const guild = interaction.guild; const guild = interaction.guild;
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const userRoles = interaction.member.roles.cache; const userRoles = interaction.member.roles.cache;
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/";
if (interaction.customId === "staffapply") { if (interaction.customId === "staffapply") {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
if (!userRoles.has(guildRole)) { if (!userRoles.has(guildRole)) {
await interaction.editReply({content: "You must be a member of the guild to apply for staff.", ephemeral: true}); await interaction.editReply({
return content: "You must be a member of the guild to apply for staff.",
ephemeral: true,
});
return;
} }
if (userRoles.has(guildStaff)) { if (userRoles.has(guildStaff)) {
await interaction.editReply({content: "You are already a staff member.", ephemeral: true}); await interaction.editReply({ content: "You are already a staff member.", ephemeral: true });
return return;
} }
const application = await staffapp.findOne({ userID: user.id }); const application = await staffapp.findOne({ userID: user.id });
if (application) { if (application) {
await interaction.editReply({ content: "You already have an application in progress.", ephemeral: true }); await interaction.editReply({
return content: "You already have an application in progress.",
ephemeral: true,
});
return;
} }
const tooLong = new EmbedBuilder() const tooLong = new EmbedBuilder().setDescription("You took too long to respond.").setColor(embedColor);
.setDescription("You took too long to respond.")
.setColor(embedColor)
const cancelled = new EmbedBuilder() const cancelled = new EmbedBuilder()
.setDescription("You have cancelled your application.") .setDescription("You have cancelled your application.")
.setColor(embedColor) .setColor(embedColor);
const attachments = new EmbedBuilder() const attachments = new EmbedBuilder()
.setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.") .setDescription("You have uploaded an attachment. Please do not upload images, videos, or GIFS.")
.setColor(embedColor) .setColor(embedColor);
try { try {
await user.send({ await user.send({
embeds: [{ embeds: [
title: 'Staff Application', {
description: "Please answer the following questions to apply for staff.\n" + title: "Staff Application",
"If you wish to cancel your application, please press type `cancel` at any time.\n" + description:
"If you wish to proceed with your application, please type `yes`.\n\n" + "Please answer the following questions to apply for staff.\n" +
"**Do not upload images, videos, or GIFS.**\n" + "If you wish to cancel your application, please press type `cancel` at any time.\n" +
"You have a minute to respond to this message.", "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, 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.first().attachments.size > 0) { } catch (error) {
await user.send({ embeds: [attachments] }); await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true });
return return;
} }
if (input.size === 0) {
await user.send({ embeds: [tooLong] });
return
}
if (input.first().content.toLowerCase() !== 'yes') {
await user.send({ embeds: [cancelled]} );
return
}
// first question await interaction.editReply({ content: "Please check your DMs.", ephemeral: true });
const question1 = await user.send({
embeds: [{ const input = await user.dmChannel.awaitMessages({
title : "**Question 1**", filter: (m) => m.author.id === user.id,
description: sq1 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`", 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;
}
// first question
const question1 = await user.send({
embeds: [
{
title: "**Question 1**",
description:
sq1 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
ignM +
"`",
color: embedColor, color: embedColor,
footer:{ footer: {
text: "You have 5 minutes to respond to this message." text: "You have 5 minutes to respond to this message.",
} },
}] },
}) ],
const answer1 = await user.dmChannel.awaitMessages({ });
filter: m => m.author.id === user.id, const answer1 = await user.dmChannel.awaitMessages({
max: 1, filter: (m) => m.author.id === user.id,
time: 1000 * 60 * 5, max: 1,
}); time: 1000 * 60 * 5,
if (answer1.first().attachments.size > 0) { });
await user.send({ embeds: [attachments] }); if (answer1.first().attachments.size > 0) {
return await user.send({ embeds: [attachments] });
} return;
if (answer1.first().content > 16) { }
await user.send({ if (answer1.first().content > 16) {
embeds: [{ await user.send({
embeds: [
{
description: "Max character limit is 16.", description: "Max character limit is 16.",
color: embedColor 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
// second question
const question2 = await user.send({
embeds: [{
title : "**Question 2**",
description: sq2 + "\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.first().attachments.size > 0) { return;
await user.send({ embeds: [attachments] }); }
return try {
} await fetch(mojangAPI + answer1.first().content);
if (answer2.first().content > 64) { } catch (error) {
await user.send({ await user.send({
embeds: [{ 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;
// second question
const question2 = await user.send({
embeds: [
{
title: "**Question 2**",
description:
sq2 +
"\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.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.", description: "Max character limit is 64.",
color: embedColor color: embedColor,
}] },
}) ],
return
}
if (answer2.size === 0) {
await user.send({ embeds: [tooLong] })
return
}
if (answer2.first().content.toLowerCase() === 'cancel') {
await user.send({ embeds: [cancelled] })
return
}
const answer2_1 = answer2.first().content
// third question
const question3 = await user.send({
embeds: [{
title : "**Question 3**",
description: sq3 + "\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) { return;
await user.send({ embeds: [attachments] }); }
return if (answer2.size === 0) {
} await user.send({ embeds: [tooLong] });
if (answer3.first().content > 256) { return;
await user.send({ }
embeds: [{ if (answer2.first().content.toLowerCase() === "cancel") {
description: "Max character limit is 256.", await user.send({ embeds: [cancelled] });
color: embedColor return;
}] }
}) const answer2_1 = answer2.first().content;
}
if (answer3.size === 0) {
await user.send({ embeds: [tooLong] })
return
}
if (answer3.first().content.toLowerCase() === 'cancel') {
await user.send({ embeds: [cancelled] })
return
}
const answer3_1 = answer3.first().content
// fourth question // third question
const question4 = await user.send({ const question3 = await user.send({
embeds: [{ embeds: [
title : "**Question 4**", {
description: sq4 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", title: "**Question 3**",
description:
sq3 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
largeM +
"`",
color: embedColor, color: embedColor,
footer:{ footer: {
text: "You have 15 minutes to respond to this message." text: "You have 15 minutes to respond to this message.",
} },
}] },
}) ],
const answer4 = await user.dmChannel.awaitMessages({ });
filter: m => m.author.id === user.id, const answer3 = await user.dmChannel.awaitMessages({
max: 1, filter: (m) => m.author.id === user.id,
time: 1000 * 60 * 15 max: 1,
}); time: 1000 * 60 * 15,
if (answer4.first().attachments.size > 0) { });
await user.send({ embeds: [attachments] }); if (answer3.first().attachments.size > 0) {
return await user.send({ embeds: [attachments] });
} return;
if (answer4.first().content > 256) { }
await user.send({ if (answer3.first().content > 256) {
embeds: [{
description: "Max character limit is 256.",
color: embedColor
}]
})
}
if (answer4.size === 0) {
await user.send({ embeds: [tooLong] })
return
}
if (answer4.first().content.toLowerCase() === 'cancel') {
await user.send({ embeds: [cancelled] })
return
}
const answer4_1 = answer4.first().content
// fifth question
const question5 = await user.send({
embeds: [{
title : "**Question 5**",
description: sq5 + "\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.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
}]
})
}
if (answer5.size === 0) {
await user.send({ embeds: [tooLong] })
return
}
if (answer5.first().content.toLowerCase() === 'cancel') {
await user.send({ embeds: [cancelled] })
return
}
const answer5_1 = answer5.first().content
// sixth question
const question6 = await user.send({
embeds: [{
title : "**Question 6**",
description: sq6 + "\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.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
}]
})
}
if (answer6.size === 0) {
await user.send({ embeds: [tooLong] })
return
}
if (answer6.first().content.toLowerCase() === 'cancel') {
await user.send({ embeds: [cancelled] })
return
}
const answer6_1 = answer6.first().content
await user.send({ await user.send({
embeds: [{ embeds: [
{
description: "Max character limit is 256.",
color: embedColor,
},
],
});
}
if (answer3.size === 0) {
await user.send({ embeds: [tooLong] });
return;
}
if (answer3.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] });
return;
}
const answer3_1 = answer3.first().content;
// fourth question
const question4 = await user.send({
embeds: [
{
title: "**Question 4**",
description:
sq4 +
"\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.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,
},
],
});
}
if (answer4.size === 0) {
await user.send({ embeds: [tooLong] });
return;
}
if (answer4.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] });
return;
}
const answer4_1 = answer4.first().content;
// fifth question
const question5 = await user.send({
embeds: [
{
title: "**Question 5**",
description:
sq5 +
"\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.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,
},
],
});
}
if (answer5.size === 0) {
await user.send({ embeds: [tooLong] });
return;
}
if (answer5.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] });
return;
}
const answer5_1 = answer5.first().content;
// sixth question
const question6 = await user.send({
embeds: [
{
title: "**Question 6**",
description:
sq6 +
"\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.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,
},
],
});
}
if (answer6.size === 0) {
await user.send({ embeds: [tooLong] });
return;
}
if (answer6.first().content.toLowerCase() === "cancel") {
await user.send({ embeds: [cancelled] });
return;
}
const answer6_1 = answer6.first().content;
await user.send({
embeds: [
{
description: "If you want to submit your application, type `yes` if not, type `no`", description: "If you want to submit your application, type `yes` if not, type `no`",
color: embedColor color: embedColor,
}] },
}) ],
});
const final = await user.dmChannel.awaitMessages({ const final = await user.dmChannel.awaitMessages({
filter: m => m.author.id === user.id, filter: (m) => m.author.id === user.id,
max: 1, max: 1,
time: 1000 * 60 * 5 time: 1000 * 60 * 5,
}); });
if (final.first().attachments.size > 0) { if (final.first().attachments.size > 0) {
await user.send({ embeds: [attachments] }); await user.send({ embeds: [attachments] });
return return;
} }
if (final.size === 0) { if (final.size === 0) {
await user.send({ embeds: [tooLong] }); await user.send({ embeds: [tooLong] });
return return;
} }
if (final.first().content.toLowerCase() !== 'yes') { if (final.first().content.toLowerCase() !== "yes") {
await user.send({ embeds: [cancelled]} ); await user.send({ embeds: [cancelled] });
return return;
} }
await user.send({ await user.send({
embeds: [{ embeds: [
{
description: "Your application has been submitted!", description: "Your application has been submitted!",
color: embedColor color: embedColor,
}] },
}) ],
});
const userCheck = await fetch(mojangAPI + answer1_1) const userCheck = await fetch(mojangAPI + answer1_1);
const uuid = userCheck.data.id const uuid = userCheck.data.id;
const newStaffApp = new staffapp({ const newStaffApp = new staffapp({
_id: new mongoose.Types.ObjectId(), _id: new mongoose.Types.ObjectId(),
userID: user.id, userID: user.id,
uuid: uuid, uuid: uuid,
}) });
await newStaffApp.save() await newStaffApp.save();
await user.deleteDM(); await user.deleteDM();
const channel = guild.channels.cache.get(staffApplicationsChannel); const channel = guild.channels.cache.get(staffApplicationsChannel);
await channel.send({ await channel.send({
embeds: [{ embeds: [
{
title: user.username + "#" + user.discriminator + " - Staff Application", title: user.username + "#" + user.discriminator + " - Staff Application",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: user.avatarURL() url: user.avatarURL(),
}, },
fields: [ fields: [
{ {
name: rsq1, name: rsq1,
value: "```" + answer1_1 + "```" value: "```" + answer1_1 + "```",
}, },
{ {
name: rsq2, name: rsq2,
value: "```" + answer2_1 + "```" value: "```" + answer2_1 + "```",
}, },
{ {
name: rsq3, name: rsq3,
value: "```" + answer3_1 + "```" value: "```" + answer3_1 + "```",
}, },
{ {
name: rsq4, name: rsq4,
value: "```" + answer4_1 + "```" value: "```" + answer4_1 + "```",
}, },
{ {
name: rsq5, name: rsq5,
value: "```" + answer5_1 + "```" value: "```" + answer5_1 + "```",
}, },
{ {
name: rsq6, name: rsq6,
value: "```" + answer6_1 + "```" value: "```" + answer6_1 + "```",
} },
], ],
footer: { footer: {
iconURL: guild.iconURL(), iconURL: guild.iconURL(),
text: "ID: " + user.id text: "ID: " + user.id,
} },
}], },
components: [ ],
new ActionRowBuilder().addComponents( components: [
new ButtonBuilder() new ActionRowBuilder().addComponents(
.setCustomId("staffapplicationaccept") new ButtonBuilder()
.setLabel("Accept") .setCustomId("staffapplicationaccept")
.setStyle(ButtonStyle.Primary), .setLabel("Accept")
new ButtonBuilder() .setStyle(ButtonStyle.Primary),
.setCustomId("staffapplicationdeny") new ButtonBuilder()
.setLabel("Deny") .setCustomId("staffapplicationdeny")
.setStyle(ButtonStyle.Danger) .setLabel("Deny")
) .setStyle(ButtonStyle.Danger),
] ),
} ],
); });
} }
} },
} };

View File

@@ -1,28 +1,27 @@
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require('discord.js') const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require("discord.js");
const { color } = require('../../config/options.json') const { color } = require("../../config/options.json");
module.exports = { module.exports = {
name: 'verify', name: "verify",
description: 'Configure the bot.', description: "Configure the bot.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
const modal = new ModalBuilder()
const modal = new ModalBuilder() .setTitle("Verification")
.setTitle("Verification") .setCustomId("verifybox")
.setCustomId("verifybox") .setComponents(
.setComponents( new ActionRowBuilder().setComponents(
new ActionRowBuilder().setComponents( new TextInputBuilder()
new TextInputBuilder() .setLabel("IGN")
.setLabel("IGN") .setCustomId("verifyfield")
.setCustomId("verifyfield") .setStyle(TextInputStyle.Short)
.setStyle(TextInputStyle.Short) .setPlaceholder("Enter your ign.")
.setPlaceholder("Enter your ign.") .setRequired(true)
.setRequired(true) .setMinLength(3)
.setMinLength(3) .setMaxLength(16),
.setMaxLength(16) ),
) );
) await interaction.showModal(modal);
await interaction.showModal(modal) },
} };
}

View File

@@ -1,66 +1,64 @@
const mongoose = require('mongoose'); const mongoose = require("mongoose");
const waitinglist = require('../../schemas/waitinglistSchema.js'); const waitinglist = require("../../schemas/waitinglistSchema.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const key = process.env.HYPIXELAPIKEY; const key = process.env.HYPIXELAPIKEY;
const { hypixelGuildID } = require("../../config/options.json") const { hypixelGuildID } = require("../../config/options.json");
const fetch = require("axios"); const fetch = require("axios");
module.exports = { module.exports = {
name: 'waitinglistupdate', name: "waitinglistupdate",
description: 'Update the waiting list.', description: "Update the waiting list.",
type: 'button', type: "button",
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({ ephemeral: true });
await interaction.deferReply({ ephemeral: true }); const user = interaction.user;
const message = interaction.message;
const user = interaction.user; const embed = message.embeds[0];
const message = interaction.message; const accepted = await waitinglist.find();
const embed = message.embeds[0]; const guildAPI = "https://api.hypixel.net/guild";
const accepted = await waitinglist.find() const guild = guildAPI + "?key=" + key + "&player=";
const guildAPI = "https://api.hypixel.net/guild"
const guild = guildAPI + "?key=" + key + "&player="
for (let i = 0; i < accepted.length; i++) { for (let i = 0; i < accepted.length; i++) {
const uuid = accepted[i].uuid;
const uuid = accepted[i].uuid const check = await fetch(guild + uuid);
const check = await fetch(guild + uuid)
if (check.data.guild._id === hypixelGuildID) { if (check.data.guild._id === hypixelGuildID) {
await waitinglist.findOneAndDelete({ uuid: uuid }) await waitinglist.findOneAndDelete({ uuid: uuid });
continue continue;
} }
} }
let fields = []; let fields = [];
for (let i = 0; i < accepted.length; i++) { for (let i = 0; i < accepted.length; i++) {
const timestamp1 = accepted[i].timestamp / 1000;
const timestamp = Math.floor(timestamp1);
const timestamp1 = accepted[i].timestamp / 1000 fields.push({
const timestamp = Math.floor(timestamp1) name: `${i + 1}. ${accepted[i].IGN}`,
value: `TS: <t:${timestamp}:R>`,
});
}
fields.push({ await message.edit({
name: `${i + 1}. ${accepted[i].IGN}`, embeds: [
value: `TS: <t:${timestamp}:R>` {
}); 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 message.edit({ await interaction.editReply({ content: "Updated the waiting list", ephemeral: true });
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 });
}
}

View File

@@ -1,17 +1,16 @@
const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
const mongoose = require('mongoose'); const mongoose = require("mongoose");
const guildapp = require('../../schemas/guildAppSchema.js'); const guildapp = require("../../schemas/guildAppSchema.js");
const fs = require('fs'); const fs = require("fs");
const path = require('path'); const path = require("path");
module.exports = { module.exports = {
name: 'denyreasonbox', name: "denyreasonbox",
description: 'Deny reason box.', description: "Deny reason box.",
type: 'modal', type: "modal",
async execute(interaction) { async execute(interaction) {
if (interaction.type !== InteractionType.ModalSubmit) return; if (interaction.type !== InteractionType.ModalSubmit) return;
if (interaction.customId !== "denyreasonbox") return; if (interaction.customId !== "denyreasonbox") return;
@@ -24,7 +23,7 @@ module.exports = {
const applicantId = embed.footer.text.split(" ")[1]; const applicantId = embed.footer.text.split(" ")[1];
const applicant = await guild.members.fetch(applicantId); const applicant = await guild.members.fetch(applicantId);
const reason = interaction.fields.fields.get('denyreason').value || "No reason provided"; const reason = interaction.fields.fields.get("denyreason").value || "No reason provided";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`); const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`);
@@ -45,14 +44,15 @@ module.exports = {
.setCustomId("checkstats") .setCustomId("checkstats")
.setLabel("Check Stats") .setLabel("Check Stats")
.setStyle(ButtonStyle.Secondary) .setStyle(ButtonStyle.Secondary)
.setDisabled(true) .setDisabled(true),
) ),
] ],
}); });
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription("Your application for the Illegitimate guild has been denied\n" + .setDescription(
"**Reason:** `" + reason + "`") "Your application for the Illegitimate guild has been denied\n" + "**Reason:** `" + reason + "`",
)
.setColor(embedColor); .setColor(embedColor);
await applicant.send({ embeds: [dmMessage] }); await applicant.send({ embeds: [dmMessage] });
@@ -60,19 +60,26 @@ module.exports = {
await guildapp.findOneAndDelete({ userID: applicantId }); await guildapp.findOneAndDelete({ userID: applicantId });
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: "Application Denied", {
description: "The application has been denied by <@" + interaction.user.id + ">.\n" + title: "Application Denied",
"**Reason:** `" + reason + "`", description:
color: embedColor, "The application has been denied by <@" +
thumbnail: { interaction.user.id +
url: applicant.avatarURL() ">.\n" +
"**Reason:** `" +
reason +
"`",
color: embedColor,
thumbnail: {
url: applicant.avatarURL(),
},
footer: {
iconURL: guild.iconURL(),
text: "ID: " + applicant.id,
},
}, },
footer: { ],
iconURL: guild.iconURL(),
text: "ID: " + applicant.id
}
}],
}); });
} },
} };

View File

@@ -1,17 +1,16 @@
const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const { color } = require('../../config/options.json'); const { color } = require("../../config/options.json");
const mongoose = require('mongoose'); const mongoose = require("mongoose");
const staffapp = require('../../schemas/staffAppSchema.js'); const staffapp = require("../../schemas/staffAppSchema.js");
const fs = require('fs'); const fs = require("fs");
const path = require('path'); const path = require("path");
module.exports = { module.exports = {
name: 'staffdenyreasonbox', name: "staffdenyreasonbox",
description: 'Deny reason box.', description: "Deny reason box.",
type: 'modal', type: "modal",
async execute(interaction) { async execute(interaction) {
if (interaction.type !== InteractionType.ModalSubmit) return; if (interaction.type !== InteractionType.ModalSubmit) return;
if (interaction.customId !== "staffdenyreasonbox") return; if (interaction.customId !== "staffdenyreasonbox") return;
@@ -19,13 +18,13 @@ module.exports = {
const channel = interaction.channel; const channel = interaction.channel;
const guild = interaction.guild; const guild = interaction.guild;
const reason = interaction.fields.fields.get('staffdenyreason').value || "No reason provided"; const reason = interaction.fields.fields.get("staffdenyreason").value || "No reason provided";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const message = interaction.message; const message = interaction.message;
const embed = message.embeds[0]; const embed = message.embeds[0];
const applicantId = embed.footer.text.split(" ")[1] const applicantId = embed.footer.text.split(" ")[1];
const applicant = await guild.members.fetch(applicantId) const applicant = await guild.members.fetch(applicantId);
await message.edit({ await message.edit({
components: [ components: [
@@ -40,13 +39,14 @@ module.exports = {
.setLabel("Deny") .setLabel("Deny")
.setStyle(ButtonStyle.Danger) .setStyle(ButtonStyle.Danger)
.setDisabled(true), .setDisabled(true),
) ),
] ],
}); });
const dmMessage = new EmbedBuilder() const dmMessage = new EmbedBuilder()
.setDescription("Your application for the Illegitimate guild staff has been denied\n" + .setDescription(
"**Reason:** `" + reason + "`") "Your application for the Illegitimate guild staff has been denied\n" + "**Reason:** `" + reason + "`",
)
.setColor(embedColor); .setColor(embedColor);
await applicant.send({ embeds: [dmMessage] }); await applicant.send({ embeds: [dmMessage] });
@@ -54,19 +54,26 @@ module.exports = {
await staffapp.findOneAndDelete({ userID: applicantId }); await staffapp.findOneAndDelete({ userID: applicantId });
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
title: "Application Denied", {
description: "The application has been denied by <@" + interaction.user.id + ">.\n" + title: "Application Denied",
"**Reason:** `" + reason + "`", description:
color: embedColor, "The application has been denied by <@" +
thumbnail: { interaction.user.id +
url: applicant.avatarURL() ">.\n" +
"**Reason:** `" +
reason +
"`",
color: embedColor,
thumbnail: {
url: applicant.avatarURL(),
},
footer: {
iconURL: guild.iconURL(),
text: "ID: " + applicant.id,
},
}, },
footer: { ],
iconURL: guild.iconURL(), });
text: "ID: " + applicant.id },
} };
}],
});;
}
}

133
index.js
View File

@@ -1,21 +1,21 @@
const { Client, GatewayIntentBits, Partials, ActivityType, Events, Collection } = require('discord.js'); const { Client, GatewayIntentBits, Partials, ActivityType, Events, Collection } = require("discord.js");
const { botLogChannel, color } = require('./config/options.json'); const { botLogChannel, color } = require("./config/options.json");
const env = require('dotenv').config(); const env = require("dotenv").config();
const token = process.env.TOKEN; const token = process.env.TOKEN;
const mongoURI = process.env.MONGOURI; const mongoURI = process.env.MONGOURI;
const { connect } = require('mongoose'); const { connect } = require("mongoose");
const path = require('path'); const path = require("path");
const fs = require('fs'); const fs = require("fs");
const client = new Client({ const client = new Client({
intents: [ intents: [
GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages,
GatewayIntentBits.DirectMessages GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
], ],
partials: [ partials: [Partials.GuildMember, Partials.User, Partials.Message, Partials.Channel],
Partials.GuildMember, Partials.User, Partials.Message, Partials.Channel
]
}); });
client.commands = new Collection(); client.commands = new Collection();
@@ -23,15 +23,14 @@ client.events = new Collection();
client.modals = new Collection(); client.modals = new Collection();
//! commands //! commands
const cmdPath = path.join(__dirname, 'commands'); const cmdPath = path.join(__dirname, "commands");
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith('.js')); const cmdFiles = fs.readdirSync(cmdPath).filter((file) => file.endsWith(".js"));
for (const file of cmdFiles) { for (const file of cmdFiles) {
const filePath = path.join(cmdPath, file); const filePath = path.join(cmdPath, file);
const cmd = require(filePath); const cmd = require(filePath);
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') { if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
client.commands.set(cmd.data.name, cmd); client.commands.set(cmd.data.name, cmd);
} else { } else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`); console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
@@ -39,16 +38,14 @@ for (const file of cmdFiles) {
} }
//! commands testing //! commands testing
const cmdTestPath = path.join(__dirname, 'commands-testing'); const cmdTestPath = path.join(__dirname, "commands-testing");
const cmdTestFiles = const cmdTestFiles = fs.readdirSync(cmdTestPath).filter((file) => file.endsWith(".js"));
fs.readdirSync(cmdTestPath).filter(file => file.endsWith('.js'));
for (const file of cmdTestFiles) { for (const file of cmdTestFiles) {
const filePath = path.join(cmdTestPath, file); const filePath = path.join(cmdTestPath, file);
const cmd = require(filePath); const cmd = require(filePath);
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') { if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
client.commands.set(cmd.data.name, cmd); client.commands.set(cmd.data.name, cmd);
} else { } else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`); console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
@@ -56,9 +53,8 @@ for (const file of cmdTestFiles) {
} }
//! command handler //! command handler
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) if (!interaction.isChatInputCommand()) return;
return;
const command = interaction.client.commands.get(interaction.commandName); const command = interaction.client.commands.get(interaction.commandName);
@@ -72,23 +68,21 @@ client.on(Events.InteractionCreate, async interaction => {
} catch (error) { } catch (error) {
console.error(error); console.error(error);
await interaction.reply({ await interaction.reply({
content: 'There was an error while executing this command!', content: "There was an error while executing this command!",
ephemeral: true ephemeral: true,
}) });
} }
}); });
//! commands //! commands
const contextMenuPath = path.join(__dirname, 'commands-contextmenu'); const contextMenuPath = path.join(__dirname, "commands-contextmenu");
const contextMenuFiles = const contextMenuFiles = fs.readdirSync(contextMenuPath).filter((file) => file.endsWith(".js"));
fs.readdirSync(contextMenuPath).filter(file => file.endsWith('.js'));
for (const file of contextMenuFiles) { for (const file of contextMenuFiles) {
const filePath = path.join(contextMenuPath, file); const filePath = path.join(contextMenuPath, file);
const cmd = require(filePath); const cmd = require(filePath);
if ('data' in cmd && 'execute' in cmd && cmd.type === 'contextmenu') { if ("data" in cmd && "execute" in cmd && cmd.type === "contextmenu") {
client.commands.set(cmd.data.name, cmd); client.commands.set(cmd.data.name, cmd);
} else { } else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`); console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
@@ -96,9 +90,8 @@ for (const file of contextMenuFiles) {
} }
//! context menu command handler //! context menu command handler
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isContextMenuCommand()) if (!interaction.isContextMenuCommand()) return;
return;
const command = interaction.client.commands.get(interaction.commandName); const command = interaction.client.commands.get(interaction.commandName);
@@ -112,22 +105,21 @@ client.on(Events.InteractionCreate, async interaction => {
} catch (error) { } catch (error) {
console.error(error); console.error(error);
await interaction.reply({ await interaction.reply({
content: 'There was an error while executing this command!', content: "There was an error while executing this command!",
ephemeral: true ephemeral: true,
}) });
} }
}); });
//! button events //! button events
const btnPath = path.join(__dirname, 'events', 'buttons'); const btnPath = path.join(__dirname, "events", "buttons");
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith('.js')); const btnFiles = fs.readdirSync(btnPath).filter((file) => file.endsWith(".js"));
for (const file of btnFiles) { for (const file of btnFiles) {
const filePath = path.join(btnPath, file); const filePath = path.join(btnPath, file);
const btn = require(filePath); const btn = require(filePath);
if ('name' in btn && 'execute' in btn && btn.type === 'button') { if ("name" in btn && "execute" in btn && btn.type === "button") {
client.events.set(btn.name, btn); client.events.set(btn.name, btn);
} else { } else {
console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`); console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`);
@@ -135,9 +127,8 @@ for (const file of btnFiles) {
} }
//! button event handler //! button event handler
client.on(Events.InteractionCreate, async event => { client.on(Events.InteractionCreate, async (event) => {
if (!event.isButton()) if (!event.isButton()) return;
return;
const event2 = event.client.events.get(event.customId); const event2 = event.client.events.get(event.customId);
@@ -151,57 +142,53 @@ client.on(Events.InteractionCreate, async event => {
} catch (error) { } catch (error) {
console.error(error); console.error(error);
await event.reply({ await event.reply({
content: 'There was an error while executing this event!', content: "There was an error while executing this event!",
ephemeral: true ephemeral: true,
}) });
} }
}) });
//! modals //! modals
const modalPath = path.join(__dirname, 'events', 'modals'); const modalPath = path.join(__dirname, "events", "modals");
const modalFiles = const modalFiles = fs.readdirSync(modalPath).filter((file) => file.endsWith(".js"));
fs.readdirSync(modalPath).filter(file => file.endsWith('.js'));
for (const file of modalFiles) { for (const file of modalFiles) {
const filePath = path.join(modalPath, file); const filePath = path.join(modalPath, file);
const modal = require(filePath); const modal = require(filePath);
if ('name' in modal && 'execute' in modal && modal.type === 'modal') { if ("name" in modal && "execute" in modal && modal.type === "modal") {
client.on(Events.InteractionCreate, modal.execute); client.on(Events.InteractionCreate, modal.execute);
} else { } else {
console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`); console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`);
} }
} }
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async (interaction) => {
if (interaction.isCommand()) { if (interaction.isCommand()) {
console.log(interaction.user.username + "#" + console.log(
interaction.user.discriminator + " ran " + interaction.user.username + "#" + interaction.user.discriminator + " ran " + interaction.commandName,
interaction.commandName); );
} else if (interaction.isButton()) { } else if (interaction.isButton()) {
console.log(interaction.user.username + "#" + console.log(
interaction.user.discriminator + " clicked " + interaction.user.username + "#" + interaction.user.discriminator + " clicked " + interaction.customId,
interaction.customId); );
} }
}); });
client.on(Events.ClientReady, () => { client.on(Events.ClientReady, () => {
console.log("Logged in as " + client.user.tag + "!"); console.log("Logged in as " + client.user.tag + "!");
const channel = client.channels.cache.get(botLogChannel); const channel = client.channels.cache.get(botLogChannel);
const embedColor = Number(color.replace('#', '0x')) const embedColor = Number(color.replace("#", "0x"));
if (!channel) { if (!channel) {
return; return;
} }
channel.send( channel.send({ embeds: [{ description: `Bot is online!`, color: embedColor }] });
{ embeds: [{ description: `Bot is online!`, color: embedColor }] });
}); });
client.on(Events.ClientReady, () => { client.on(Events.ClientReady, () => {
client.user.setActivity( client.user.setActivity({ name: "over the Illegitimate Server", type: ActivityType.Watching });
{ name: "over the Illegitimate Server", type: ActivityType.Watching });
const activities = [ const activities = [
{ name: "for Martina's return", type: ActivityType.Watching }, { name: "for Martina's return", type: ActivityType.Watching },
@@ -210,17 +197,17 @@ client.on(Events.ClientReady, () => {
{ name: "with Perlcence the AI", type: ActivityType.Playing }, { name: "with Perlcence the AI", type: ActivityType.Playing },
{ name: "with ur mom in my bed", type: ActivityType.Playing }, { name: "with ur mom in my bed", type: ActivityType.Playing },
{ name: "with Jone the idiot", type: ActivityType.Playing }, { name: "with Jone the idiot", type: ActivityType.Playing },
{ name: "over the Illegitimate Server", type: ActivityType.Watching } { name: "over the Illegitimate Server", type: ActivityType.Watching },
]; ];
let i = 0; let i = 0;
setInterval(() => setInterval(() => client.user.setActivity(activities[i++ % activities.length]), 1000 * 60 * 30);
client.user.setActivity(activities[i++ % activities.length]), });
1000 * 60 * 30) client.on(Events.ClientReady, () => {
client.user.setStatus("dnd");
}); });
client.on(Events.ClientReady, () => { client.user.setStatus('dnd'); });
client.login(token); client.login(token);
connect(mongoURI, {}).then(() => { connect(mongoURI, {}).then(() => {
console.log('Connected to MongoDB'); console.log("Connected to MongoDB");
}) });

1408
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,18 @@
{ {
"name": "illegitimate-bot", "name": "illegitimate-bot",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"prod:build": "node scripts/deploy-commands.js --prod", "prod:build": "node scripts/deploy-commands.js --prod",
"dev:build": "node scripts/deploy-commands.js --dev" "dev:build": "node scripts/deploy-commands.js --dev"
}, },
"author": "Taken", "author": "Taken",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"axios": "^1.3.4", "axios": "^1.3.4",
"discord.js": "^14.8.0", "discord.js": "^14.8.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"mongoose": "^7.0.1" "mongoose": "^7.0.1"
} }
} }

View File

@@ -1,4 +1,4 @@
const { Schema, model } = require('mongoose'); const { Schema, model } = require("mongoose");
const guildAppSchema = new Schema({ const guildAppSchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
@@ -6,4 +6,4 @@ const guildAppSchema = new Schema({
uuid: { type: String, required: true }, uuid: { type: String, required: true },
}); });
module.exports = model('guildapp', guildAppSchema, 'guildapp'); module.exports = model("guildapp", guildAppSchema, "guildapp");

View File

@@ -1,4 +1,4 @@
const { Schema, model } = require('mongoose'); const { Schema, model } = require("mongoose");
const staffAppSchema = new Schema({ const staffAppSchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
@@ -6,4 +6,4 @@ const staffAppSchema = new Schema({
uuid: { type: String, required: true }, uuid: { type: String, required: true },
}); });
module.exports = model('staffapp', staffAppSchema, 'staffapp'); module.exports = model("staffapp", staffAppSchema, "staffapp");

View File

@@ -1,4 +1,4 @@
const { Schema, model } = require('mongoose'); const { Schema, model } = require("mongoose");
const verifySchema = new Schema({ const verifySchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
@@ -6,4 +6,4 @@ const verifySchema = new Schema({
uuid: { type: String, required: true }, uuid: { type: String, required: true },
}); });
module.exports = model('verify', verifySchema, 'verify'); module.exports = model("verify", verifySchema, "verify");

View File

@@ -1,11 +1,11 @@
const { Schema, model } = require('mongoose'); const { Schema, model } = require("mongoose");
const waitinglistSchema = new Schema({ const waitinglistSchema = new Schema({
_id: Schema.Types.ObjectId, _id: Schema.Types.ObjectId,
userID: { type: String, required: true }, userID: { type: String, required: true },
uuid: { type: String, required: true }, uuid: { type: String, required: true },
IGN: { type: String, required: true }, IGN: { type: String, required: true },
timestamp: { type: String, required: true } timestamp: { type: String, required: true },
}); });
module.exports = model('waitinglist', waitinglistSchema, 'waitinglist'); module.exports = model("waitinglist", waitinglistSchema, "waitinglist");

View File

@@ -1,87 +1,76 @@
const { REST, Routes } = require('discord.js'); const { REST, Routes } = require("discord.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const token = process.env.PRODTOKEN; const token = process.env.PRODTOKEN;
const clientId = process.env.CLIENTID; const clientId = process.env.CLIENTID;
const guildId = process.env.GUILDID; const guildId = process.env.GUILDID;
const fs = require('node:fs'); const fs = require("node:fs");
const args = process.argv.slice(2); const args = process.argv.slice(2);
const arg = args[0]; const arg = args[0];
if (!arg) { if (!arg) {
console.log('Please specify a command to run!'); console.log("Please specify a command to run!");
} } else if (arg === "--prod") {
else if (arg === '--prod') { const commands = [];
const commands = []; // Grab all the command files from the commands directory you created earlier
// Grab all the command files from the commands directory you created earlier const commandFiles = fs.readdirSync("./commands").filter((file) => file.endsWith(".js"));
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); const contentMenuCommands = fs.readdirSync("./commands-contextmenu").filter((file) => file.endsWith(".js"));
const contentMenuCommands = fs.readdirSync('./commands-contextmenu').filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment for (const file of commandFiles) {
for (const file of commandFiles) { const command = require(`../commands/${file}`);
const command = require(`../commands/${file}`); commands.push(command.data.toJSON());
commands.push(command.data.toJSON()); }
}
for (const file of contentMenuCommands) {
for (const file of contentMenuCommands) { const command = require(`../commands-contextmenu/${file}`);
const command = require(`../commands-contextmenu/${file}`); commands.push(command.data.toJSON());
commands.push(command.data.toJSON()); }
}
// Construct and prepare an instance of the REST module
// Construct and prepare an instance of the REST module const rest = new REST({ version: "10" }).setToken(token);
const rest = new REST({ version: '10' }).setToken(token);
// and deploy your commands!
(async () => {
// and deploy your commands! try {
(async () => { console.log(`Started refreshing ${commands.length} application (/) commands.`);
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`); // The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(Routes.applicationCommands(clientId), { body: commands });
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put( console.log(`Successfully reloaded ${data.length} application (/) commands.`);
Routes.applicationCommands(clientId), } catch (error) {
{ body: commands }, // And of course, make sure you catch and log any errors!
); console.error(error);
}
console.log(`Successfully reloaded ${data.length} application (/) commands.`); })();
} catch (error) { } else if (arg === "--dev") {
// And of course, make sure you catch and log any errors! const commands = [];
console.error(error); // Grab all the command files from the commands directory you created earlier
} const commandFiles = fs.readdirSync("./commands-testing").filter((file) => file.endsWith(".js"));
})();
} // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
else if (arg === '--dev') { for (const file of commandFiles) {
const commands = []; const command = require(`../commands-testing/${file}`);
// Grab all the command files from the commands directory you created earlier commands.push(command.data.toJSON());
const commandFiles = fs.readdirSync('./commands-testing').filter(file => file.endsWith('.js')); }
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment // Construct and prepare an instance of the REST module
for (const file of commandFiles) { const rest = new REST({ version: "10" }).setToken(token);
const command = require(`../commands-testing/${file}`);
commands.push(command.data.toJSON()); // and deploy your commands!
} (async () => {
try {
// Construct and prepare an instance of the REST module console.log(`Started refreshing ${commands.length} application (/) commands.`);
const rest = new REST({ version: '10' }).setToken(token);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands });
// and deploy your commands!
(async () => { console.log(`Successfully reloaded ${data.length} application (/) commands.`);
try { } catch (error) {
console.log(`Started refreshing ${commands.length} application (/) commands.`); // And of course, make sure you catch and log any errors!
console.error(error);
// The put method is used to fully refresh all commands in the guild with the current set }
const data = await rest.put( })();
Routes.applicationGuildCommands(clientId, guildId), } else if (arg && arg !== "--prod" && arg !== "--dev") {
{ body: commands }, console.log("Invalid argument!");
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
}
else if (arg && arg !== '--prod' && arg !== '--dev') {
console.log('Invalid argument!');
} }

View File

@@ -1,5 +1,5 @@
const { REST, Routes } = require('discord.js'); const { REST, Routes } = require("discord.js");
const env = require('dotenv').config(); const env = require("dotenv").config();
const token = process.env.TOKEN; const token = process.env.TOKEN;
const clientId = process.env.DEVID; const clientId = process.env.DEVID;
const guildId = process.env.GUILDID; const guildId = process.env.GUILDID;
@@ -8,34 +8,28 @@ const commands = [];
// Grab all the command files from the commands directory you created earlier // Grab all the command files from the commands directory you created earlier
// const commandFiles = fs.readdirSync('./commands-testing').filter(file => file.endsWith('.js')); // const commandFiles = fs.readdirSync('./commands-testing').filter(file => file.endsWith('.js'));
const commandFiles = [ const commandFiles = ["./commands/config.js"];
'./commands/config.js',
]
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`${file}`); const command = require(`${file}`);
commands.push(command.data.toJSON()); commands.push(command.data.toJSON());
} }
// Construct and prepare an instance of the REST module // Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token); const rest = new REST({ version: "10" }).setToken(token);
// and deploy your commands! // and deploy your commands!
(async () => { (async () => {
try { try {
console.log(`Started refreshing ${commands.length} application (/) commands.`); console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set // The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put( const data = await rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands });
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`); console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) { } catch (error) {
// And of course, make sure you catch and log any errors! // And of course, make sure you catch and log any errors!
console.error(error); console.error(error);
} }
})(); })();

View File

@@ -1,52 +1,51 @@
/* ---------- bedwars level ---------- */ /* ---------- bedwars level ---------- */
function getExpForLevel(level){ function getExpForLevel(level) {
if(level == 0) return 0; if (level == 0) return 0;
var respectedLevel = getLevelRespectingPrestige(level); var respectedLevel = getLevelRespectingPrestige(level);
if(respectedLevel > EASY_LEVELS){ if (respectedLevel > EASY_LEVELS) {
return 5000; return 5000;
} }
switch(respectedLevel){ switch (respectedLevel) {
case 1: case 1:
return 500; return 500;
case 2: case 2:
return 1000; return 1000;
case 3: case 3:
return 2000; return 2000;
case 4: case 4:
return 3500; return 3500;
} }
return 5000; return 5000;
} }
function getLevelRespectingPrestige(level){ function getLevelRespectingPrestige(level) {
if(level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE){ if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE; return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE;
} } else {
else { return level % LEVELS_PER_PRESTIGE;
return level % LEVELS_PER_PRESTIGE; }
}
} }
const EASY_LEVELS = 4; const EASY_LEVELS = 4;
const EASY_LEVELS_XP = 7000; const EASY_LEVELS_XP = 7000;
const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP; const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP;
const LEVELS_PER_PRESTIGE = 100; const LEVELS_PER_PRESTIGE = 100;
const HIGHEST_PRESTIGE = 50; const HIGHEST_PRESTIGE = 50;
function getLevelForExp(exp){ function getLevelForExp(exp) {
var prestiges = Math.floor(exp / XP_PER_PRESTIGE); var prestiges = Math.floor(exp / XP_PER_PRESTIGE);
var level = prestiges * LEVELS_PER_PRESTIGE; var level = prestiges * LEVELS_PER_PRESTIGE;
var expWithoutPrestiges = exp - (prestiges * XP_PER_PRESTIGE); var expWithoutPrestiges = exp - prestiges * XP_PER_PRESTIGE;
for(let i = 1; i <= EASY_LEVELS; ++i){ for (let i = 1; i <= EASY_LEVELS; ++i) {
var expForEasyLevel = getExpForLevel(i); var expForEasyLevel = getExpForLevel(i);
if(expWithoutPrestiges < expForEasyLevel){ if (expWithoutPrestiges < expForEasyLevel) {
break; break;
} }
level++; level++;
expWithoutPrestiges -= expForEasyLevel; expWithoutPrestiges -= expForEasyLevel;
} }
return level + expWithoutPrestiges / 5000 return level + expWithoutPrestiges / 5000;
} }
// hypixel // hypixel
const BASE = 10000; const BASE = 10000;
@@ -59,51 +58,51 @@ const REVERSE_CONST = REVERSE_PQ_PREFIX * REVERSE_PQ_PREFIX;
const GROWTH_DIVIDES_2 = 2 / GROWTH; const GROWTH_DIVIDES_2 = 2 / GROWTH;
function getLevel(exp) { function getLevel(exp) {
return exp <= 1 ? 1 : Math.floor(1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp)); return exp <= 1 ? 1 : Math.floor(1 + REVERSE_PQ_PREFIX + Math.sqrt(REVERSE_CONST + GROWTH_DIVIDES_2 * exp));
} }
function getExactLevel(exp) { function getExactLevel(exp) {
return getLevel(exp) + getPercentageToNextLevel(exp); return getLevel(exp) + getPercentageToNextLevel(exp);
} }
function getExpFromLevelToNext(level) { function getExpFromLevelToNext(level) {
return level < 1 ? BASE : GROWTH * (level - 1) + BASE; return level < 1 ? BASE : GROWTH * (level - 1) + BASE;
} }
function getTotalExpToLevel(level) { function getTotalExpToLevel(level) {
const lv = Math.floor(level); const const lv = Math.floor(level);
x0 = getTotalExpToFullLevel(lv); const x0 = getTotalExpToFullLevel(lv);
if (level === lv) return x0; if (level === lv) return x0;
return (getTotalExpToFullLevel(lv + 1) - x0) * (level % 1) + x0; return (getTotalExpToFullLevel(lv + 1) - x0) * (level % 1) + x0;
} }
function getTotalExpToFullLevel(level) { function getTotalExpToFullLevel(level) {
return (HALF_GROWTH * (level - 2) + BASE) * (level - 1); return (HALF_GROWTH * (level - 2) + BASE) * (level - 1);
} }
function getPercentageToNextLevel(exp) { function getPercentageToNextLevel(exp) {
const lv = getLevel(exp); const lv = getLevel(exp);
const x0 = getTotalExpToLevel(lv); const x0 = getTotalExpToLevel(lv);
return (exp - x0) / (getTotalExpToLevel(lv + 1) - x0); return (exp - x0) / (getTotalExpToLevel(lv + 1) - x0);
} }
/* ---------- skywars level ---------- */ /* ---------- skywars level ---------- */
function skywarsLevel(xp) { function skywarsLevel(xp) {
var xps = [0, 20, 70, 150, 250, 500, 1000, 2000, 3500, 6000, 10000, 15000]; var xps = [0, 20, 70, 150, 250, 500, 1000, 2000, 3500, 6000, 10000, 15000];
let exactLevel = 0 let exactLevel = 0;
if (xp >= 15000) { if (xp >= 15000) {
exactLevel = (xp - 15000) / 10000 + 12; exactLevel = (xp - 15000) / 10000 + 12;
return exactLevel; return exactLevel;
} else { } else {
for (i = 0; i < xps.length; i++) { for (i = 0; i < xps.length; i++) {
if (xp < xps[i]) { if (xp < xps[i]) {
exactLevel = i + (xp - xps[i-1]) / (xps[i] - xps[i-1]); exactLevel = i + (xp - xps[i - 1]) / (xps[i] - xps[i - 1]);
return exactLevel; return exactLevel;
} }
} }
} }
} }
module.exports = { module.exports = {
getExactLevel, getExactLevel,
skywarsLevel, skywarsLevel,
getLevelForExp getLevelForExp,
} };