Removing unneccesarry files and dep.

This commit is contained in:
2023-06-13 12:40:29 +02:00
parent e7d43697b3
commit 48ffa5bb97
7 changed files with 312 additions and 1952 deletions

View File

@@ -1,165 +1,188 @@
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require("discord.js"); const {SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits} =
const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require("../config/reqs.json"); require("discord.js");
const {bwfdkr, bwstars, bwwins, duelswins, swstars} =
require("../config/reqs.json");
const env = require("dotenv").config(); 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.setName("ign")
option .setDescription("The player's IGN.")
.setName("ign") .setRequired(true))
.setDescription("The player's IGN.") .setDMPermission(false),
.setRequired(true))
.setDMPermission(false),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply({}); await interaction.deferReply({});
const ign = interaction.options.getString("ign"); const ign = interaction.options.getString("ign");
const mojang = "https://api.mojang.com/users/profiles/minecraft/"; const mojang = "https://api.mojang.com/users/profiles/minecraft/";
const 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;
} }
try { try {
await fetch(mojang + ign); await fetch(mojang + ign);
} catch (error) { } catch (error) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds : [
description: "That player doesn't exist.", {description : "That player doesn't exist.", color : embedColor}
color: embedColor ]
}] });
}); return;
return; }
}
const userCheck = await fetch(mojang + ign); const userCheck = await fetch(mojang + ign);
const uuid = userCheck.data.id; const uuid = userCheck.data.id;
try { try {
await fetch(slothPixel + uuid); await fetch(slothPixel + uuid);
} catch (error) { } catch (error) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds : [ {
description: "That player hasn't played Hypixel before.", description : "That player hasn't played Hypixel before.",
color: embedColor color : embedColor
}] } ]
}); });
return; return;
} }
const stats = await fetch(slothPixel + uuid); const stats = await fetch(slothPixel + uuid);
const head = minotar + ign; const head = minotar + ign;
if (!stats.data.uuid) { if (!stats.data.uuid) {
interaction.editReply({ interaction.editReply({
embeds: [{ embeds : [ {
description: "That player hasn't played Hypixel before.", description : "That player hasn't played Hypixel before.",
color: embedColor color : embedColor
}] } ]
}); });
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 === "") {
var rank = "";
} else {
var rank = rank2 + " ";
}
try {
const guildCheck = await fetch(guildAPI + uuid);
var guildName = guildCheck.data.name;
} catch (error) {
var guildName = "None";
}
const hsbwstars = stats.data.stats.BedWars.level; if (rank2 === "") {
const hsbwfkdr = stats.data.stats.BedWars.final_k_d; var rank = "";
const hsbwwins = stats.data.stats.BedWars.wins; } else {
const hsswstars = stats.data.stats.SkyWars.level; var rank = rank2 + " ";
const hsduelswins = stats.data.stats.Duels.general.wins; }
if (hsbwstars < bwstars || hsbwfkdr < bwfdkr || hsbwwins < bwwins) { try {
var bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."; const guildCheck = await fetch(guildAPI + uuid);
} else { var guildName = guildCheck.data.name;
var bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements."; } catch (error) {
} var guildName = "None";
}
if (hsswstars < swstars) { const hsbwstars = stats.data.stats.BedWars.level;
var swtitle = "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements."; const hsbwfkdr = stats.data.stats.BedWars.final_k_d;
} else { const hsbwwins = stats.data.stats.BedWars.wins;
var swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements."; const hsswstars = stats.data.stats.SkyWars.level;
} const hsduelswins = stats.data.stats.Duels.general.wins;
if (hsduelswins < duelswins) { if (hsbwstars < bwstars || hsbwfkdr < bwfdkr || hsbwwins < bwwins) {
var duelstitle = "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements."; var bwtitle =
} else { "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements.";
var duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."; } else {
} var bwtitle =
"<a:check_a:1087808632172847134> This player meets the BedWars requirements.";
}
try { if (hsswstars < swstars) {
const guildCheck = await fetch(guildAPI + uuid); var swtitle =
const tag_formatted = guildCheck.data.tag_formatted; "<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements.";
const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, ""); } else {
var guildTag = " " + guildTag2; var swtitle =
} catch (error) { "<a:check_a:1087808632172847134> This player meets the SkyWars requirements.";
var guildTag = ""; }
}
await interaction.editReply({ if (hsduelswins < duelswins) {
embeds: [ var duelstitle =
{ "<a:cross_a:1087808606897983539> This player does not meet the Duels requirements.";
title: rank + stats.data.username + guildTag, } else {
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + var duelstitle =
"**Current Guild:** `" + guildName + "`", "<a:check_a:1087808632172847134> This player meets the Duels requirements.";
color: embedColor, }
thumbnail: {
url: head try {
}, const guildCheck = await fetch(guildAPI + uuid);
footer: { const tag_formatted = guildCheck.data.tag_formatted;
text: interaction.guild.name + " | Developed by @Taken#0002", const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "");
icon_url: interaction.guild.iconURL() var guildTag = " " + guildTag2;
}, } catch (error) {
fields: [ var guildTag = "";
{ }
name: bwtitle,
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + " / " + bwstars.toString() + "`\n" + await interaction.editReply({
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + " / " + bwfdkr.toString() + "`\n" + embeds : [ {
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + " / " + bwwins.toString() + "`" title : rank + stats.data.username + guildTag,
}, description : "**Network Level:** `" +
{ stats.data.level.toString() + "`\n" +
name: swtitle, "**Current Guild:** `" + guildName + "`",
value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + " / " + swstars.toString() + "`\n" + color : embedColor,
"**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" + thumbnail : {url : head},
"**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`" footer : {
}, text : interaction.guild.name + " | Developed by @Taken#0002",
{ icon_url : interaction.guild.iconURL()
name: duelstitle, },
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + " / " + duelswins.toString() + "`\n" + fields : [
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + {
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`" name : bwtitle,
} value : "**➺ Stars:** `" +
] 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,
value :
"**➺ Stars:** `" +
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,
value : "**➺ Wins:** `" +
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() +
"`"
}
]
} ]
});
}
}; };

300
index.js
View File

@@ -1,27 +1,23 @@
const { Client, GatewayIntentBits, Partials, ActivityType, Events, Collection } = require('discord.js'); const {Client, GatewayIntentBits, Partials, ActivityType, Events, Collection} =
const { botLogChannel, color } = require('./config/options.json'); require('discord.js');
const {botLogChannel, color} = require('./config/options.json');
const env = require('dotenv').config(); const env = require('dotenv').config();
const token = process.env.TOKEN; const token = process.env.TOKEN;
const mongoURI = process.env.MONGOURI; const mongoURI = process.env.MONGOURI;
const { connect } = require('mongoose'); const {connect} = require('mongoose');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const { parseArgs } = require('util'); const {parseArgs} = require('util');
const client = new Client({ const client = new Client({
intents: [ intents : [
GatewayIntentBits.Guilds, GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers, GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers, GatewayIntentBits.DirectMessages
GatewayIntentBits.MessageContent, ],
GatewayIntentBits.DirectMessages partials : [
], Partials.GuildMember, Partials.User, Partials.Message, Partials.Channel
partials: [ ]
Partials.GuildMember,
Partials.User,
Partials.Message,
Partials.Channel
]
}); });
client.commands = new Collection(); client.commands = new Collection();
@@ -34,84 +30,97 @@ 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);
if (!command) { const command = interaction.client.commands.get(interaction.commandName);
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try { if (!command) {
await command.execute(interaction); console.error(`No command matching ${interaction.commandName} was found.`);
} catch (error) { return;
console.error(error); }
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true })
} try {
await command.execute(interaction);
} catch (error) {
console.error(error);
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);
if (!command) { const command = interaction.client.commands.get(interaction.commandName);
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try { if (!command) {
await command.execute(interaction); console.error(`No command matching ${interaction.commandName} was found.`);
} catch (error) { return;
console.error(error); }
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true })
} try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({
content : 'There was an error while executing this command!',
ephemeral : true
})
}
}); });
//! button events //! button events
@@ -119,125 +128,104 @@ 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 btn = require(filePath);
if ('name' in btn && 'execute' in btn && btn.type === 'button') { const filePath = path.join(btnPath, file);
client.events.set(btn.name, btn); const btn = require(filePath);
} else {
console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`); if ('name' in btn && 'execute' in btn && btn.type === 'button') {
} client.events.set(btn.name, btn);
} else {
console.log(`[WARNING] The button at ${
filePath} is missing a required "name", "execute" or "type" property.`);
}
} }
//! 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);
if (!event2) { if (!event2) {
console.error(`No event matching ${event.customId} was found.`); console.error(`No event matching ${event.customId} was found.`);
return; return;
} }
try { try {
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.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async interaction => {
if (interaction.isCommand()) {
if (interaction.isCommand()) { console.log(interaction.user.username + "#" +
console.log(interaction.user.username + "#" + interaction.user.discriminator + " ran " + interaction.commandName); interaction.user.discriminator + " ran " +
} else if (interaction.isButton()) { interaction.commandName);
console.log(interaction.user.username + "#" + interaction.user.discriminator + " clicked " + interaction.customId); } else if (interaction.isButton()) {
} console.log(interaction.user.username + "#" +
interaction.user.discriminator + " clicked " +
interaction.customId);
}
}); });
client.on(Events.ClientReady, () => { client.on(Events.ClientReady, () => {
console.log("Logged in as " + client.user.tag + "!"); console.log("Logged in as " + client.user.tag + "!");
const channel = client.channels.cache.get(botLogChannel); const channel = client.channels.cache.get(botLogChannel);
const embedColor = Number(color.replace('#', '0x')) const embedColor = Number(color.replace('#', '0x'))
if (!channel) { if (!channel) {
return; return;
} }
channel.send({ channel.send(
embeds: [{ {embeds : [ {description : `Bot is online!`, color : embedColor} ]});
description: `Bot is online!`,
color: embedColor
}]
});
}); });
client.on(Events.ClientReady, () => { client.on(Events.ClientReady, () => {
client.user.setActivity(
{name : "over the Illegitimate Server", type : ActivityType.Watching});
client.user.setActivity({ name: "over the Illegitimate Server", type: ActivityType.Watching }); const activities = [
{name : "with Jone the idiot", type : ActivityType.Playing},
const activities = [ {name : "with Martina the bot", type : ActivityType.Playing},
{ {name : "urCryhard steal finals again", type : ActivityType.Watching},
name: "with Jone the idiot", {name : "with Perlcence the AI", type : ActivityType.Playing},
type: ActivityType.Playing {name : "my creator Taken", type : ActivityType.Watching},
}, {name : "with ur mom in my bed", type : ActivityType.Playing},
{ {name : "over the Illegitimate Server", type : ActivityType.Watching}
name: "with Martina the bot", ];
type: ActivityType.Playing
},
{
name: "urCryhard steal finals again",
type: ActivityType.Watching
},
{
name: "with Perlcence the AI",
type: ActivityType.Playing
},
{
name: "my creator Taken",
type: ActivityType.Watching
},
{
name: "with ur mom in my bed",
type: ActivityType.Playing
},
{
name: "over the Illegitimate Server",
type: ActivityType.Watching
}
];
let i = 0;
setInterval(() =>
client.user.setActivity(activities[i++ % activities.length]), 1000 * 60 * 30
)
let i = 0;
setInterval(() =>
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');
})

1600
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,8 +14,6 @@
"axios": "^1.3.4", "axios": "^1.3.4",
"discord.js": "^14.8.0", "discord.js": "^14.8.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"mineflayer": "^4.8.1", "mongoose": "^7.0.1"
"mongoose": "^7.0.1",
"prismarine-viewer": "^1.24.0"
} }
} }

View File

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

View File

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

View File

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