Beautifying

This commit is contained in:
2023-04-24 23:38:33 +02:00
parent e2747dab3f
commit 3a3bb89635
40 changed files with 4010 additions and 3388 deletions

View File

@@ -1,34 +1,46 @@
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,55 @@
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,49 +1,44 @@
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: 'functest', name: "functest",
description: 'Test command for the bot.', description: "Test command for the bot.",
type: 'slash', type: "slash",
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('functest') .setName("functest")
.setDescription('Test command for the bot.') .setDescription("Test command for the bot.")
.addStringOption(option => .addStringOption((option) =>
option option.setName("test").setDescription("Test option.")
.setName('test') )
.setDescription('Test option.')) .addStringOption((option) =>
.addStringOption(option => option.setName("test2").setDescription("Test option.")
option )
.setName('test2') .addStringOption((option) =>
.setDescription('Test option.')) option.setName("test3").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 uuid = await getuuid(test); const uuid = await getuuid(test);
if (uuid === null) { if (uuid === null) {
await interaction.reply({ await interaction.reply({
content: 'Invalid username.', content: "Invalid username.",
ephemeral: true ephemeral: true
}); });
return return;
} }
await interaction.reply({ await interaction.reply({
content: uuid, content: uuid,
ephemeral: true ephemeral: true
}); });
} }
}; };

View File

@@ -1,88 +1,101 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); const {
const env = require('dotenv').config(); SlashCommandBuilder,
PermissionFlagsBits,
userMention
} = require("discord.js");
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 option
.setName('user') .setName("user")
.setDescription('The user to mute') .setDescription("The user to mute")
.setRequired(true)) .setRequired(true)
.addStringOption(option => )
option .addStringOption((option) =>
.setName('reason') option.setName("reason").setDescription("The reason for the mute")
.setDescription('The reason for the mute')) )
.addStringOption(option => .addStringOption((option) =>
option option.setName("duration").setDescription("The duration of the mute")
.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 =
const duration = interaction.options.getString('duration'); interaction.options.getString("reason") ?? "No reason provided";
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.", description: "You don't have permission to use this command.",
color: embedColor, color: embedColor,
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 (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.", description: "You can't mute yourself.",
color: embedColor, color: embedColor,
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 (member.id === dev) { if (member.id === dev) {
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
description: "You can't mute my developer.", description: "You can't mute my developer.",
color: embedColor, color: embedColor,
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 (memberRoles.includes(admin) || memberRoles.includes(helper)) { // if (memberRoles.includes(admin) || memberRoles.includes(helper)) {
@@ -102,25 +115,28 @@ 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.", {
description:
"Successfully muted " + userMention(member1.id) + " forever.",
color: embedColor, color: embedColor,
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;
} }
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;
@@ -128,19 +144,36 @@ module.exports = {
const nminutes = Number(minutes) ?? 0; const nminutes = Number(minutes) ?? 0;
const nseconds = Number(seconds) ?? 0; const nseconds = Number(seconds) ?? 0;
const time = nweeks * 604800000 + ndays * 86400000 + nhours * 3600000 + nminutes * 60000 + nseconds * 1000; const time =
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)" : ""); 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)" : "");
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 + ".", {
description:
"Successfully muted " +
userMention(member1.id) +
" for " +
mutedTime +
".",
color: embedColor, color: embedColor,
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 })
} }
}] }
]
}); });
const logChannel = interaction.guild.channels.cache.get(staffOtherChannel); const logChannel = interaction.guild.channels.cache.get(staffOtherChannel);
@@ -148,15 +181,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.", description: userMention(member1.id) + " has been unmuted.",
color: embedColor, color: embedColor,
footer: { footer: {
text: "ID: " + member1.id, text: "ID: " + member1.id,
icon_url: interaction.guild.iconURL({ dynamic: true }) icon_url: interaction.guild.iconURL({ dynamic: true })
} }
}] }
}) ]
});
}, time); }, time);
} }
}; };

View File

@@ -1,45 +1,55 @@
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js'); const {
const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../config/reqs.json') SlashCommandBuilder,
const getuuid = require('../utils/functions'); EmbedBuilder,
const env = require('dotenv').config(); PermissionFlagsBits
} = require("discord.js");
const {
bwfdkr,
bwstars,
bwwins,
duelswins,
swstars
} = require("../config/reqs.json");
const getuuid = require("../utils/functions");
const env = require("dotenv").config();
const hypixelApiKey = process.env.HYPIXELAPI; const hypixelApiKey = process.env.HYPIXELAPI;
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
const fetch = require('axios'); const fetch = require("axios");
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 => .addStringOption((option) =>
option option
.setName('ign') .setName("ign")
.setDescription('The player\'s IGN.') .setDescription("The player's IGN.")
.setRequired(true)) .setRequired(true)
)
.setDMPermission(false), .setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({});
await interaction.deferReply({}) const ign = interaction.options.getString("ign");
const mojang = "https://api.mojang.com/users/profiles/minecraft/";
const ign = interaction.options.getString('ign');
const mojang = "https://api.mojang.com/users/profiles/minecraft/"
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 minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
if (!ign) { if (!ign) {
await interaction.editReply('Please provide a player\'s IGN.') await interaction.editReply("Please provide a player's IGN.");
return return;
} }
if (await getuuid(ign) === null) { if ((await getuuid(ign)) === null) {
await interaction.editReply('That player doesn\'t exist. [Mojang]') await interaction.editReply("That player doesn't exist. [Mojang]");
return return;
} }
const userUUID = await getuuid(ign); const userUUID = await getuuid(ign);
@@ -47,72 +57,84 @@ module.exports = {
try { try {
await fetch(slothPixel + userUUID); await fetch(slothPixel + userUUID);
} catch (error) { } catch (error) {
interaction.editReply('That player doesn\'t exist. [Hypixel]') interaction.editReply("That player doesn't exist. [Hypixel]");
return return;
} }
const stats = await fetch(slothPixel + userUUID); const stats = await fetch(slothPixel + userUUID);
const head = minotar + ign; const head = minotar + ign;
if (!stats.data.uuid) { if (!stats.data.uuid) {
interaction.editReply('That player doesn\'t exist. [Hypixel]') interaction.editReply("That player doesn't exist. [Hypixel]");
return return;
} }
const rank_formatted = stats.data.rank_formatted const rank_formatted = stats.data.rank_formatted;
const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, "") const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, "");
if (rank2 === "") { if (rank2 === "") {
var rank = "" var rank = "";
} else { } else {
var rank = rank2 + " " var rank = rank2 + " ";
} }
try { try {
const guildCheck = await fetch(guildAPI + userUUID); const guildCheck = await fetch(guildAPI + userUUID);
var guildName = guildCheck.data.name var guildName = guildCheck.data.name;
} catch (error) { } catch (error) {
var guildName = "None" var guildName = "None";
} }
const hsbwstars = stats.data.stats.BedWars.level const hsbwstars = stats.data.stats.BedWars.level;
const hsbwfkdr = stats.data.stats.BedWars.final_k_d const hsbwfkdr = stats.data.stats.BedWars.final_k_d;
const hsbwwins = stats.data.stats.BedWars.wins const hsbwwins = stats.data.stats.BedWars.wins;
const hsswstars = stats.data.stats.SkyWars.level const hsswstars = stats.data.stats.SkyWars.level;
const hsduelswins = stats.data.stats.Duels.general.wins const hsduelswins = stats.data.stats.Duels.general.wins;
if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) { if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && 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) { if (hsduelswins < duelswins) {
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.";
} }
try { try {
const guildCheck = await fetch(guildAPI + userUUID); const guildCheck = await fetch(guildAPI + userUUID);
const tag_formatted = guildCheck.data.tag_formatted const tag_formatted = guildCheck.data.tag_formatted;
const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "") const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "");
var guildTag = " " + guildTag2 var guildTag = " " + guildTag2;
} catch (error) { } catch (error) {
var guildTag = "" var guildTag = "";
} }
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: rank + stats.data.username + guildTag, title: rank + stats.data.username + guildTag,
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + description:
"**Current Guild:** `" + guildName + "`", "**Network Level:** `" +
stats.data.level.toString() +
"`\n" +
"**Current Guild:** `" +
guildName +
"`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -124,24 +146,58 @@ module.exports = {
fields: [ fields: [
{ {
name: bwtitle, name: bwtitle,
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + " / " + bwstars.toString() + "`\n" + value:
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + " / " + bwfdkr.toString() + "`\n" + "**➺ Stars:** `" +
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + " / " + bwwins.toString() + "`" stats.data.stats.BedWars.level.toString() +
" / " +
bwstars.toString() +
"`\n" +
"**➺ FKDR:** `" +
stats.data.stats.BedWars.final_k_d.toString() +
" / " +
bwfdkr.toString() +
"`\n" +
"**➺ Wins:** `" +
stats.data.stats.BedWars.wins.toString() +
" / " +
bwwins.toString() +
"`"
}, },
{ {
name: swtitle, name: swtitle,
value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + " / " + swstars.toString() + "`\n" + value:
"**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" + "**➺ Stars:** `" +
"**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`" stats.data.stats.SkyWars.level.toFixed(2).toString() +
" / " +
swstars.toString() +
"`\n" +
"**➺ KDR:** `" +
stats.data.stats.SkyWars.kill_death_ratio.toString() +
"`\n" +
"**➺ Wins:** `" +
stats.data.stats.SkyWars.wins.toString() +
"`"
}, },
{ {
name: duelstitle, name: duelstitle,
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + " / " + duelswins.toString() + "`\n" + value:
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + "**➺ Wins:** `" +
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`" stats.data.stats.Duels.general.wins.toString() +
" / " +
duelswins.toString() +
"`\n" +
"**➺ KDR:** `" +
stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() +
"`\n" +
"**➺ WLR:** `" +
stats.data.stats.Duels.general.win_loss_ratio
.toFixed(2)
.toString() +
"`"
} }
] ]
}] }
}) ]
});
} }
}; };

View File

@@ -1,70 +1,83 @@
const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle, EmbedBuilder, WebhookClient } = require('discord.js'); const {
const { title } = require('process'); SlashCommandBuilder,
const { color } = require('../config/options.json'); PermissionFlagsBits,
ButtonBuilder,
ActionRowBuilder,
ButtonStyle,
EmbedBuilder,
WebhookClient
} = require("discord.js");
const { title } = require("process");
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 subcommand
.setName('sendguildapplication') .setName("sendguildapplication")
.setDescription('Send the application 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 application to.') .setDescription("The channel to send the application to.")
.setRequired(true))) .setRequired(true)
.addSubcommand(subcommand => )
)
.addSubcommand((subcommand) =>
subcommand subcommand
.setName('sendstaffapplication') .setName("sendstaffapplication")
.setDescription('Send the application 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 application to.') .setDescription("The channel to send the application to.")
.setRequired(true))) .setRequired(true)
.addSubcommand(subcommand => )
)
.addSubcommand((subcommand) =>
subcommand subcommand
.setName('sendguildinfo') .setName("sendguildinfo")
.setDescription('Send the guild info message to a channel.')) .setDescription("Send the guild info message to a channel.")
.addSubcommand(subcommand => )
.addSubcommand((subcommand) =>
subcommand subcommand
.setName('sendrequirements') .setName("sendrequirements")
.setDescription('Send the guild requirements message to a channel.')) .setDescription("Send the guild requirements message to a channel.")
.addSubcommand(subcommand => )
.addSubcommand((subcommand) =>
subcommand subcommand
.setName('sendrules-info') .setName("sendrules-info")
.setDescription('Send the rules and info message to a channel.')) .setDescription("Send the rules and info message to a channel.")
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false), .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 === 'reload') { if (subcommand === "reload") {
await interaction.reply({ content: "In development", ephemeral: true });
await interaction.reply({ content: 'In development', ephemeral: true }) return;
return
} }
if (subcommand === 'sendguildapplication') { if (subcommand === "sendguildapplication") {
const channel = interaction.options.getChannel("channel");
const channel = interaction.options.getChannel('channel');
await channel.send({ await channel.send({
embeds: [{ embeds: [
title: 'Guild Application', {
description: "You can apply for the guild by clicking the button below.", title: "Guild Application",
description:
"You can apply for the guild by clicking the button below.",
color: embedColor, color: embedColor,
footer: { footer: {
text: interaction.guild.name + " | Developed by @Taken#0002", text: interaction.guild.name + " | Developed by @Taken#0002",
@@ -73,28 +86,30 @@ module.exports = {
thumbnail: { thumbnail: {
url: interaction.guild.iconURL({ dynamic: true }) url: interaction.guild.iconURL({ dynamic: true })
} }
}], }
],
components: [ components: [
new ActionRowBuilder().addComponents( new ActionRowBuilder().addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId('guildapply') .setCustomId("guildapply")
.setLabel('Apply') .setLabel("Apply")
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setEmoji({ name: '✅' }) .setEmoji({ name: "✅" })
) )
] ]
}) });
await interaction.reply({ content: 'Message sent', ephemeral: true }) await interaction.reply({ content: "Message sent", ephemeral: true });
} }
if (subcommand === 'sendstaffapplication') { if (subcommand === "sendstaffapplication") {
const channel = interaction.options.getChannel("channel");
const channel = interaction.options.getChannel('channel');
await channel.send({ await channel.send({
embeds: [{ embeds: [
title: 'Staff Application', {
description: "You can apply for the staff team by clicking the button below.", title: "Staff Application",
description:
"You can apply for the staff team by clicking the button below.",
color: embedColor, color: embedColor,
footer: { footer: {
text: interaction.guild.name + " | Developed by @Taken#0002", text: interaction.guild.name + " | Developed by @Taken#0002",
@@ -103,23 +118,28 @@ module.exports = {
thumbnail: { thumbnail: {
url: interaction.guild.iconURL({ dynamic: true }) url: interaction.guild.iconURL({ dynamic: true })
} }
}], }
],
components: [ components: [
new ActionRowBuilder().addComponents( new ActionRowBuilder().addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId('staffapply') .setCustomId("staffapply")
.setLabel('Apply') .setLabel("Apply")
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setEmoji({ name: '✅' }) .setEmoji({ name: "✅" })
) )
] ]
}) });
await interaction.reply({ content: 'Message sent', ephemeral: true }) await interaction.reply({ content: "Message sent", ephemeral: true });
} }
if (subcommand !== "sendguildinfo" || "sendrequirements" || "sendrules-info") { if (
await interaction.reply({ content: 'In development.', ephemeral: true }); subcommand !== "sendguildinfo" ||
"sendrequirements" ||
"sendrules-info"
) {
await interaction.reply({ content: "In development.", ephemeral: true });
} }
} }
}; };

View File

@@ -1,86 +1,88 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention, EmbedBuilder } = require('discord.js'); const {
const { hypixelGuildID, color } = require('../config/options.json'); SlashCommandBuilder,
const verify = require('../schemas/verifySchema.js'); PermissionFlagsBits,
const env = require('dotenv').config(); userMention,
EmbedBuilder
} = require("discord.js");
const { hypixelGuildID, color } = require("../config/options.json");
const verify = require("../schemas/verifySchema.js");
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 subcommand
.setName('dbclearnonguildmembers') .setName("dbclearnonguildmembers")
.setDescription('Clears the database of non-guild members.')) .setDescription("Clears the database of non-guild members.")
.addSubcommand(subcommand => )
.addSubcommand((subcommand) =>
subcommand.setName("reload").setDescription("Reload the bot.")
)
.addSubcommand((subcommand) =>
subcommand subcommand
.setName('reload') .setName("listallverified")
.setDescription('Reload the bot.')) .setDescription("List all verified users.")
.addSubcommand(subcommand => )
subcommand
.setName('listallverified')
.setDescription('List all verified users.'))
.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 === 'dbclearnonguildmembers') { if (subcommand === "dbclearnonguildmembers") {
await interaction.deferReply({ ephemeral: true });
await interaction.deferReply({ ephemeral: true })
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 slothPixel = "https://api.slothpixel.me/api/guilds/" const slothPixel = "https://api.slothpixel.me/api/guilds/";
const verifiedUsers = await verify.find() const verifiedUsers = await verify.find();
verifiedUsers.forEach(async (user) => { verifiedUsers.forEach(async (user) => {
const userGuild = await fetch(slothPixel + user.uuid); const userGuild = await fetch(slothPixel + user.uuid);
if (userGuild.data.id !== hypixelGuildID) { if (userGuild.data.id !== hypixelGuildID) {
await verify.deleteOne({ uuid: user.uuid }) await verify.deleteOne({ uuid: user.uuid });
}
});
interaction.editReply({ content: "Done!", ephemeral: true });
} }
}) if (subcommand === "reload") {
await interaction.reply({ content: "In development", ephemeral: true });
interaction.editReply({ content: 'Done!', ephemeral: true }) return;
} }
if (subcommand === 'reload') { if (subcommand === "listallverified") {
const verifiedUsers = await verify.find();
await interaction.reply({ content: 'In development', ephemeral: true }) const mojang = "https://api.mojang.com/user/profile/";
return
}
if (subcommand === 'listallverified') {
const verifiedUsers = await verify.find()
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);
@@ -91,15 +93,12 @@ 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]
}) });
} }
} }
}; };

View File

@@ -1,47 +1,74 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); const {
const { hypixelGuildID, color } = require('../config/options.json'); SlashCommandBuilder,
const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); PermissionFlagsBits,
const verify = require('../schemas/verifySchema.js') userMention
const fetch = require('axios'); } = require("discord.js");
const removeThese = [gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff] const { hypixelGuildID, color } = require("../config/options.json");
const {
gm,
manager,
moderator,
beast,
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,
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 option
.setName('user') .setName("user")
.setDescription('The user to force update') .setDescription("The user to force update")
.setRequired(true)) .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 guild = interaction.guild; const guild = interaction.guild;
const verifyData = await verify.findOne({ userID: user.id }) const verifyData = await verify.findOne({ userID: user.id });
const user1 = guild.members.cache.get(user.id); const user1 = guild.members.cache.get(user.id);
const roleManage = user1.roles; const roleManage = user1.roles;
if (!verifyData) { if (!verifyData) {
for (let i = 0; i < removeThese.length; i++) { for (let i = 0; i < removeThese.length; i++) {
await roleManage.remove(removeThese[i], "Auto role removal. (Force Update)") await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)"
);
} }
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: usermentioned + " was given the the Default Member role.", {
description:
usermentioned + " was given the the Default Member role.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -50,15 +77,16 @@ module.exports = {
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 })
} }
}] }
}) ]
await roleManage.add(defaultMember, "User was force updated.") });
return await roleManage.add(defaultMember, "User was force updated.");
return;
} }
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 mojangAPI = "https://api.mojang.com/user/profile/" const mojangAPI = "https://api.mojang.com/user/profile/";
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);
@@ -73,14 +101,18 @@ module.exports = {
} }
if (responseGuildID !== hypixelGuildID) { if (responseGuildID !== 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. (Force Update)") await roleManage.remove(
removeThese[i],
"Auto role removal. (Force Update)"
);
} }
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
description: usermentioned + " was given the the Default Member role.", {
description:
usermentioned + " was given the the Default Member role.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -89,32 +121,38 @@ module.exports = {
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 })
} }
}] }
}) ]
await roleManage.add(defaultMember) });
return await roleManage.add(defaultMember);
return;
} }
const guildCheck = await fetch(guildAPI + verifyData.uuid); const guildCheck = await fetch(guildAPI + verifyData.uuid);
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const GuildMembers = await guildCheck.data.members; const GuildMembers = await guildCheck.data.members;
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank; const guildRank = GuildMembers.find(
(member) => member.uuid === verifyData.uuid
if (guildRank === 'Guild Master' && responseGuildID === hypixelGuildID) { ).rank;
if (guildRank === "Guild Master" && responseGuildID === 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. (Force Update)") 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(gm, "User was force updated.");
await roleManage.add(defaultMember, "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 `Guild Master`", {
description:
usermentioned + "'s rank has been updated to `Guild Master`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -123,25 +161,29 @@ module.exports = {
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 })
} }
}] }
}) ]
});
} }
if (guildRank === 'Manager' && responseGuildID === hypixelGuildID) { if (guildRank === "Manager" && responseGuildID === 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. (Force Update)") 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(manager, "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({ await interaction.editReply({
embeds: [{ embeds: [
description: usermentioned + "'s rank has been updated to `Manager`", {
description:
usermentioned + "'s rank has been updated to `Manager`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -150,25 +192,29 @@ module.exports = {
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 })
} }
}] }
}) ]
});
} }
if (guildRank === 'Moderator' && responseGuildID === hypixelGuildID) { if (guildRank === "Moderator" && responseGuildID === 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. (Force Update)") 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(moderator, "User was force updated.") await roleManage.add(moderator, "User was force updated.");
await roleManage.add(defaultMember, "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 `Moderator`", {
description:
usermentioned + "'s rank has been updated to `Moderator`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -177,24 +223,26 @@ module.exports = {
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 })
} }
}] }
}) ]
});
} }
if (guildRank === 'Beast' && responseGuildID === hypixelGuildID) { if (guildRank === "Beast" && responseGuildID === 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. (Force Update)") 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(beast, "User was force updated.") await roleManage.add(beast, "User was force updated.");
await roleManage.add(defaultMember, "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 `Beast`.", description: usermentioned + "'s rank has been updated to `Beast`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -204,25 +252,29 @@ module.exports = {
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 === 'Member' && responseGuildID === hypixelGuildID) { if (guildRank === "Member" && responseGuildID === 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. (Force Update)") 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(member, "User was force updated.") await roleManage.add(member, "User was force updated.");
await roleManage.add(defaultMember, "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 `Member`.", {
description:
usermentioned + "'s rank has been updated to `Member`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -231,25 +283,29 @@ module.exports = {
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 === 'Trial Member' && responseGuildID === hypixelGuildID) { if (guildRank === "Trial Member" && responseGuildID === 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. (Force Update)") 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(trialmember, "User was force updated.") await roleManage.add(trialmember, "User was force updated.");
await roleManage.add(defaultMember, "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 `Trial Member`.", {
description:
usermentioned + "'s rank has been updated to `Trial Member`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -258,9 +314,10 @@ module.exports = {
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;
} }
} }
} };

View File

@@ -1,77 +1,84 @@
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, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); const {
gm,
manager,
moderator,
beast,
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 option.setName("user").setDescription("The user to force verify.")
.setName('user') )
.setDescription('The user to force verify.')) .addStringOption((option) =>
.addStringOption(option => option.setName("ign").setDescription("The user's in-game name.")
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 fullUsername = user1.username + "#" + user1.discriminator const fullUsername = user1.username + "#" + user1.discriminator;
const ign = interaction.options.getString('ign'); const ign = interaction.options.getString("ign");
const mod = interaction.user.username + "#" + interaction.user.discriminator const mod =
interaction.user.username + "#" + interaction.user.discriminator;
const mojang = "https://api.mojang.com/users/profiles/minecraft/" const mojang = "https://api.mojang.com/users/profiles/minecraft/";
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 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.') interaction.editReply("Please provide a user to force verify.");
return return;
} }
if (!ign) { if (!ign) {
interaction.editReply('Please provide a player\'s IGN.') interaction.editReply("Please provide a player's IGN.");
return 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;
} }
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;
} }
try { try {
await fetch(slothPixel + ign); await fetch(slothPixel + ign);
} catch (err) { } catch (err) {
interaction.editReply('That player doesn\'t exist. [Hypixel]') interaction.editReply("That player doesn't exist. [Hypixel]");
return return;
} }
const userCheck = await fetch(mojang + ign); const userCheck = await fetch(mojang + ign);
@@ -88,13 +95,18 @@ module.exports = {
} }
if (responseGuildID !== hypixelGuildID) { if (responseGuildID !== hypixelGuildID) {
await user.roles.add(defaultMember, "User was force verified by " + mod); await user.roles.add(defaultMember, "User was force verified by " + mod);
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: interaction.guild.name, title: interaction.guild.name,
description: "You have successfully force verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", description:
"You have successfully force verified `" +
fullUsername +
"` with the account `" +
hypixelCheck.data.username +
"`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -103,46 +115,49 @@ module.exports = {
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"
} }
}] }
]
}); });
return return;
} }
const guildCheck = await fetch(guildAPI + userUUID); const guildCheck = await fetch(guildAPI + userUUID);
const GuildMembers = await guildCheck.data.members; const GuildMembers = await guildCheck.data.members;
const guildRank = GuildMembers.find(member => member.uuid === hypixelCheck.data.uuid).rank; const guildRank = GuildMembers.find(
(member) => member.uuid === hypixelCheck.data.uuid
).rank;
if (guildRank === "Guild Master" && guildCheck.data.id === hypixelGuildID) { if (guildRank === "Guild Master" && guildCheck.data.id === hypixelGuildID) {
await user.roles.add(gm, "User was force verified by " + mod); await user.roles.add(gm, "User was force verified by " + mod);
await user.roles.add(guildRole, "User was force verified by " + mod) await user.roles.add(guildRole, "User was force verified by " + mod);
await user.roles.add(guildStaff, "User was force verified by " + mod) await user.roles.add(guildStaff, "User was force verified by " + mod);
} }
if (guildRank === "Manager" && guildCheck.data.id === hypixelGuildID) { if (guildRank === "Manager" && guildCheck.data.id === hypixelGuildID) {
await user.roles.add(manager, "User was force verified by " + mod); await user.roles.add(manager, "User was force verified by " + mod);
await user.roles.add(guildRole, "User was force verified by " + mod) await user.roles.add(guildRole, "User was force verified by " + mod);
await user.roles.add(guildStaff, "User was force verified by " + mod) await user.roles.add(guildStaff, "User was force verified by " + mod);
} }
if (guildRank === "Moderator" && guildCheck.data.id === hypixelGuildID) { if (guildRank === "Moderator" && guildCheck.data.id === hypixelGuildID) {
await user.roles.add(moderator, "User was force verified by " + mod); await user.roles.add(moderator, "User was force verified by " + mod);
await user.roles.add(guildRole, "User was force verified by " + mod) await user.roles.add(guildRole, "User was force verified by " + mod);
await user.roles.add(guildStaff, "User was force verified by " + mod) await user.roles.add(guildStaff, "User was force verified by " + mod);
} }
if (guildRank === "Beast" && guildCheck.data.id === hypixelGuildID) { if (guildRank === "Beast" && guildCheck.data.id === hypixelGuildID) {
await user.roles.add(beast, "User was force verified by " + mod); await user.roles.add(beast, "User was force verified by " + mod);
await user.roles.add(guildRole, "User was force verified by " + mod) await user.roles.add(guildRole, "User was force verified by " + mod);
} }
if (guildRank === "Member" && guildCheck.data.id === hypixelGuildID) { if (guildRank === "Member" && guildCheck.data.id === hypixelGuildID) {
await user.roles.add(member, "User was force verified by " + mod); await user.roles.add(member, "User was force verified by " + mod);
await user.roles.add(guildRole, "User was force verified by " + mod) await user.roles.add(guildRole, "User was force verified by " + mod);
} }
if (guildRank === "Trial Member" && guildCheck.data.id === hypixelGuildID) { if (guildRank === "Trial Member" && guildCheck.data.id === hypixelGuildID) {
await user.roles.add(trialmember, "User was force verified by " + mod); await user.roles.add(trialmember, "User was force verified by " + mod);
await user.roles.add(guildRole, "User was force verified by " + mod) await user.roles.add(guildRole, "User was force verified by " + mod);
} }
await user.roles.add(defaultMember, "User was force verified by " + mod); await user.roles.add(defaultMember, "User was force verified by " + mod);
@@ -151,14 +166,20 @@ module.exports = {
_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, title: interaction.guild.name,
description: "You have successfully force verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", description:
"You have successfully force verified `" +
fullUsername +
"` with the account `" +
hypixelCheck.data.username +
"`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -167,8 +188,8 @@ module.exports = {
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,42 +1,42 @@
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') .setName("help")
.setDescription('Help command') .setDescription("Help command")
.setDMPermission(true), .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', {
title: "Commands",
description: "List of commands", description: "List of commands",
fields: [ fields: [
{ {
name: '/check', name: "/check",
value: 'Check the stats of a player' value: "Check the stats of a player"
}, },
{ {
name: '/reqs', name: "/reqs",
value: 'Check the requirements of the guild' value: "Check the requirements of the guild"
}, },
{ {
name: '/update', name: "/update",
value: 'Update\'s your roles' value: "Update's your roles"
}, },
{ {
name: '/help', name: "/help",
value: 'Shows this message' value: "Shows this message"
} }
], ],
color: embedColor, color: embedColor,
@@ -45,10 +45,10 @@ module.exports = {
}, },
footer: { footer: {
icon_url: interaction.guild.iconURL({ dynamic: true }), icon_url: interaction.guild.iconURL({ dynamic: true }),
text: interaction.guild.name + ' | Developed by: @Taken#0001' text: interaction.guild.name + " | Developed by: @Taken#0001"
} }
}] }
]
}); });
} }
}; };

View File

@@ -1,50 +1,63 @@
const { SlashCommandBuilder } = require('discord.js'); const { SlashCommandBuilder } = require("discord.js");
const { color } = require('../config/options.json'); const { color } = require("../config/options.json");
const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../config/reqs.json'); const {
bwfdkr,
bwstars,
bwwins,
duelswins,
swstars
} = 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') .setName("reqs")
.setDescription('Displays the requirements for the guild.'), .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",
description:
"**You must make 100k-150k weekly GEXP.\nAs well as onne of the game stats below**",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: interaction.guild.iconURL() url: interaction.guild.iconURL()
}, },
fields: [ fields: [
{ {
name: '**Bedwars**', name: "**Bedwars**",
value: '**Stars:** `' + bwstars.toString() + value:
'`\n**Wins:** `' + bwwins.toString() + "**Stars:** `" +
'`\n**FKDR:** `' + bwfdkr.toString() + '`' bwstars.toString() +
"`\n**Wins:** `" +
bwwins.toString() +
"`\n**FKDR:** `" +
bwfdkr.toString() +
"`"
}, },
{ {
name: '**Skywars**', name: "**Skywars**",
value: '**Stars:** `' + swstars.toString() + '`' value: "**Stars:** `" + swstars.toString() + "`"
}, },
{ {
name: '**Duels**', name: "**Duels**",
value: '**Wins:** `' + duelswins.toString() + '`' value: "**Wins:** `" + duelswins.toString() + "`"
} }
], ],
footer: { footer: {
text: interaction.guild.name + ' | Developed by: @Taken#0002', text: interaction.guild.name + " | Developed by: @Taken#0002",
icon_url: interaction.guild.iconURL() icon_url: interaction.guild.iconURL()
} }
}]
})
} }
} ]
});
}
};

View File

@@ -1,41 +1,46 @@
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.")
)
.addChannelOption((option) =>
option option
.setName('message') .setName("channel")
.setDescription('The message to send.')) .setDescription("The channel to send the message to.")
.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({
return content: "Please provide a message to send.",
ephemeral: true
});
return;
} }
if (!channel) { if (!channel) {
interaction.editReply({ content: 'Please provide a channel to send the message to.', ephemeral: true }) interaction.editReply({
return content: "Please provide a channel to send the message to.",
ephemeral: true
});
return;
} }
channel.send({ channel.send({

View File

@@ -1,39 +1,50 @@
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') .setName("user")
.setDescription('The user to set the nickname for') .setDescription("The user to set the nickname for")
.setRequired(true)) .setRequired(true)
.addStringOption(option => )
.addStringOption((option) =>
option option
.setName('nickname') .setName("nickname")
.setDescription('The nickname to set') .setDescription("The nickname to set")
.setRequired(true)) .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,64 @@
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') .setName("seconds")
.setDescription('The amount of seconds to set the slowmode to.')) .setDescription("The amount of seconds to set the slowmode to.")
.addChannelOption(option => )
.addChannelOption((option) =>
option option
.setName('channel') .setName("channel")
.setDescription('The channel to set the slowmode of.')) .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.`, description: `Set the slowmode of ${channel} to 21600 seconds.`,
color: embedColor, color: embedColor,
footer: { footer: {
text: interaction.guild.name + " | Developed by: @Taken#0001", text: interaction.guild.name + " | Developed by: @Taken#0001",
icon_url: interaction.guild.iconURL({ dynamic: true }) 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.`, description: `Set the slowmode of ${channel} to ${seconds} seconds.`,
color: embedColor, color: embedColor,
footer: { footer: {
text: interaction.guild.name + " | Developed by: @Taken#0001", text: interaction.guild.name + " | Developed by: @Taken#0001",
icon_url: interaction.guild.iconURL({ dynamic: true }) icon_url: interaction.guild.iconURL({ dynamic: true })
} }
}]
})
await channel.setRateLimitPerUser(seconds)
} }
} ]
});
await channel.setRateLimitPerUser(seconds);
}
};

View File

@@ -1,40 +1,58 @@
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, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); const {
gm,
manager,
moderator,
beast,
member,
trialmember,
guildRole,
guildStaff,
defaultMember
} = require("../config/roles.json");
const removeThese = [gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff]; const removeThese = [
gm,
manager,
moderator,
beast,
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') .setName("update")
.setDescription('Update your guild rank.') .setDescription("Update your guild rank.")
.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 verifyData = await verify.findOne({ userID: user.id }) const verifyData = await verify.findOne({ userID: user.id });
const roleManage = user.roles; const roleManage = user.roles;
if (!verifyData) { if (!verifyData) {
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 interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
description: "Updated your roles to `Default Member`", description: "Updated your roles to `Default Member`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -44,14 +62,15 @@ module.exports = {
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;
} }
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 mojangAPI = "https://api.mojang.com/user/profile/" const mojangAPI = "https://api.mojang.com/user/profile/";
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);
@@ -65,15 +84,15 @@ module.exports = {
} }
if (responseGuildID !== hypixelGuildID) { if (responseGuildID !== 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`", description: "Updated your roles to `Default Member`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -83,9 +102,10 @@ module.exports = {
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;
} }
const guildCheck = await fetch(guildAPI + verifyData.uuid); const guildCheck = await fetch(guildAPI + verifyData.uuid);
@@ -93,22 +113,23 @@ module.exports = {
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
const GuildMembers = guildCheck.data.members; const GuildMembers = guildCheck.data.members;
const guildRank = GuildMembers.find(member => member.uuid === verifyData.uuid).rank; const guildRank = GuildMembers.find(
(member) => member.uuid === verifyData.uuid
if (guildRank === 'Guild Master' && responseGuildID === hypixelGuildID) { ).rank;
if (guildRank === "Guild Master" && responseGuildID === 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(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(guildStaff, "User used the update command");
await roleManage.add(gm, "User used the update command") await roleManage.add(gm, "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 `Guild Master`", description: "Your rank has been updated to `Guild Master`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -118,24 +139,24 @@ module.exports = {
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 })
} }
}] }
}) ]
});
} }
if (guildRank === 'Manager' && responseGuildID === hypixelGuildID) { if (guildRank === "Manager" && responseGuildID === 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(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(guildStaff, "User used the update command");
await roleManage.add(manager, "User used the update command") await roleManage.add(manager, "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 `Manager`", description: "Your rank has been updated to `Manager`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -145,24 +166,24 @@ module.exports = {
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 })
} }
}] }
}) ]
});
} }
if (guildRank === 'Moderator' && responseGuildID === hypixelGuildID) { if (guildRank === "Moderator" && responseGuildID === 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(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(guildStaff, "User used the update command");
await roleManage.add(moderator, "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({ await interaction.editReply({
embeds: [{ embeds: [
{
description: "Your rank has been updated to `Moderator`", description: "Your rank has been updated to `Moderator`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -172,24 +193,23 @@ module.exports = {
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 })
} }
}] }
}) ]
});
} }
if (guildRank === 'Beast' && responseGuildID === hypixelGuildID) { if (guildRank === "Beast" && responseGuildID === 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(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(beast, "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 `Beast`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -199,24 +219,24 @@ module.exports = {
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 === 'Member' && responseGuildID === hypixelGuildID) { if (guildRank === "Member" && responseGuildID === 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(guildRole, "User used the update command") await roleManage.add(guildRole, "User used the update command");
await roleManage.add(member, "User used the update command") await roleManage.add(member, "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 `Member`.", description: "Your rank has been updated to `Member`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -226,24 +246,24 @@ module.exports = {
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 === 'Trial Member' && responseGuildID === hypixelGuildID) { if (guildRank === "Trial Member" && responseGuildID === 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(guildRole, "User used the update command") await roleManage.add(guildRole, "User used the update command");
await roleManage.add(trialmember, "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 `Trial Member`.", description: "Your rank has been updated to `Trial Member`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
@@ -253,10 +273,10 @@ module.exports = {
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;
}
} }
}; };

View File

@@ -1,66 +1,73 @@
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 { 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, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json'); const {
gm,
manager,
moderator,
beast,
member,
trialmember,
guildRole,
guildStaff,
defaultMember
} = require("../config/roles.json");
module.exports = { module.exports = {
name: 'verify', name: "verify",
description: 'Verify yourself as a member of the server.', description: "Verify yourself as a member of the server.",
type: 'slash', type: "slash",
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 option.setName("ign").setDescription("Your in-game name.")
.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 = await interaction.guild.members.fetch(user1.id); const user = await interaction.guild.members.fetch(user1.id);
const fullUsername = user.user.username + "#" + user.user.discriminator const fullUsername = user.user.username + "#" + user.user.discriminator;
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 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 minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
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.') interaction.editReply("You are 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;
} }
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;
} }
try { try {
await fetch(slothPixel + ign); await fetch(slothPixel + ign);
} catch (err) { } catch (err) {
interaction.editReply('That player doesn\'t exist. [Hypixel]') interaction.editReply("That player doesn't exist. [Hypixel]");
return return;
} }
const userCheck = await fetch(mojang + ign); const userCheck = await fetch(mojang + ign);
@@ -70,8 +77,10 @@ module.exports = {
const head = minotar + ign; const head = minotar + ign;
if (hypixelCheck.data.links.DISCORD !== fullUsername) { if (hypixelCheck.data.links.DISCORD !== fullUsername) {
interaction.editReply('Your Discord tag does not match your in-game tag.') interaction.editReply(
return "Your Discord tag does not match your in-game tag."
);
return;
} }
try { try {
@@ -82,13 +91,18 @@ module.exports = {
} }
if (responseGuildID !== hypixelGuildID) { if (responseGuildID !== hypixelGuildID) {
await user.roles.add(defaultMember, "Verification");
await user.roles.add(defaultMember, "Verification")
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: interaction.guild.name, title: interaction.guild.name,
description: "You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", description:
"You have successfully verified `" +
fullUsername +
"` with the account `" +
hypixelCheck.data.username +
"`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -97,62 +111,71 @@ module.exports = {
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"
} }
}] }
]
}); });
return return;
} }
const guildCheck = await fetch(guildAPI + userUUID); const guildCheck = await fetch(guildAPI + userUUID);
const GuildMembers = await guildCheck.data.members; const GuildMembers = await guildCheck.data.members;
const guildRank = GuildMembers.find(member => member.uuid === hypixelCheck.data.uuid).rank; const guildRank = GuildMembers.find(
(member) => member.uuid === hypixelCheck.data.uuid
).rank;
if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) { if (guildRank === "Guild Master" && responseGuildID === 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" && responseGuildID === hypixelGuildID) { if (guildRank === "Manager" && responseGuildID === 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" && responseGuildID === hypixelGuildID) { if (guildRank === "Moderator" && responseGuildID === 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" && responseGuildID === hypixelGuildID) { if (guildRank === "Beast" && responseGuildID === 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 === "Member" && responseGuildID === hypixelGuildID) { if (guildRank === "Member" && responseGuildID === 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" && responseGuildID === hypixelGuildID) { if (guildRank === "Trial Member" && responseGuildID === 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();
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: interaction.guild.name, title: interaction.guild.name,
description: "You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.", description:
"You have successfully verified `" +
fullUsername +
"` with the account `" +
hypixelCheck.data.username +
"`.",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -161,8 +184,8 @@ module.exports = {
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,44 @@
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); const {
const { color } = require('../config/options.json'); SlashCommandBuilder,
const verify = require('../schemas/verifySchema.js'); PermissionFlagsBits,
const fetch = require('axios'); userMention
} = require("discord.js");
const { color } = require("../config/options.json");
const verify = require("../schemas/verifySchema.js");
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') .setName("user")
.setDescription('The user to get the ign of.') .setDescription("The user to get the ign of.")
.setRequired(true)) .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({
return content: "This user has not verified their account."
});
return;
} }
const userCheck = await fetch(mojang + verifiedUser.uuid); const userCheck = await fetch(mojang + verifiedUser.uuid);
@@ -40,9 +46,11 @@ module.exports = {
const head = minotar + ign; const head = minotar + ign;
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: interaction.guild.name, title: interaction.guild.name,
description: "**User:** " + userMention(user.id) + "\n**IGN:** " + ign, description:
"**User:** " + userMention(user.id) + "\n**IGN:** " + ign,
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -51,8 +59,8 @@ module.exports = {
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 })
} }
}] }
}) ]
});
} }
}; };

View File

@@ -1,19 +1,22 @@
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.CLIENTID; const clientId = process.env.CLIENTID;
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
const contentMenuCommands = fs.readdirSync('./commands-contextmenu').filter(file => file.endsWith('.js')); .readdirSync("./commands")
.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) {
@@ -27,31 +30,34 @@ else if (arg === '--prod') {
} }
// 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
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
); );
console.log(`Successfully reloaded ${data.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
});
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);
} }
})(); })();
} } else if (arg === "--dev") {
else if (arg === '--dev') {
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-contextmenu').filter(file => file.endsWith('.js')); const commandFiles = 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) {
@@ -60,27 +66,28 @@ else if (arg === '--dev') {
} }
// 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
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
); );
console.log(`Successfully reloaded ${data.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
});
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);
} }
})(); })();
} } else if (arg && arg !== "--prod" && arg !== "--dev") {
else if (arg && arg !== '--prod' && arg !== '--dev') { console.log("Invalid argument!");
console.log('Invalid argument!');
} }

View File

@@ -1,27 +1,32 @@
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 { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../../config/reqs.json'); const {
bwfdkr,
bwstars,
bwwins,
duelswins,
swstars
} = require("../../config/reqs.json");
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 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 minotar = "https://minotar.net/helm/"; const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x")); const embedColor = Number(color.replace("#", "0x"));
@@ -31,67 +36,79 @@ module.exports = {
try { try {
await fetch(slothPixel + uuid); await fetch(slothPixel + uuid);
} catch (error) { } catch (error) {
interaction.editReply('That player doesn\'t exist. [Hypixel]') interaction.editReply("That player doesn't exist. [Hypixel]");
return return;
} }
const stats = await fetch(slothPixel + uuid); const stats = await fetch(slothPixel + uuid);
const head = minotar + ign; const head = minotar + ign;
const rank_formatted = stats.data.rank_formatted const rank_formatted = stats.data.rank_formatted;
const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, "") const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, "");
if (rank2 === "") { if (rank2 === "") {
var rank = "" var rank = "";
} else { } else {
var rank = rank2 + " " var rank = rank2 + " ";
} }
try { try {
const guildCheck = await fetch(guildAPI + uuid); const guildCheck = await fetch(guildAPI + uuid);
var guildName = guildCheck.data.name var guildName = guildCheck.data.name;
} catch (error) { } catch (error) {
var guildName = "None" var guildName = "None";
} }
const hsbwstars = stats.data.stats.BedWars.level const hsbwstars = stats.data.stats.BedWars.level;
const hsbwfkdr = stats.data.stats.BedWars.final_k_d const hsbwfkdr = stats.data.stats.BedWars.final_k_d;
const hsbwwins = stats.data.stats.BedWars.wins const hsbwwins = stats.data.stats.BedWars.wins;
const hsswstars = stats.data.stats.SkyWars.level const hsswstars = stats.data.stats.SkyWars.level;
const hsduelswins = stats.data.stats.Duels.general.wins const hsduelswins = stats.data.stats.Duels.general.wins;
if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && hsbwwins < bwwins) { if (hsbwstars < bwstars && hsbwfkdr < bwfdkr && 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) { if (hsduelswins < duelswins) {
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.";
} }
try { try {
const guildCheck = await fetch(guildAPI + userUUID); const guildCheck = await fetch(guildAPI + userUUID);
const tag_formatted = guildCheck.data.tag_formatted const tag_formatted = guildCheck.data.tag_formatted;
const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "") const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "");
var guildTag = " " + guildTag2 var guildTag = " " + guildTag2;
} catch (error) { } catch (error) {
var guildTag = "" var guildTag = "";
} }
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: rank + stats.data.username + guildTag, title: rank + stats.data.username + guildTag,
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + description:
"**Current Guild:** `" + guildName + "`", "**Network Level:** `" +
stats.data.level.toString() +
"`\n" +
"**Current Guild:** `" +
guildName +
"`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -103,25 +120,48 @@ module.exports = {
fields: [ fields: [
{ {
name: bwtitle, name: bwtitle,
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + "`\n" + value:
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + "`\n" + "**➺ Stars:** `" +
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + "`" stats.data.stats.BedWars.level.toString() +
"`\n" +
"**➺ FKDR:** `" +
stats.data.stats.BedWars.final_k_d.toString() +
"`\n" +
"**➺ Wins:** `" +
stats.data.stats.BedWars.wins.toString() +
"`"
}, },
{ {
name: swtitle, name: swtitle,
value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + "`\n" + value:
"**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" + "**➺ Stars:** `" +
"**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`" stats.data.stats.SkyWars.level.toFixed(2).toString() +
"`\n" +
"**➺ KDR:** `" +
stats.data.stats.SkyWars.kill_death_ratio.toString() +
"`\n" +
"**➺ Wins:** `" +
stats.data.stats.SkyWars.wins.toString() +
"`"
}, },
{ {
name: duelstitle, name: duelstitle,
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + "`\n" + value:
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + "**➺ Wins:** `" +
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`" stats.data.stats.Duels.general.wins.toString() +
"`\n" +
"**➺ KDR:** `" +
stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() +
"`\n" +
"**➺ WLR:** `" +
stats.data.stats.Duels.general.win_loss_ratio
.toFixed(2)
.toString() +
"`"
} }
] ]
}] }
]
}) });
} }
}; };

View File

@@ -1,459 +1,570 @@
const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js'); const {
const { color } = require('../../config/options.json'); ButtonBuilder,
const { largeM, smallM, ignM } = require('../../config/limitmessages.json') ButtonStyle,
const { applicationsChannel } = require('../../config/options.json'); ActionRowBuilder,
const { qu1, qu2, qu3, qu4, qu5, qu6, qu7, qu8 } = require('../../config/questions.json'); EmbedBuilder
const { rq1, rq2, rq3, rq4, rq5, rq6, rq7, rq8 } = require('../../config/questions.json'); } = require("discord.js");
const { guildRole } = require('../../config/roles.json') const { color } = require("../../config/options.json");
const mongoose = require('mongoose'); const { largeM, smallM, ignM } = require("../../config/limitmessages.json");
const guildapp = require('../../schemas/guildAppSchema.js'); const { applicationsChannel } = require("../../config/options.json");
const fetch = require('axios'); 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 { guildRole } = require("../../config/roles.json");
const mongoose = require("mongoose");
const guildapp = require("../../schemas/guildAppSchema.js");
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)
if (interaction.customId === 'guildapply') { .roles.cache.map((role) => role.id);
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({
return content: "You are already a member of the guild.",
ephemeral: true
});
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.") .setDescription("You took too long to respond.")
.setColor(embedColor) .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(
.setColor(embedColor) "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 Application', {
description: "Please answer the following questions to apply for the guild.\n" + title: "Guild Application",
description:
"Please answer the following questions to apply for the guild.\n" +
"If you wish to cancel your application, please press type `cancel` at any time.\n" + "If you wish to cancel your application, please press type `cancel` at any time.\n" +
"If you wish to proceed with your application, please type `yes`.\n\n" + "If you wish to proceed with your application, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" + "**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.", "You have a minute to respond to this message.",
color: embedColor, color: embedColor
}] }
}) ]
});
} catch (error) { } catch (error) {
await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true }); await interaction.editReply({
return content: "Please enable your DMs.",
ephemeral: true
});
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**",
description:
qu1 +
"\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({ 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" + {
description:
"That is not a valid Minecraft username.\n" +
"Application cancelled.", "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**",
description:
qu2 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n" +
"`(8 characters max)`",
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 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.", description: "Max character limit is 8.",
color: embedColor 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**",
description:
qu3 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
smallM +
"`",
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 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.", description: "Max character limit is 128.",
color: embedColor 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:
qu4 +
"\n\nPlease type your answer below or type `cancel` to cancel your application." +
" `(We expect a longer answer.)`\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({ 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.", description: "Max character limit is 256.",
color: embedColor 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**",
description:
qu5 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
smallM +
"`",
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 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.", description: "Max character limit is 128.",
color: embedColor 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**",
description:
qu6 +
"\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 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.", description: "Max character limit is 256.",
color: embedColor 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**",
description:
qu7 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" +
smallM +
"`",
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 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.", description: "Max character limit is 128.",
color: embedColor 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**",
description:
qu8 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n" +
"`(64 characters max)`",
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 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.", description: "Max character limit is 64.",
color: embedColor 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`", {
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 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", {
title:
user.username + "#" + user.discriminator + " - Guild Application",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: user.avatarURL() url: user.avatarURL()
@@ -496,7 +607,8 @@ module.exports = {
iconURL: guild.iconURL(), iconURL: guild.iconURL(),
text: "ID: " + user.id text: "ID: " + user.id
} }
}], }
],
components: [ components: [
new ActionRowBuilder().addComponents( new ActionRowBuilder().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -514,7 +626,6 @@ module.exports = {
) )
] ]
}); });
} }
} }
} };

View File

@@ -1,15 +1,14 @@
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 guildapp = require('../../schemas/guildAppSchema.js'); const guildapp = require("../../schemas/guildAppSchema.js");
const { waitingList } = require('../../config/roles.json'); const { waitingList } = 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;
@@ -18,10 +17,11 @@ 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 message.edit({ await message.edit({
components: [ components: [
@@ -46,17 +46,20 @@ module.exports = {
}); });
await applicant.send({ await applicant.send({
embeds: [{ embeds: [
{
description: `Your application for the Illegitimate guild has been accepted.`, description: `Your application for the Illegitimate guild has been accepted.`,
color: embedColor color: embedColor
}] }
]
}); });
await applicant.roles.add(waitingList); await applicant.roles.add(waitingList);
await guildapp.findOneAndDelete({ userID: applicantId }); await guildapp.findOneAndDelete({ userID: applicantId });
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: applicantUsername + " - Guild Application", title: applicantUsername + " - Guild Application",
description: "Application has been accepted by <@" + user.id + ">.", description: "Application has been accepted by <@" + user.id + ">.",
color: embedColor, color: embedColor,
@@ -67,7 +70,8 @@ module.exports = {
iconURL: guild.iconURL(), iconURL: guild.iconURL(),
text: "ID: " + applicant.id text: "ID: " + applicant.id
} }
}] }
]
}); });
} }
}; };

View File

@@ -1,13 +1,17 @@
const { ModalBuilder, ActionRowBuilder, TextInputBuilder, TextInputStyle } = require('discord.js'); const {
const { color } = require('../../config/options.json'); ModalBuilder,
ActionRowBuilder,
TextInputBuilder,
TextInputStyle
} = require("discord.js");
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 +19,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,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,19 @@ 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.`, description: `Your application for the Illegitimate staff team has been accepted.`,
color: embedColor color: embedColor
}] }
]
}); });
await message.edit({ await message.edit({
@@ -48,7 +50,8 @@ module.exports = {
await staffapp.findOneAndDelete({ userId: applicantId }); await staffapp.findOneAndDelete({ userId: applicantId });
await interaction.reply({ await interaction.reply({
embeds: [{ embeds: [
{
title: applicantUsername + " - Staff Application.", title: applicantUsername + " - Staff Application.",
description: "Application accepted by <@" + user.id + ">.", description: "Application accepted by <@" + user.id + ">.",
color: embedColor, color: embedColor,
@@ -59,8 +62,8 @@ module.exports = {
iconurl: guild.iconURL(), iconurl: guild.iconURL(),
text: "ID: " + applicantId text: "ID: " + applicantId
} }
}]
});
} }
} ]
});
}
};

View File

@@ -1,25 +1,29 @@
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,387 +1,474 @@
const { ButtonBuilder, ButtonStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js'); const {
const { color } = require('../../config/options.json'); ButtonBuilder,
const { largeM, smallM, ignM } = require('../../config/limitmessages.json') ButtonStyle,
const { staffApplicationsChannel } = require('../../config/options.json'); ActionRowBuilder,
const { sq1, sq2, sq3, sq4, sq5, sq6 } = require('../../config/questions.json'); EmbedBuilder
const { rsq1, rsq2, rsq3, rsq4, rsq5, rsq6 } = require('../../config/questions.json'); } = require("discord.js");
const { guildRole, guildStaff } = require('../../config/roles.json') const { color } = require("../../config/options.json");
const mongoose = require('mongoose'); const { largeM, smallM, ignM } = require("../../config/limitmessages.json");
const staffapp = require('../../schemas/staffAppSchema.js'); const { staffApplicationsChannel } = require("../../config/options.json");
const fetch = require('axios'); const { sq1, sq2, sq3, sq4, sq5, sq6 } = require("../../config/questions.json");
const {
rsq1,
rsq2,
rsq3,
rsq4,
rsq5,
rsq6
} = require("../../config/questions.json");
const { guildRole, guildStaff } = require("../../config/roles.json");
const mongoose = require("mongoose");
const staffapp = require("../../schemas/staffAppSchema.js");
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({
return content: "You are already a staff member.",
ephemeral: true
});
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.") .setDescription("You took too long to respond.")
.setColor(embedColor) .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(
.setColor(embedColor) "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: 'Staff Application', {
description: "Please answer the following questions to apply for staff.\n" + title: "Staff Application",
description:
"Please answer the following questions to apply for staff.\n" +
"If you wish to cancel your application, please press type `cancel` at any time.\n" + "If you wish to cancel your application, please press type `cancel` at any time.\n" +
"If you wish to proceed with your application, please type `yes`.\n\n" + "If you wish to proceed with your application, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" + "**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.", "You have a minute to respond to this message.",
color: embedColor, color: embedColor
}] }
}) ]
});
} catch (error) { } catch (error) {
await interaction.editReply({ content: "Please enable your DMs.", ephemeral: true }); await interaction.editReply({
return content: "Please enable your DMs.",
ephemeral: true
});
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: sq1 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + ignM + "`", 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({ 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" + {
description:
"That is not a valid Minecraft username.\n" +
"Application cancelled.", "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: sq2 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n" + "`(64 characters max)`", title: "**Question 2**",
description:
sq2 +
"\n\nPlease type your answer below or type `cancel` to cancel your application.\n" +
"`(64 characters max)`",
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 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 > 64) { if (answer2.first().content > 64) {
await user.send({ await user.send({
embeds: [{ embeds: [
{
description: "Max character limit is 64.", description: "Max character limit is 64.",
color: embedColor 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: sq3 + "\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 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 > 256) { if (answer3.first().content > 256) {
await user.send({ await user.send({
embeds: [{ embeds: [
{
description: "Max character limit is 256.", description: "Max character limit is 256.",
color: embedColor 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: sq4 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", title: "**Question 4**",
description:
sq4 +
"\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({ 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.", description: "Max character limit is 256.",
color: embedColor 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: sq5 + "\n\nPlease type your answer below or type `cancel` to cancel your application.\n`" + largeM + "`", title: "**Question 5**",
description:
sq5 +
"\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 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 > 256) { if (answer5.first().content > 256) {
await user.send({ await user.send({
embeds: [{ embeds: [
{
description: "Max character limit is 256.", description: "Max character limit is 256.",
color: embedColor 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: sq6 + "\n\nPlease type your answer below or type `cancel` to cancel your application." + title: "**Question 6**",
"`(We expect a longer answer here)`\n`" + largeM + "`", 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, 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 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.", description: "Max character limit is 256.",
color: embedColor 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;
await user.send({ await user.send({
embeds: [{ 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()
@@ -411,13 +498,13 @@ module.exports = {
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: [ components: [
new ActionRowBuilder().addComponents( new ActionRowBuilder().addComponents(
new ButtonBuilder() new ButtonBuilder()
@@ -430,8 +517,7 @@ module.exports = {
.setStyle(ButtonStyle.Danger) .setStyle(ButtonStyle.Danger)
) )
] ]
} });
);
} }
} }
} };

View File

@@ -1,17 +1,22 @@
const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const {
const { color } = require('../../config/options.json'); InteractionType,
const mongoose = require('mongoose'); EmbedBuilder,
const guildapp = require('../../schemas/guildAppSchema.js'); ActionRowBuilder,
const fs = require('fs'); ButtonBuilder,
const path = require('path'); ButtonStyle
} = require("discord.js");
const { color } = require("../../config/options.json");
const mongoose = require("mongoose");
const guildapp = require("../../schemas/guildAppSchema.js");
const fs = require("fs");
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 +29,8 @@ 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}`);
@@ -51,8 +57,12 @@ module.exports = {
}); });
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,10 +70,16 @@ module.exports = {
await guildapp.findOneAndDelete({ userID: applicantId }); await guildapp.findOneAndDelete({ userID: applicantId });
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: "Application Denied", title: "Application Denied",
description: "The application has been denied by <@" + interaction.user.id + ">.\n" + description:
"**Reason:** `" + reason + "`", "The application has been denied by <@" +
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: applicant.avatarURL() url: applicant.avatarURL()
@@ -72,7 +88,8 @@ module.exports = {
iconURL: guild.iconURL(), iconURL: guild.iconURL(),
text: "ID: " + applicant.id text: "ID: " + applicant.id
} }
}], }
]
}); });
} }
} };

View File

@@ -1,17 +1,22 @@
const { InteractionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const {
const { color } = require('../../config/options.json'); InteractionType,
const mongoose = require('mongoose'); EmbedBuilder,
const staffapp = require('../../schemas/staffAppSchema.js'); ActionRowBuilder,
const fs = require('fs'); ButtonBuilder,
const path = require('path'); ButtonStyle
} = require("discord.js");
const { color } = require("../../config/options.json");
const mongoose = require("mongoose");
const staffapp = require("../../schemas/staffAppSchema.js");
const fs = require("fs");
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 +24,15 @@ 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: [
@@ -39,14 +46,18 @@ module.exports = {
.setCustomId("staffapplicationdeny") .setCustomId("staffapplicationdeny")
.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,10 +65,16 @@ module.exports = {
await staffapp.findOneAndDelete({ userID: applicantId }); await staffapp.findOneAndDelete({ userID: applicantId });
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [
{
title: "Application Denied", title: "Application Denied",
description: "The application has been denied by <@" + interaction.user.id + ">.\n" + description:
"**Reason:** `" + reason + "`", "The application has been denied by <@" +
interaction.user.id +
">.\n" +
"**Reason:** `" +
reason +
"`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: applicant.avatarURL() url: applicant.avatarURL()
@@ -66,7 +83,8 @@ module.exports = {
iconURL: guild.iconURL(), iconURL: guild.iconURL(),
text: "ID: " + applicant.id text: "ID: " + applicant.id
} }
}],
});;
} }
} ]
});
}
};

140
index.js
View File

@@ -1,10 +1,17 @@
const { Client, GatewayIntentBits, Partials, ActivityType, Events, Collection } = require('discord.js'); const {
const env = require('dotenv').config(); Client,
GatewayIntentBits,
Partials,
ActivityType,
Events,
Collection
} = require("discord.js");
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: [
@@ -27,40 +34,44 @@ 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.`
);
} }
} }
//! commands testing //! commands testing
const cmdTestPath = path.join(__dirname, 'commands-testing'); const cmdTestPath = path.join(__dirname, "commands-testing");
const cmdTestFiles = fs.readdirSync(cmdTestPath).filter(file => file.endsWith('.js')); const cmdTestFiles = 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.`
);
} }
} }
//! command handler //! command handler
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async (interaction) => {
if(!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName); const command = interaction.client.commands.get(interaction.commandName);
@@ -73,29 +84,35 @@ client.on(Events.InteractionCreate, async interaction => {
await command.execute(interaction); await command.execute(interaction);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }) await interaction.reply({
content: "There was an error while executing this command!",
ephemeral: true
});
} }
}); });
//! commands //! commands
const contextMenuPath = path.join(__dirname, 'commands-contextmenu'); const contextMenuPath = path.join(__dirname, "commands-contextmenu");
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith('.js')); const contextMenuFiles = 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.`
);
} }
} }
//! context menu command handler //! context menu command handler
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async (interaction) => {
if(!interaction.isContextMenuCommand()) return; if (!interaction.isContextMenuCommand()) return;
const command = interaction.client.commands.get(interaction.commandName); const command = interaction.client.commands.get(interaction.commandName);
@@ -108,29 +125,33 @@ client.on(Events.InteractionCreate, async interaction => {
await command.execute(interaction); await command.execute(interaction);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }) await interaction.reply({
content: "There was an error while executing this command!",
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.`
);
} }
} }
//! button event handler //! button event handler
client.on(Events.InteractionCreate, async event => { client.on(Events.InteractionCreate, async (event) => {
if(!event.isButton()) return; if (!event.isButton()) return;
const event2 = event.client.events.get(event.customId); const event2 = event.client.events.get(event.customId);
@@ -143,23 +164,29 @@ client.on(Events.InteractionCreate, async event => {
await event2.execute(event); await event2.execute(event);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
await event.reply({ content: 'There was an error while executing this event!', ephemeral: true }) await event.reply({
content: "There was an error while executing this event!",
ephemeral: true
});
} }
}) });
//! modals //! modals
const modalPath = path.join(__dirname, 'events', 'modals'); const modalPath = path.join(__dirname, "events", "modals");
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith('.js')); const modalFiles = 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.ClientReady, () => { client.on(Events.ClientReady, () => {
@@ -167,24 +194,27 @@ client.on(Events.ClientReady, () => {
}); });
// message events // message events
const msgPath = path.join(__dirname, 'events', 'messages'); const msgPath = path.join(__dirname, "events", "messages");
const msgFiles = fs.readdirSync(msgPath).filter(file => file.endsWith('.js')); const msgFiles = fs.readdirSync(msgPath).filter((file) => file.endsWith(".js"));
for (const file of msgFiles) { for (const file of msgFiles) {
const filePath = path.join(msgPath, file); const filePath = path.join(msgPath, file);
const msg = require(filePath); const msg = require(filePath);
if ('name' in msg && 'execute' in msg && msg.type === 'message') { if ("name" in msg && "execute" in msg && msg.type === "message") {
client.on(Events.MessageCreate, msg.execute); client.on(Events.MessageCreate, msg.execute);
} else { } else {
console.log(`[WARNING] The message at ${filePath} is missing a required "name", "execute" or "type" property.`); console.log(
`[WARNING] The message at ${filePath} is missing a required "name", "execute" or "type" property.`
);
} }
} }
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 = [
{ {
@@ -218,16 +248,16 @@ client.on(Events.ClientReady, () => {
]; ];
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.on(Events.ClientReady, () => {
client.user.setStatus('dnd'); 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");
}) });

View File

@@ -1,9 +1,9 @@
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,
userID: { type: String, required: true }, userID: { type: String, required: true },
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,9 +1,9 @@
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,
userID: { type: String, required: true }, userID: { type: String, required: true },
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,9 +1,9 @@
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,
userID: { type: String, required: true }, userID: { type: String, required: true },
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,10 +1,10 @@
const fetch = require("axios"); const fetch = require("axios");
async function getuuid(ign) { async function getuuid(ign) {
const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/" const mojangAPI = "https://api.mojang.com/users/profiles/minecraft/";
try { try {
const user = await fetch(mojangAPI + ign) const user = await fetch(mojangAPI + ign);
return user.data.id; return user.data.id;
} catch (error) { } catch (error) {
return null; return null;
@@ -15,12 +15,12 @@ async function getplayer(uuid) {
const slothPixel = "https://api.slothpixel.me/api/players/"; const slothPixel = "https://api.slothpixel.me/api/players/";
try { try {
const player = await fetch(slothPixel + uuid) const player = await fetch(slothPixel + uuid);
return player return player;
} catch (error) { } catch (error) {
return null; return null;
} }
} }
module.exports = getuuid module.exports = getuuid;
module.exports = getplayer module.exports = getplayer;

View File

@@ -1,12 +1,11 @@
module.exports = { module.exports = {
name: 'limbo', name: "limbo",
description: 'Sends bot to limbo.', description: "Sends bot to limbo.",
type: 'spawn', type: "spawn",
async execute() { async execute() {
const bot = require ('../../index.js'); const bot = require("../../index.js");
bot.chat("\u00a7")
bot.chat("\u00a7");
} }
}; };

View File

@@ -1,13 +1,12 @@
const client = require('../../index.js'); const client = require("../../index.js");
module.exports = { module.exports = {
name: 'Guild chat relay', name: "Guild chat relay",
description: 'Sends a message to the chat.', description: "Sends a message to the chat.",
type: 'message', type: "message",
async execute(jsonMsg) { async execute(jsonMsg) {
const gcchannel = "1092569207918575687";
const gcchannel = "1092569207918575687"
const msg = jsonMsg.getText(); const msg = jsonMsg.getText();
const annoyingMessages = [ const annoyingMessages = [
@@ -15,7 +14,7 @@ module.exports = {
"REMINDER: Your Online Status is currently set to Appear Offline", "REMINDER: Your Online Status is currently set to Appear Offline",
"You have 1 unclaimed achievement reward!", "You have 1 unclaimed achievement reward!",
"Click here to view it!" "Click here to view it!"
] ];
if (annoyingMessages.includes(msg)) return; if (annoyingMessages.includes(msg)) return;
@@ -24,6 +23,5 @@ module.exports = {
const channel = client.guild.channels.cache.get(gcchannel); const channel = client.guild.channels.cache.get(gcchannel);
channel.send(msg); channel.send(msg);
} }
}; };

View File

@@ -1,10 +1,10 @@
module.exports = { module.exports = {
name: 'login', name: "login",
description: 'Logs the bot in.', description: "Logs the bot in.",
type: 'login', type: "login",
async execute() { async execute() {
const bot = require ('../../index.js'); const bot = require("../../index.js");
console.log('Logged in as ' + bot.username + '!') console.log("Logged in as " + bot.username + "!");
} }
} };