Removing unneccesarry files and dep.
This commit is contained in:
@@ -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 === "") {
|
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 =
|
||||||
} else {
|
"<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements.";
|
||||||
var bwtitle = "<a:check_a:1087808632172847134> This player meets the BedWars requirements.";
|
} else {
|
||||||
}
|
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 =
|
||||||
} else {
|
"<a:cross_a:1087808606897983539> This player does not meet the SkyWars requirements.";
|
||||||
var swtitle = "<a:check_a:1087808632172847134> This player meets the SkyWars requirements.";
|
} else {
|
||||||
}
|
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 =
|
||||||
} else {
|
"<a:cross_a:1087808606897983539> This player does not meet the Duels requirements.";
|
||||||
var duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements.";
|
} else {
|
||||||
}
|
var duelstitle =
|
||||||
|
"<a:check_a:1087808632172847134> This player meets the Duels requirements.";
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const guildCheck = await fetch(guildAPI + uuid);
|
const guildCheck = await fetch(guildAPI + uuid);
|
||||||
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:** `" +
|
||||||
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",
|
||||||
footer: {
|
icon_url : interaction.guild.iconURL()
|
||||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
},
|
||||||
icon_url: interaction.guild.iconURL()
|
fields : [
|
||||||
},
|
{
|
||||||
fields: [
|
name : bwtitle,
|
||||||
{
|
value : "**➺ Stars:** `" +
|
||||||
name: bwtitle,
|
stats.data.stats.BedWars.level.toString() + " / " +
|
||||||
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + " / " + bwstars.toString() + "`\n" +
|
bwstars.toString() + "`\n" +
|
||||||
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + " / " + bwfdkr.toString() + "`\n" +
|
"**➺ FKDR:** `" +
|
||||||
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + " / " + bwwins.toString() + "`"
|
stats.data.stats.BedWars.final_k_d.toString() +
|
||||||
},
|
" / " + bwfdkr.toString() + "`\n" +
|
||||||
{
|
"**➺ Wins:** `" +
|
||||||
name: swtitle,
|
stats.data.stats.BedWars.wins.toString() + " / " +
|
||||||
value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + " / " + swstars.toString() + "`\n" +
|
bwwins.toString() + "`"
|
||||||
"**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" +
|
},
|
||||||
"**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`"
|
{
|
||||||
},
|
name : swtitle,
|
||||||
{
|
value :
|
||||||
name: duelstitle,
|
"**➺ Stars:** `" +
|
||||||
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + " / " + duelswins.toString() + "`\n" +
|
stats.data.stats.SkyWars.level.toFixed(2).toString() +
|
||||||
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" +
|
" / " + swstars.toString() + "`\n" +
|
||||||
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`"
|
"**➺ 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
294
index.js
@@ -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);
|
const command = interaction.client.commands.get(interaction.commandName);
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
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);
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
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
|
||||||
@@ -120,124 +129,103 @@ 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);
|
||||||
|
|
||||||
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
1600
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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")
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -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 + '!')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user