2nd commit
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
|
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
|
||||||
const { hypixelApiKey, dev } = require('../config.json');
|
const { hypixelApiKey, dev } = require('../config.json');
|
||||||
|
const { color } = require('../options.json');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'check',
|
name: 'check',
|
||||||
@@ -22,11 +23,12 @@ module.exports = {
|
|||||||
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 minotar = "https://minotar.net/helm/";
|
const minotar = "https://minotar.net/helm/";
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('axios');
|
||||||
|
const embedColor = Number(color.replace("#", "0x"));
|
||||||
|
|
||||||
const userCheck = await fetch(mojang + ign);
|
const userCheck = await fetch(mojang + ign);
|
||||||
const stats = await fetch(slothPixel + ign);
|
const stats = await fetch(slothPixel + ign);
|
||||||
const head = await fetch(minotar + ign + "/100.png");
|
const head = minotar + ign;
|
||||||
|
|
||||||
if (interaction.user.id !== dev) {
|
if (interaction.user.id !== dev) {
|
||||||
interaction.reply('This command is currently under development.')
|
interaction.reply('This command is currently under development.')
|
||||||
@@ -38,26 +40,50 @@ module.exports = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userCheck.status === 200) {
|
if (!userCheck.data.id) {
|
||||||
interaction.reply('That player doesn\'t exist. [Mojang]')
|
interaction.reply('That player doesn\'t exist. [Mojang]')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stats.status === 200) {
|
if (!stats.data.uuid) {
|
||||||
interaction.reply('That player doesn\'t exist. [Hypixel]')
|
interaction.reply('That player doesn\'t exist. [Hypixel]')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const level = stats.data.stats.SkyWars.level;
|
||||||
|
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: ign,
|
title: stats.data.username,
|
||||||
description: stats.stats.Bedwars.level,
|
description: "**Stats:**",
|
||||||
color: 0x00ff00,
|
color: embedColor,
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
url: head
|
url: head
|
||||||
},
|
},
|
||||||
|
footer: {
|
||||||
|
text: "Developed by @Taken#0002"
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "**Network Level**",
|
||||||
|
value: stats.data.level.toString(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "**Bedwars**",
|
||||||
|
value: "**Stars:** " + stats.data.stats.BedWars.level.toString() + "\n" +
|
||||||
|
"**FKDR:** " + stats.data.stats.BedWars.final_k_d.toString() + "\n" +
|
||||||
|
"**Wins:** " + stats.data.stats.BedWars.wins.toString()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "**Skywars**",
|
||||||
|
value: "**Stars:** " + stats.data.stats.SkyWars.level.toFixed(2).toString() + "\n" +
|
||||||
|
"**KDR**: " + stats.data.stats.SkyWars.kill_death_ratio.toString() + "\n" +
|
||||||
|
"**Wins:** " + stats.data.stats.SkyWars.wins.toString()
|
||||||
|
}
|
||||||
|
]
|
||||||
}]
|
}]
|
||||||
});
|
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
62
commands/config.js
Normal file
62
commands/config.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ActionRowBuilder, ButtonStyle } = require('discord.js');
|
||||||
|
const { color } = require('../options.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'config',
|
||||||
|
description: 'Configure the bot.',
|
||||||
|
type: 'slash',
|
||||||
|
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('config')
|
||||||
|
.setDescription('Configure the bot.')
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName('sendapplication')
|
||||||
|
.setDescription('Configure the send application command.')
|
||||||
|
.addChannelOption(option =>
|
||||||
|
option
|
||||||
|
.setName('channel')
|
||||||
|
.setDescription('The channel to send the application to.')
|
||||||
|
.setRequired(true)))
|
||||||
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||||
|
.setDMPermission(false),
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
|
||||||
|
const subcommand = interaction.options.getSubcommand();
|
||||||
|
const embedColor = Number(color.replace("#", "0x"));
|
||||||
|
|
||||||
|
if (subcommand === 'sendapplication') {
|
||||||
|
|
||||||
|
const channel = interaction.options.getChannel('channel');
|
||||||
|
|
||||||
|
await channel.send({
|
||||||
|
embeds: [{
|
||||||
|
title: 'Guild Application',
|
||||||
|
description: "You can apply for the guild by clicking the button below.",
|
||||||
|
color: embedColor,
|
||||||
|
footer: {
|
||||||
|
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||||
|
},
|
||||||
|
thumbnail: {
|
||||||
|
url: interaction.guild.iconURL({ dynamic: true })
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
components: [
|
||||||
|
new ActionRowBuilder().addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId('guildapply')
|
||||||
|
.setLabel('Apply')
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setEmoji({ name: '✅' })
|
||||||
|
)
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
await interaction.reply({ content: 'Message sent', ephemeral: true })
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
|
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
|
||||||
|
const { color } = require('../options.json');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'send',
|
name: 'send',
|
||||||
@@ -38,7 +39,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
title: interaction.guild.name,
|
title: interaction.guild.name,
|
||||||
description: message,
|
description: message,
|
||||||
color: 0x00ff00,
|
color: color,
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
url: interaction.guild.iconURL({ dynamic: true })
|
url: interaction.guild.iconURL({ dynamic: true })
|
||||||
},
|
},
|
||||||
|
|||||||
21
events/buttons/guilapply.js
Normal file
21
events/buttons/guilapply.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
const { color } = require('../../options.json');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'guildapply',
|
||||||
|
description: 'Guild application button.',
|
||||||
|
type: 'button',
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
|
||||||
|
const user = interaction.user;
|
||||||
|
const guild = interaction.guild;
|
||||||
|
const embedColor = Number(color.replace("#", "0x"));
|
||||||
|
|
||||||
|
if (interaction.customId === 'guildapply') {
|
||||||
|
|
||||||
|
await interaction.reply({ content: 'Please wait...', ephemeral: true });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
38
index.js
38
index.js
@@ -17,6 +17,7 @@ const client = new Client({
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
|
client.events = new Collection();
|
||||||
|
|
||||||
//! commands
|
//! commands
|
||||||
const cmdPath = path.join(__dirname, 'commands');
|
const cmdPath = path.join(__dirname, 'commands');
|
||||||
@@ -53,6 +54,43 @@ client.on(Events.InteractionCreate, async interaction => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//! button events
|
||||||
|
const btnPath = path.join(__dirname, 'events', 'buttons');
|
||||||
|
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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
const event2 = event.client.events.get(event.customId);
|
||||||
|
|
||||||
|
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 })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client.once(Events.Ready, c => {
|
client.once(Events.Ready, c => {
|
||||||
console.log(`Logged in as ${c.user.tag}!`);
|
console.log(`Logged in as ${c.user.tag}!`);
|
||||||
});
|
});
|
||||||
|
|||||||
3
options.json
Normal file
3
options.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"color": "#eeaadb"
|
||||||
|
}
|
||||||
91
package-lock.json
generated
91
package-lock.json
generated
@@ -9,6 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^1.3.4",
|
||||||
"discord.js": "^14.7.1"
|
"discord.js": "^14.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -111,6 +112,21 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/asynckit": {
|
||||||
|
"version": "0.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||||
|
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||||
|
},
|
||||||
|
"node_modules/axios": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
|
||||||
|
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"follow-redirects": "^1.15.0",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
|
"proxy-from-env": "^1.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/busboy": {
|
"node_modules/busboy": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
||||||
@@ -122,6 +138,25 @@
|
|||||||
"node": ">=10.16.0"
|
"node": ">=10.16.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/combined-stream": {
|
||||||
|
"version": "1.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||||
|
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||||
|
"dependencies": {
|
||||||
|
"delayed-stream": "~1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/delayed-stream": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/discord-api-types": {
|
"node_modules/discord-api-types": {
|
||||||
"version": "0.37.35",
|
"version": "0.37.35",
|
||||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.35.tgz",
|
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.35.tgz",
|
||||||
@@ -170,6 +205,38 @@
|
|||||||
"url": "https://github.com/sindresorhus/file-type?sponsor=1"
|
"url": "https://github.com/sindresorhus/file-type?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/follow-redirects": {
|
||||||
|
"version": "1.15.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
||||||
|
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"debug": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/form-data": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||||
|
"dependencies": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.8",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ieee754": {
|
"node_modules/ieee754": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||||
@@ -204,6 +271,25 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
|
||||||
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
|
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/mime-db": {
|
||||||
|
"version": "1.52.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||||
|
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mime-types": {
|
||||||
|
"version": "2.1.35",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||||
|
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-db": "1.52.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/peek-readable": {
|
"node_modules/peek-readable": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.0.0.tgz",
|
||||||
@@ -216,6 +302,11 @@
|
|||||||
"url": "https://github.com/sponsors/Borewit"
|
"url": "https://github.com/sponsors/Borewit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/proxy-from-env": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||||
|
},
|
||||||
"node_modules/readable-stream": {
|
"node_modules/readable-stream": {
|
||||||
"version": "3.6.2",
|
"version": "3.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"author": "Taken",
|
"author": "Taken",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^1.3.4",
|
||||||
"discord.js": "^14.7.1"
|
"discord.js": "^14.7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user