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,21 +1,21 @@
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
.setName("ign")
.setDescription("The player's IGN.") .setDescription("The player's IGN.")
.setRequired(true)) .setRequired(true))
.setDMPermission(false), .setDMPermission(false),
@@ -39,10 +39,9 @@ module.exports = {
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;
} }
@@ -54,10 +53,10 @@ module.exports = {
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;
} }
@@ -67,10 +66,10 @@ module.exports = {
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;
} }
@@ -98,21 +97,27 @@ module.exports = {
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 {
@@ -125,41 +130,59 @@ module.exports = {
} }
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds : [ {
{ title : rank + stats.data.username + guildTag,
title: rank + stats.data.username + guildTag, description : "**Network Level:** `" +
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + stats.data.level.toString() + "`\n" +
"**Current Guild:** `" + guildName + "`", "**Current Guild:** `" + guildName + "`",
color: embedColor, color : embedColor,
thumbnail: { thumbnail : {url : head},
url: head footer : {
text : interaction.guild.name + " | Developed by @Taken#0002",
icon_url : interaction.guild.iconURL()
}, },
footer: { fields : [
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL()
},
fields: [
{ {
name: bwtitle, name : bwtitle,
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + " / " + bwstars.toString() + "`\n" + value : "**➺ Stars:** `" +
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + " / " + bwfdkr.toString() + "`\n" + stats.data.stats.BedWars.level.toString() + " / " +
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + " / " + bwwins.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 : "**➺ Wins:** `" +
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" + stats.data.stats.Duels.general.wins.toString() +
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).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() +
"`"
} }
] ]
} ]
}); });
} }
}; };

144
index.js
View File

@@ -1,26 +1,22 @@
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.MessageContent,
GatewayIntentBits.DirectMessages GatewayIntentBits.DirectMessages
], ],
partials: [ partials : [
Partials.GuildMember, Partials.GuildMember, Partials.User, Partials.Message, Partials.Channel
Partials.User,
Partials.Message,
Partials.Channel
] ]
}); });
@@ -40,13 +36,15 @@ for (const file of cmdFiles) {
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) {
@@ -56,13 +54,15 @@ for (const file of cmdTestFiles) {
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);
@@ -75,13 +75,17 @@ 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) {
@@ -91,13 +95,15 @@ for (const file of contextMenuFiles) {
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);
@@ -110,7 +116,10 @@ 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
})
} }
}); });
@@ -126,13 +135,15 @@ for (const file of btnFiles) {
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);
@@ -145,34 +156,41 @@ 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.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async interaction => {
if (interaction.isCommand()) { if (interaction.isCommand()) {
console.log(interaction.user.username + "#" + interaction.user.discriminator + " ran " + interaction.commandName); console.log(interaction.user.username + "#" +
interaction.user.discriminator + " ran " +
interaction.commandName);
} else if (interaction.isButton()) { } else if (interaction.isButton()) {
console.log(interaction.user.username + "#" + interaction.user.discriminator + " clicked " + interaction.customId); console.log(interaction.user.username + "#" +
interaction.user.discriminator + " clicked " +
interaction.customId);
} }
}); });
client.on(Events.ClientReady, () => { client.on(Events.ClientReady, () => {
@@ -184,60 +202,30 @@ client.on(Events.ClientReady, () => {
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(
client.user.setActivity({ name: "over the Illegitimate Server", type: ActivityType.Watching }); {name : "over the Illegitimate Server", type : ActivityType.Watching});
const activities = [ const activities = [
{ {name : "with Jone the idiot", type : ActivityType.Playing},
name: "with Jone the idiot", {name : "with Martina the bot", type : ActivityType.Playing},
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 Martina the bot", {name : "with ur mom in my bed", type : ActivityType.Playing},
type: ActivityType.Playing {name : "over the Illegitimate Server", type : ActivityType.Watching}
},
{
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; let i = 0;
setInterval(() => setInterval(() =>
client.user.setActivity(activities[i++ % activities.length]), 1000 * 60 * 30 client.user.setActivity(activities[i++ % activities.length]),
) 1000 * 60 * 30)
});
client.on(Events.ClientReady, () => {
client.user.setStatus('dnd');
}); });
client.on(Events.ClientReady, () => { client.user.setStatus('dnd'); });
client.login(token); client.login(token);
connect(mongoURI, {}).then(() => { connect(mongoURI, {}).then(() => { console.log('Connected to MongoDB'); })
console.log('Connected to MongoDB');
})

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