Adding command logger
This commit is contained in:
@@ -1,59 +1,54 @@
|
|||||||
const { SlashCommandBuilder } = require('discord.js');
|
const { SlashCommandBuilder } = require("discord.js");
|
||||||
const env = require('dotenv').config();
|
const env = require("dotenv").config();
|
||||||
const hypixelApiKey = process.env.HYPIXELAPIKEY;
|
const hypixelApiKey = process.env.HYPIXELAPIKEY;
|
||||||
const fetch = require('axios');
|
const fetch = require("axios");
|
||||||
const { color, hypixelGuildID } = require('../config/options.json');
|
const { color, hypixelGuildID } = require("../config/options.json");
|
||||||
const verify = require('../schemas/verifySchema.js')
|
const verify = require("../schemas/verifySchema.js");
|
||||||
const mongoose = require('mongoose');
|
const mongoose = require("mongoose");
|
||||||
const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require('../config/roles.json');
|
const { gm, manager, moderator, beast, member, trialmember, guildRole, guildStaff, defaultMember } = require("../config/roles.json");
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'verify',
|
name: "verify",
|
||||||
description: 'Verify yourself as a member of the server.',
|
description: "Verify yourself as a member of the server.",
|
||||||
type: 'slash',
|
type: "slash",
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('verify')
|
.setName("verify")
|
||||||
.setDescription('Verify yourself as a member of the server.')
|
.setDescription("Verify yourself as a member of the server.")
|
||||||
.addStringOption(option =>
|
.addStringOption((option) => option.setName("ign").setDescription("Your in-game name."))
|
||||||
option
|
|
||||||
.setName('ign')
|
|
||||||
.setDescription('Your in-game name.'))
|
|
||||||
.setDMPermission(false),
|
.setDMPermission(false),
|
||||||
|
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
const user1 = interaction.user;
|
const user1 = interaction.user;
|
||||||
const user = await interaction.guild.members.fetch(user1.id);
|
const user = await interaction.guild.members.fetch(user1.id);
|
||||||
|
|
||||||
const fullUsername = user.user.username + "#" + user.user.discriminator
|
const fullUsername = user.user.username + "#" + user.user.discriminator;
|
||||||
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"));
|
||||||
|
|
||||||
const verifyData = await verify.findOne({ userID: user.id })
|
const verifyData = await verify.findOne({ userID: user.id });
|
||||||
|
|
||||||
if (verifyData) {
|
if (verifyData) {
|
||||||
interaction.editReply('You are already verified.')
|
interaction.editReply("You are already verified.");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ign) {
|
if (!ign) {
|
||||||
interaction.editReply('Please provide a player\'s IGN.')
|
interaction.editReply("Please provide a player's IGN.");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(mojang + ign);
|
await fetch(mojang + ign);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
interaction.editReply('That player doesn\'t exist. [Mojang]')
|
interaction.editReply("That player doesn't exist. [Mojang]");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userCheck = await fetch(mojang + ign);
|
const userCheck = await fetch(mojang + ign);
|
||||||
@@ -62,8 +57,8 @@ module.exports = {
|
|||||||
try {
|
try {
|
||||||
await fetch(slothPixel + userUUID);
|
await fetch(slothPixel + userUUID);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
interaction.editReply('That player doesn\'t exist. [Hypixel]')
|
interaction.editReply("That player doesn't exist. [Hypixel]");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hypixelCheck = await fetch(slothPixel + userUUID);
|
const hypixelCheck = await fetch(slothPixel + userUUID);
|
||||||
@@ -71,12 +66,14 @@ module.exports = {
|
|||||||
|
|
||||||
if (hypixelCheck.data.links.DISCORD !== fullUsername) {
|
if (hypixelCheck.data.links.DISCORD !== fullUsername) {
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
embeds: [{
|
embeds: [
|
||||||
|
{
|
||||||
description: "<a:cross_a:1087808606897983539> The discord tag for `" + userCheck.data.name + "` is not `" + fullUsername + "`. Please link your discord account to your hypixel account.",
|
description: "<a:cross_a:1087808606897983539> The discord tag for `" + userCheck.data.name + "` is not `" + fullUsername + "`. Please link your discord account to your hypixel account.",
|
||||||
color: embedColor
|
color: embedColor
|
||||||
}]
|
}
|
||||||
})
|
]
|
||||||
return
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -87,11 +84,11 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (responseGuildID !== hypixelGuildID) {
|
if (responseGuildID !== hypixelGuildID) {
|
||||||
|
await user.roles.add(defaultMember, "Verification");
|
||||||
await user.roles.add(defaultMember, "Verification")
|
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [
|
||||||
|
{
|
||||||
title: interaction.guild.name,
|
title: interaction.guild.name,
|
||||||
description: "<a:check_a:1087808632172847134> You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.",
|
description: "<a:check_a:1087808632172847134> You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.",
|
||||||
color: embedColor,
|
color: embedColor,
|
||||||
@@ -102,60 +99,62 @@ module.exports = {
|
|||||||
icon_url: interaction.guild.iconURL(),
|
icon_url: interaction.guild.iconURL(),
|
||||||
text: interaction.guild.name + " | Developed by Taken#0002"
|
text: interaction.guild.name + " | Developed by Taken#0002"
|
||||||
}
|
}
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const guildCheck = await fetch(guildAPI + userUUID);
|
const guildCheck = await fetch(guildAPI + userUUID);
|
||||||
const GuildMembers = await guildCheck.data.members;
|
const GuildMembers = await guildCheck.data.members;
|
||||||
const guildRank = GuildMembers.find(member => member.uuid === hypixelCheck.data.uuid).rank;
|
const guildRank = GuildMembers.find((member) => member.uuid === hypixelCheck.data.uuid).rank;
|
||||||
|
|
||||||
if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) {
|
if (guildRank === "Guild Master" && responseGuildID === hypixelGuildID) {
|
||||||
await user.roles.add(gm, "Verification");
|
await user.roles.add(gm, "Verification");
|
||||||
await user.roles.add(guildRole, "Verification")
|
await user.roles.add(guildRole, "Verification");
|
||||||
await user.roles.add(guildStaff, "Verification")
|
await user.roles.add(guildStaff, "Verification");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guildRank === "Manager" && responseGuildID === hypixelGuildID) {
|
if (guildRank === "Manager" && responseGuildID === hypixelGuildID) {
|
||||||
await user.roles.add(manager, "Verification");
|
await user.roles.add(manager, "Verification");
|
||||||
await user.roles.add(guildRole, "Verification")
|
await user.roles.add(guildRole, "Verification");
|
||||||
await user.roles.add(guildStaff, "Verification")
|
await user.roles.add(guildStaff, "Verification");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) {
|
if (guildRank === "Moderator" && responseGuildID === hypixelGuildID) {
|
||||||
await user.roles.add(moderator, "Verification");
|
await user.roles.add(moderator, "Verification");
|
||||||
await user.roles.add(guildRole, "Verification")
|
await user.roles.add(guildRole, "Verification");
|
||||||
await user.roles.add(guildStaff, "Verification")
|
await user.roles.add(guildStaff, "Verification");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guildRank === "Beast" && responseGuildID === hypixelGuildID) {
|
if (guildRank === "Beast" && responseGuildID === hypixelGuildID) {
|
||||||
await user.roles.add(beast, "Verification");
|
await user.roles.add(beast, "Verification");
|
||||||
await user.roles.add(guildRole, "Verification")
|
await user.roles.add(guildRole, "Verification");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guildRank === "Member" && responseGuildID === hypixelGuildID) {
|
if (guildRank === "Member" && responseGuildID === hypixelGuildID) {
|
||||||
await user.roles.add(member, "Verification");
|
await user.roles.add(member, "Verification");
|
||||||
await user.roles.add(guildRole, "Verification")
|
await user.roles.add(guildRole, "Verification");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) {
|
if (guildRank === "Trial Member" && responseGuildID === hypixelGuildID) {
|
||||||
await user.roles.add(trialmember, "Verification");
|
await user.roles.add(trialmember, "Verification");
|
||||||
await user.roles.add(guildRole, "Verification")
|
await user.roles.add(guildRole, "Verification");
|
||||||
}
|
}
|
||||||
|
|
||||||
await user.roles.add(defaultMember, "Verification")
|
await user.roles.add(defaultMember, "Verification");
|
||||||
|
|
||||||
const newVerify = new verify({
|
const newVerify = new verify({
|
||||||
_id: new mongoose.Types.ObjectId(),
|
_id: new mongoose.Types.ObjectId(),
|
||||||
userID: user.id,
|
userID: user.id,
|
||||||
uuid: userUUID
|
uuid: userUUID
|
||||||
})
|
});
|
||||||
|
|
||||||
await newVerify.save()
|
await newVerify.save();
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [
|
||||||
|
{
|
||||||
title: interaction.guild.name,
|
title: interaction.guild.name,
|
||||||
description: "You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.",
|
description: "You have successfully verified `" + fullUsername + "` with the account `" + hypixelCheck.data.username + "`.",
|
||||||
color: embedColor,
|
color: embedColor,
|
||||||
@@ -166,8 +165,8 @@ module.exports = {
|
|||||||
icon_url: interaction.guild.iconURL(),
|
icon_url: interaction.guild.iconURL(),
|
||||||
text: interaction.guild.name + " | Developed by Taken#0002"
|
text: interaction.guild.name + " | Developed by Taken#0002"
|
||||||
}
|
}
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
11
index.js
11
index.js
@@ -164,6 +164,17 @@ for (const file of modalFiles) {
|
|||||||
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 => {
|
||||||
|
|
||||||
|
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, () => {
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user