2nd commit

This commit is contained in:
2023-03-11 20:16:50 +01:00
parent d7d6c0f399
commit 151498af20
8 changed files with 253 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { hypixelApiKey, dev } = require('../config.json');
const { color } = require('../options.json');
module.exports = {
name: 'check',
@@ -22,11 +23,12 @@ module.exports = {
const mojang = "https://api.mojang.com/users/profiles/minecraft/"
const slothPixel = "https://api.slothpixel.me/api/players/";
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 stats = await fetch(slothPixel + ign);
const head = await fetch(minotar + ign + "/100.png");
const head = minotar + ign;
if (interaction.user.id !== dev) {
interaction.reply('This command is currently under development.')
@@ -38,26 +40,50 @@ module.exports = {
return
}
if (!userCheck.status === 200) {
if (!userCheck.data.id) {
interaction.reply('That player doesn\'t exist. [Mojang]')
return
}
if (!stats.status === 200) {
if (!stats.data.uuid) {
interaction.reply('That player doesn\'t exist. [Hypixel]')
return
}
const level = stats.data.stats.SkyWars.level;
await interaction.reply({
embeds: [{
title: ign,
description: stats.stats.Bedwars.level,
color: 0x00ff00,
title: stats.data.username,
description: "**Stats:**",
color: embedColor,
thumbnail: {
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
View 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 })
}
}
};

View File

@@ -1,4 +1,5 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
const { color } = require('../options.json');
module.exports = {
name: 'send',
@@ -38,7 +39,7 @@ module.exports = {
{
title: interaction.guild.name,
description: message,
color: 0x00ff00,
color: color,
thumbnail: {
url: interaction.guild.iconURL({ dynamic: true })
},