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

294
index.js
View File

@@ -1,27 +1,23 @@
const { Client, GatewayIntentBits, Partials, ActivityType, Events, Collection } = require('discord.js');
const { botLogChannel, color } = require('./config/options.json');
const {Client, GatewayIntentBits, Partials, ActivityType, Events, Collection} =
require('discord.js');
const {botLogChannel, color} = require('./config/options.json');
const env = require('dotenv').config();
const token = process.env.TOKEN;
const mongoURI = process.env.MONGOURI;
const { connect } = require('mongoose');
const {connect} = require('mongoose');
const path = require('path');
const fs = require('fs');
const { parseArgs } = require('util');
const {parseArgs} = require('util');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.GuildMember,
Partials.User,
Partials.Message,
Partials.Channel
]
intents : [
GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers, GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages
],
partials : [
Partials.GuildMember, Partials.User, Partials.Message, Partials.Channel
]
});
client.commands = new Collection();
@@ -34,84 +30,97 @@ const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith('.js'));
for (const file of cmdFiles) {
const filePath = path.join(cmdPath, file);
const cmd = require(filePath);
const filePath = path.join(cmdPath, file);
const cmd = require(filePath);
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') {
client.commands.set(cmd.data.name, cmd);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
}
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') {
client.commands.set(cmd.data.name, cmd);
} else {
console.log(`[WARNING] The command at ${
filePath} is missing a required "data", "execute" or "type" property.`);
}
}
//! commands testing
const cmdTestPath = path.join(__dirname, 'commands-testing');
const cmdTestFiles = fs.readdirSync(cmdTestPath).filter(file => file.endsWith('.js'));
const cmdTestFiles =
fs.readdirSync(cmdTestPath).filter(file => file.endsWith('.js'));
for (const file of cmdTestFiles) {
const filePath = path.join(cmdTestPath, file);
const cmd = require(filePath);
const filePath = path.join(cmdTestPath, file);
const cmd = require(filePath);
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') {
client.commands.set(cmd.data.name, cmd);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
}
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') {
client.commands.set(cmd.data.name, cmd);
} else {
console.log(`[WARNING] The command at ${
filePath} is missing a required "data", "execute" or "type" property.`);
}
}
//! command handler
client.on(Events.InteractionCreate, async interaction => {
if(!interaction.isChatInputCommand()) return;
if (!interaction.isChatInputCommand())
return;
const command = interaction.client.commands.get(interaction.commandName);
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true })
}
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
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) {
const filePath = path.join(contextMenuPath, file);
const cmd = require(filePath);
const filePath = path.join(contextMenuPath, file);
const cmd = require(filePath);
if ('data' in cmd && 'execute' in cmd && cmd.type === 'contextmenu') {
client.commands.set(cmd.data.name, cmd);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
}
if ('data' in cmd && 'execute' in cmd && cmd.type === 'contextmenu') {
client.commands.set(cmd.data.name, cmd);
} else {
console.log(`[WARNING] The command at ${
filePath} is missing a required "data", "execute" or "type" property.`);
}
}
//! context menu command handler
client.on(Events.InteractionCreate, async interaction => {
if(!interaction.isContextMenuCommand()) return;
if (!interaction.isContextMenuCommand())
return;
const command = interaction.client.commands.get(interaction.commandName);
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true })
}
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
@@ -120,124 +129,103 @@ const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith('.js'));
for (const file of btnFiles) {
const filePath = path.join(btnPath, file);
const btn = require(filePath);
const filePath = path.join(btnPath, file);
const btn = require(filePath);
if ('name' in btn && 'execute' in btn && btn.type === 'button') {
client.events.set(btn.name, btn);
} else {
console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`);
}
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
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) {
console.error(`No event matching ${event.customId} was found.`);
return;
}
if (!event2) {
console.error(`No event matching ${event.customId} was found.`);
return;
}
try {
await event2.execute(event);
} catch (error) {
console.error(error);
await event.reply({ content: 'There was an error while executing this event!', ephemeral: true })
}
try {
await event2.execute(event);
} catch (error) {
console.error(error);
await event.reply({
content : 'There was an error while executing this event!',
ephemeral : true
})
}
})
//! 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) {
const filePath = path.join(modalPath, file);
const modal = require (filePath);
const filePath = path.join(modalPath, file);
const modal = require(filePath);
if ('name' in modal && 'execute' in modal && modal.type === 'modal') {
client.on(Events.InteractionCreate, modal.execute);
} else {
console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`);
}
if ('name' in modal && 'execute' in modal && modal.type === 'modal') {
client.on(Events.InteractionCreate, modal.execute);
} else {
console.log(`[WARNING] The modal at ${
filePath} is missing a required "name", "execute" or "type" property.`);
}
}
client.on(Events.InteractionCreate, async interaction => {
if (interaction.isCommand()) {
console.log(interaction.user.username + "#" + interaction.user.discriminator + " ran " + interaction.commandName);
} else if (interaction.isButton()) {
console.log(interaction.user.username + "#" + interaction.user.discriminator + " clicked " + interaction.customId);
}
if (interaction.isCommand()) {
console.log(interaction.user.username + "#" +
interaction.user.discriminator + " ran " +
interaction.commandName);
} else if (interaction.isButton()) {
console.log(interaction.user.username + "#" +
interaction.user.discriminator + " clicked " +
interaction.customId);
}
});
client.on(Events.ClientReady, () => {
console.log("Logged in as " + client.user.tag + "!");
const channel = client.channels.cache.get(botLogChannel);
const embedColor = Number(color.replace('#', '0x'))
console.log("Logged in as " + client.user.tag + "!");
const channel = client.channels.cache.get(botLogChannel);
const embedColor = Number(color.replace('#', '0x'))
if (!channel) {
return;
}
if (!channel) {
return;
}
channel.send({
embeds: [{
description: `Bot is online!`,
color: embedColor
}]
});
channel.send(
{embeds : [ {description : `Bot is online!`, color : embedColor} ]});
});
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
},
{
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
)
const activities = [
{name : "with Jone the idiot", type : ActivityType.Playing},
{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)
});
client.on(Events.ClientReady, () => {
client.user.setStatus('dnd');
});
client.on(Events.ClientReady, () => { client.user.setStatus('dnd'); });
client.login(token);
connect(mongoURI, {}).then(() => {
console.log('Connected to MongoDB');
})
connect(mongoURI, {}).then(() => { 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",
"discord.js": "^14.8.0",
"dotenv": "^16.0.3",
"mineflayer": "^4.8.1",
"mongoose": "^7.0.1",
"prismarine-viewer": "^1.24.0"
"mongoose": "^7.0.1"
}
}

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 + '!')
}
}