⚰️ remove unused imports

This commit is contained in:
Axel Olausson Holtenäs 2022-08-25 11:53:05 +02:00
parent 741c33f41d
commit 6a7f6f33a6
50 changed files with 268 additions and 403 deletions

View file

@ -1,5 +1,5 @@
import "dotenv/config";
import { Client, Collection, GatewayIntentBits } from "discord.js"; // discord.js
import "dotenv/config";
import * as managers from "./managers";

View file

@ -8,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import guildSchema from "../../../../../models/guild";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChannelType } from "discord-api-types/v10";
import guildSchema from "../../../../../models/guild";
export default {
metadata: {

View file

@ -1,8 +1,6 @@
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -10,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import apiSchema from "../../../../../models/api";
import encryption from "../../../../../handlers/encryption";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import encryption from "../../../../../handlers/encryption";
import apiSchema from "../../../../../models/api";
export default {
metadata: {

View file

@ -1,8 +1,6 @@
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -10,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import guildSchema from "../../../../../models/guild";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import guildSchema from "../../../../../models/guild";
export default {
metadata: {

View file

@ -1,10 +1,6 @@
import {
ChatInputCommandInteraction,
ColorResolvable,
CommandInteraction,
} from "discord.js";
import guildSchema from "../../../../../../../models/guild";
import { ChatInputCommandInteraction, ColorResolvable } from "discord.js";
import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";
import guildSchema from "../../../../../../../models/guild";
export default async (interaction: ChatInputCommandInteraction) => {
const { options, guild } = interaction;

View file

@ -1,16 +1,11 @@
import {
ColorResolvable,
ChatInputCommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
import logger from "../../../../../middlewares/logger";
import guildSchema from "../../../../../models/guild";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import guildSchema from "../../../../../models/guild";
import getValues from "./components/getValues";
export default {

View file

@ -1,9 +1,9 @@
import audits from "./audits";
import credits from "./credits";
import points from "./points";
import cpgg from "./cpgg";
import credits from "./credits";
import embeds from "./embeds";
import points from "./points";
import shop from "./shop";
import welcome from "./welcome";
import embeds from "./embeds";
export default { audits, credits, points, cpgg, shop, welcome, embeds };

View file

@ -1,7 +1,6 @@
import {
ChatInputCommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -9,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import guildSchema from "../../../../../models/guild";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import guildSchema from "../../../../../models/guild";
export default {
metadata: {

View file

@ -1,8 +1,6 @@
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -10,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import guildSchema from "../../../../../models/guild";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import guildSchema from "../../../../../models/guild";
export default {
metadata: {

View file

@ -1,8 +1,6 @@
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -10,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import guildSchema from "../../../../../models/guild";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChannelType } from "discord-api-types/v10";
import guildSchema from "../../../../../models/guild";
export default {
metadata: {

View file

@ -1,5 +1,5 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { ChatInputCommandInteraction } from "discord.js";
import modules from "../../commands/counters/modules";
@ -11,7 +11,7 @@ export const builder = new SlashCommandBuilder()
export const moduleData = modules;
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
if (interaction.options.getSubcommand() === "view") {
await modules.view.execute(interaction);
}

View file

@ -1,8 +1,8 @@
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChannelType } from "discord-api-types/v10";
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import counterSchema from "../../../../../models/counter";

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
import logger from "../../../middlewares/logger";
import modules from "./modules";
@ -15,7 +15,7 @@ export const builder = new SlashCommandBuilder()
export const moduleData = modules;
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
const { options } = interaction;
switch (options.getSubcommand()) {

View file

@ -1,7 +1,7 @@
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import logger from "../../../../../middlewares/logger";
import fetchUser from "../../../../../helpers/fetchUser";

View file

@ -1,5 +1,5 @@
// Dependencies
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
// Configurations
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
@ -10,8 +10,8 @@ import logger from "../../../../../middlewares/logger";
import mongoose from "mongoose";
// Models
import fetchUser from "../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import fetchUser from "../../../../../helpers/fetchUser";
// Function
export default {
@ -37,7 +37,7 @@ export default {
option.setName("reason").setDescription("Your reason.")
);
},
execute: async (interaction: CommandInteraction) => {
execute: async (interaction: ChatInputCommandInteraction) => {
const { errorColor, successColor, footerText, footerIcon } =
await getEmbedConfig(interaction.guild);
const { options, user, guild, client } = interaction;

View file

@ -1,7 +1,7 @@
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import logger from "../../../../../middlewares/logger";
import userSchema, { IUser } from "../../../../../models/user";

View file

@ -1,7 +1,7 @@
// Dependencies
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import Chance from "chance";
import { CommandInteraction, EmbedBuilder } from "discord.js";
// Configurations
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
@ -13,8 +13,8 @@ import logger from "../../../../../middlewares/logger";
import * as cooldown from "../../../../../helpers/cooldown";
// Helpers
import fetchUser from "../../../../../helpers/fetchUser";
import fetchGuild from "../../../../../helpers/fetchGuild";
import fetchUser from "../../../../../helpers/fetchUser";
export default {
metadata: { guildOnly: true, ephemeral: true },

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
import modules from "./modules";
export const moduleData = modules;
@ -10,7 +10,7 @@ export const builder = new SlashCommandBuilder()
.addSubcommand(modules.lookup.builder);
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
switch (interaction.options.getSubcommand()) {
case "lookup":
return modules.lookup.execute(interaction);

View file

@ -1,5 +1,5 @@
import axios from "axios";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
@ -21,7 +21,7 @@ export default {
.setRequired(true)
);
},
execute: async (interaction: CommandInteraction) => {
execute: async (interaction: ChatInputCommandInteraction) => {
const { errorColor, successColor, footerText, footerIcon } =
await getEmbedConfig(interaction.guild);
const embedTitle = "[:hammer:] Utility (Lookup)";

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
import logger from "../../../middlewares/logger";
import modules from "../../commands/fun/modules";
@ -12,7 +12,7 @@ export const builder = new SlashCommandBuilder()
export const moduleData = modules;
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
const { options } = interaction;
if (options.getSubcommand() === "meme") {

View file

@ -1,8 +1,7 @@
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import axios from "axios";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
export default {
metadata: { guildOnly: false, ephemeral: false, cooldown: 15 },

View file

@ -1,6 +1,6 @@
//Dependencies
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
// Groups
import modules from "../../commands/manage/modules";
@ -14,7 +14,7 @@ export const builder = new SlashCommandBuilder()
.addSubcommandGroup(modules.counters.builder)
.addSubcommandGroup(modules.credits.builder);
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
// Destructure
const { options } = interaction;

View file

@ -1,6 +1,6 @@
// Dependencies
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
import { ChatInputCommandInteraction, CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
import logger from "../../../../../middlewares/logger";

View file

@ -1,11 +1,11 @@
// Dependencies
import {
EmbedBuilder,
ChatInputCommandInteraction,
PermissionsBitField,
} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChannelType } from "discord-api-types/v10";
import {
ChatInputCommandInteraction,
EmbedBuilder,
PermissionsBitField,
} from "discord.js";
// Configurations
import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";

View file

@ -1,9 +1,7 @@
// Dependencies
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -14,9 +12,9 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";
import logger from "../../../../../../../middlewares/logger";
// Models
import counterSchema from "../../../../../../../models/counter";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChannelType } from "discord-api-types/v10";
import counterSchema from "../../../../../../../models/counter";
// Function
export default {

View file

@ -1,5 +1,5 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
import { ChatInputCommandInteraction } from "discord.js";
import modules from "./modules";
@ -16,7 +16,7 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => {
.addSubcommand(modules.giveaway.builder);
};
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
switch (interaction.options.getSubcommand()) {
case "give":
return modules.give.execute(interaction);

View file

@ -1,12 +1,10 @@
// Dependencies
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
// Configurations
import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";

View file

@ -1,18 +1,16 @@
// Dependencies
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import axios from "axios";
import {
CommandInteraction,
ActionRowBuilder,
ButtonBuilder,
EmbedBuilder,
Permissions,
PermissionsBitField,
ChatInputCommandInteraction,
EmbedBuilder,
PermissionsBitField,
} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { v4 as uuidv4 } from "uuid";
import axios from "axios";
import apiSchema from "../../../../../../../models/api";
import encryption from "../../../../../../../handlers/encryption";
import apiSchema from "../../../../../../../models/api";
// Configurations
import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";

View file

@ -1,7 +1,7 @@
import give from "./give";
import giveaway from "./giveaway";
import set from "./set";
import take from "./take";
import transfer from "./transfer";
import giveaway from "./giveaway";
export default { give, set, take, transfer, giveaway };

View file

@ -1,8 +1,7 @@
// Dependencies
import {
CommandInteraction,
ChatInputCommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -15,8 +14,8 @@ import logger from "../../../../../../../middlewares/logger";
// Helpers
// Models
import fetchUser from "../../../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import fetchUser from "../../../../../../../helpers/fetchUser";
// Function
export default {

View file

@ -1,9 +1,7 @@
// Dependencies
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -17,8 +15,8 @@ import logger from "../../../../../../../middlewares/logger";
import pluralize from "../../../../../../../helpers/pluralize";
// Models
import fetchUser from "../../../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import fetchUser from "../../../../../../../helpers/fetchUser";
// Function
export default {

View file

@ -1,9 +1,7 @@
// Dependencies
import {
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -16,8 +14,8 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";
import logger from "../../../../../../../middlewares/logger";
// Models
import fetchUser from "../../../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import fetchUser from "../../../../../../../helpers/fetchUser";
// Function
export default {

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
import modules from "./modules";
export const moduleData = modules;
@ -10,7 +10,7 @@ export const builder = new SlashCommandBuilder()
.addSubcommand(modules.prune.builder);
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
switch (interaction.options.getSubcommand()) {
case "prune":
return modules.prune.execute(interaction);

View file

@ -2,9 +2,7 @@
import {
ChannelType,
ChatInputCommandInteraction,
CommandInteraction,
EmbedBuilder,
Permissions,
PermissionsBitField,
} from "discord.js";
@ -36,8 +34,9 @@ export default {
);
},
execute: async (interaction: ChatInputCommandInteraction) => {
const { errorColor, successColor, footerText, footerIcon } =
await getEmbedConfig(interaction.guild);
const { errorColor, footerText, footerIcon } = await getEmbedConfig(
interaction.guild
);
const count = interaction.options.getInteger("count");
if (count == null) return;

View file

@ -1,6 +1,6 @@
// Dependencies
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
// Modules
import modules from "../../commands/profile/modules";
@ -16,7 +16,7 @@ export const builder = new SlashCommandBuilder()
.setDescription("Check a profile.")
.addSubcommand(modules.view.builder);
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
const { options } = interaction;
if (options?.getSubcommand() === "view") {

View file

@ -1,5 +1,5 @@
// Dependencies
import { CommandInteraction } from "discord.js";
import { CommandInteraction, EmbedBuilder } from "discord.js";
// Configurations
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
@ -7,8 +7,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
// Models
import fetchUser from "../../../../../helpers/fetchUser";
import logger from "../../../../../middlewares/logger";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import logger from "../../../../../middlewares/logger";
// Function
export default {
@ -24,7 +24,7 @@ export default {
},
execute: async (interaction: CommandInteraction) => {
const { successColor, footerText, footerIcon } = await getEmbedConfig(
const { errorColor, footerText, footerIcon } = await getEmbedConfig(
interaction.guild
); // Destructure
const { client, options, user, guild } = interaction;
@ -44,14 +44,12 @@ export default {
// User Information
const userObj = await fetchUser(discordUser, guild);
// Embed object
const embed = {
author: {
const embed = new EmbedBuilder()
.setAuthor({
name: `${discordUser?.username}#${discordUser?.discriminator}`,
icon_url: discordUser?.displayAvatarURL(),
},
color: successColor,
fields: [
iconURL: discordUser?.displayAvatarURL(),
})
.addFields(
{
name: `:dollar: Credits`,
value: `${userObj?.credits || "Not found"}`,
@ -76,14 +74,11 @@ export default {
name: `:rainbow_flag: Language`,
value: `${userObj?.language || "Not found"}`,
inline: true,
},
],
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
};
}
)
.setTimestamp()
.setColor(errorColor)
.setFooter({ text: footerText, iconURL: footerIcon });
// Return interaction reply
return interaction?.editReply({ embeds: [embed] });

View file

@ -1,6 +1,6 @@
// Dependencies
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
// Modules
import modules from "./modules";
@ -15,7 +15,7 @@ export const builder = new SlashCommandBuilder()
.setDescription("Manage reputation.")
.addSubcommand(modules.give.builder);
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
if (interaction.options.getSubcommand() === "give") {
await modules.give.execute(interaction);
}

View file

@ -1,4 +1,5 @@
import { User } from "discord.js";
export default async (to: User | null, from: User | null) => {
if (from?.id === to?.id) {
throw new Error("You cannot give reputation to yourself.");

View file

@ -1,9 +1,9 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
import * as cooldown from "../../../../../helpers/cooldown";
import fetchUser from "../../../../../helpers/fetchUser";
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import fetchUser from "../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import * as cooldown from "../../../../../helpers/cooldown";
import noSelfReputation from "./components/noSelfReputation";
export default {
@ -33,7 +33,7 @@ export default {
)
);
},
execute: async (interaction: CommandInteraction) => {
execute: async (interaction: ChatInputCommandInteraction) => {
const { options, user, guild } = interaction;
const { successColor, footerText, footerIcon } = await getEmbedConfig(
@ -68,19 +68,17 @@ export default {
await userObj.save().then(async () => {
logger.silly(`User reputation has been updated`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:loudspeaker:] Give")
.setDescription(
`You have given a ${optionType} repute to ${optionTarget}`
)
.setTimestamp()
.setColor(successColor)
.setFooter({ text: footerText, iconURL: footerIcon });
await interaction.editReply({
embeds: [
{
title: "[:loudspeaker:] Give",
description: `You have given a ${optionType} repute to ${optionTarget}`,
timestamp: new Date(),
color: successColor,
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
});
},

View file

@ -1,6 +1,6 @@
// Dependencies
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
// Modules
import modules from "./modules";
@ -17,7 +17,7 @@ export const builder = new SlashCommandBuilder()
.addSubcommand(modules.cpgg.builder)
.addSubcommandGroup(modules.roles.builder);
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
const { options } = interaction;
if (options?.getSubcommand() === "cpgg") {

View file

@ -1,21 +1,22 @@
import axios from "axios";
import {
CommandInteraction,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
ChatInputCommandInteraction,
EmbedBuilder,
Message,
} from "discord.js";
import { v4 as uuidv4 } from "uuid";
import axios from "axios";
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import encryption from "../../../../../handlers/encryption";
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import logger from "../../../../../middlewares/logger";
import pluralize from "../../../../../helpers/pluralize";
import apiSchema from "../../../../../models/api";
import fetchUser from "../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import fetchUser from "../../../../../helpers/fetchUser";
import pluralize from "../../../../../helpers/pluralize";
import apiSchema from "../../../../../models/api";
export default {
metadata: { guildOnly: true, ephemeral: true },
@ -31,7 +32,7 @@ export default {
.setRequired(true)
);
},
execute: async (interaction: CommandInteraction) => {
execute: async (interaction: ChatInputCommandInteraction) => {
const { errorColor, successColor, footerText, footerIcon } =
await getEmbedConfig(interaction.guild);
const { options, guild, user, client } = interaction;
@ -41,19 +42,15 @@ export default {
if (optionAmount === null) {
logger?.silly(`Amount is null.`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:dollar:] Gift")
.setDescription("We could not read your requested amount.")
.setTimestamp()
.setColor(errorColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: ":dollar: Credits [Gift]",
description: "We could not read your requested amount.",
color: errorColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
}
@ -72,76 +69,59 @@ export default {
if ((optionAmount || userDB?.credits) < 100) {
logger?.silly(`Amount or user credits is below 100.`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] CPGG")
.setDescription("You **can't** withdraw for __CPGG__ below **100**.")
.setTimestamp()
.addFields({
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
})
.setColor(errorColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: "[:shopping_cart:] CPGG",
description: `You **can't** withdraw for __CPGG__ below **100**.`,
color: errorColor,
fields: [
{
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
},
],
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
}
if ((optionAmount || userDB?.credits) > 1000000) {
logger?.silly(`Amount or user credits is above 1.000.000.`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] CPGG")
.setDescription(
"You **can't** withdraw for __CPGG__ above **1.000.000**."
)
.setTimestamp()
.addFields({
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
})
.setColor(errorColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: "[:shopping_cart:] CPGG",
description:
"You **can't** withdraw for __CPGG__ above **1.000.000**.",
color: errorColor,
fields: [
{
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
},
],
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
}
if (userDB?.credits < optionAmount) {
logger?.silly(`User credits is below amount.`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] CPGG")
.setDescription("You have **insufficient** credits.")
.setTimestamp()
.addFields({
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
})
.setColor(errorColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: "[:shopping_cart:] CPGG",
description: `You have **insufficient** credits.`,
color: errorColor,
fields: [
{
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
},
],
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
}
@ -163,10 +143,10 @@ export default {
const shopUrl = `${url}/store`;
const buttons = new ActionRowBuilder().addComponents(
const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setLabel("Redeem it here")
.setStyle("LINK")
.setStyle(ButtonStyle.Link)
.setEmoji("🏦")
.setURL(`${shopUrl}?voucher=${code}`)
);
@ -193,43 +173,37 @@ export default {
if (!interaction.guild) throw new Error("Guild is undefined");
const dmEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] CPGG")
.setDescription(
`This voucher comes from **${interaction.guild.name}**.`
)
.setTimestamp()
.addFields({
name: "💶 Credits",
value: `${optionAmount || userDB?.credits}`,
inline: true,
})
.setColor(successColor)
.setFooter({ text: footerText, iconURL: footerIcon });
await dmUser
?.send({
embeds: [
{
title: "[:shopping_cart:] CPGG",
description: `This voucher comes from **${interaction.guild.name}**.`,
fields: [
{
name: "💶 Credits",
value: `${optionAmount || userDB?.credits}`,
inline: true,
},
],
color: successColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [dmEmbed],
components: [buttons],
})
.then(async (msg) => {
.then(async (msg: Message) => {
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] CPGG")
.setDescription(
`I have sent you the code in [DM](${msg.url})!`
)
.setTimestamp()
.setColor(successColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: "[:shopping_cart:] CPGG",
description: `I have sent you the code in [DM](${msg.url})!`,
color: successColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
});
})
@ -237,19 +211,15 @@ export default {
.catch(async (error) => {
logger?.silly(`Error saving new credits. - ${error}`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] CPGG")
.setDescription(`Something went wrong.`)
.setTimestamp()
.setColor(errorColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: "[:shopping_cart:] CPGG",
description: "Something went wrong.",
color: errorColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
});
})
@ -257,19 +227,15 @@ export default {
.catch(async (error) => {
logger?.silly(`Error creating voucher. - ${error}`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] CPGG")
.setDescription(`Something went wrong.`)
.setTimestamp()
.setColor(errorColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: "[:shopping_cart:] CPGG",
description: "Something went wrong.",
color: errorColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
});
},

View file

@ -1,11 +1,8 @@
// Dependencies
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
// Handlers
import logger from "../../../../../middlewares/logger";
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
// Modules
import modules from "./modules";
@ -23,11 +20,8 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => {
.addSubcommand(modules.cancel.builder);
};
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
if (interaction.guild == null) return;
const { errorColor, footerText, footerIcon } = await getEmbedConfig(
interaction.guild
);
const { options, guild } = interaction;
const guildDB = await guildSchema?.findOne({
@ -36,24 +30,8 @@ export const execute = async (interaction: CommandInteraction) => {
if (guildDB === null) return;
if (!guildDB.shop.roles.status) {
logger.silly(`Shop roles disabled.`);
return interaction?.editReply({
embeds: [
{
title: ":dollar: Shop - Roles",
description: "This server has disabled shop roles.",
color: errorColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
});
}
if (!guildDB.shop.roles.status)
throw new Error("This server has disabled shop roles.");
if (options?.getSubcommand() === "buy") {
await modules.buy.execute(interaction);

View file

@ -1,7 +1,8 @@
// Dependencies
import {
CommandInteraction,
ChatInputCommandInteraction,
ColorResolvable,
EmbedBuilder,
GuildMemberRoleManager,
} from "discord.js";
@ -9,15 +10,15 @@ import {
import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";
// Models
import shopRolesSchema from "../../../../../../../models/shopRole";
import guildSchema from "../../../../../../../models/guild";
import shopRolesSchema from "../../../../../../../models/shopRole";
import logger from "../../../../../../../middlewares/logger";
// Helpers
import pluralize from "../../../../../../../helpers/pluralize";
import fetchUser from "../../../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import fetchUser from "../../../../../../../helpers/fetchUser";
import pluralize from "../../../../../../../helpers/pluralize";
// Function
export default {
@ -40,33 +41,18 @@ export default {
.setRequired(true)
);
},
execute: async (interaction: CommandInteraction) => {
const { errorColor, successColor, footerText, footerIcon } =
await getEmbedConfig(interaction.guild);
execute: async (interaction: ChatInputCommandInteraction) => {
const { successColor, footerText, footerIcon } = await getEmbedConfig(
interaction.guild
);
const { options, guild, user, member } = interaction;
const optionName = options?.getString("name");
const optionColor = options?.getString("color");
// If amount is null
if (optionName === null) {
logger?.silly(`Name is null.`);
return interaction?.editReply({
embeds: [
{
title: ":dollar: Shop - Roles [Buy]",
description: "We could not read your requested name.",
color: errorColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
});
}
if (optionName === null)
throw new Error("We could not read your requested name");
await guild?.roles
.create({
@ -112,28 +98,20 @@ export default {
logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`);
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] Buy")
.setDescription(
`You bought **${optionName}** for **${pluralize(
pricePerHour,
"credit"
)}**.`
)
.setTimestamp()
.setColor(successColor)
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: ":shopping_cart: Shop - Roles [Buy]",
description: `You bought **${optionName}** for **${pluralize(
pricePerHour,
"credit"
)}**.`,
color: successColor,
fields: [
{
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
},
],
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
})
.catch(async (error) => {

View file

@ -1,5 +1,9 @@
// Dependencies
import { CommandInteraction, GuildMemberRoleManager } from "discord.js";
import {
ChatInputCommandInteraction,
EmbedBuilder,
GuildMemberRoleManager,
} from "discord.js";
// Configurations
import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig";
@ -10,9 +14,9 @@ import shopRolesSchema from "../../../../../../../models/shopRole";
import logger from "../../../../../../../middlewares/logger";
// Helpers
import pluralize from "../../../../../../../helpers/pluralize";
import fetchUser from "../../../../../../../helpers/fetchUser";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import fetchUser from "../../../../../../../helpers/fetchUser";
import pluralize from "../../../../../../../helpers/pluralize";
// Function
export default {
@ -29,31 +33,16 @@ export default {
.setRequired(true)
);
},
execute: async (interaction: CommandInteraction) => {
const { errorColor, successColor, footerText, footerIcon } =
await getEmbedConfig(interaction.guild);
execute: async (interaction: ChatInputCommandInteraction) => {
const { successColor, footerText, footerIcon } = await getEmbedConfig(
interaction.guild
);
const { options, guild, user, member } = interaction;
const optionRole = options.getRole("role");
if (optionRole === null) {
logger?.silly(`Role is null.`);
return interaction?.editReply({
embeds: [
{
title: ":dollar: Shop - Roles [Cancel]",
description: "We could not read your requested role.",
color: errorColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
});
}
if (optionRole === null)
throw new Error("We could not read your requested role.");
const roleExist = await shopRolesSchema?.findOne({
guildId: guild?.id,
@ -80,28 +69,22 @@ export default {
guildId: guild?.id,
});
const interactionEmbed = new EmbedBuilder()
.setTitle("[:shopping_cart:] Cancel")
.setDescription(`You have canceled ${optionRole.name}.`)
.setTimestamp()
.setColor(successColor)
.addFields({
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
})
.setFooter({ text: footerText, iconURL: footerIcon });
return interaction?.editReply({
embeds: [
{
title: ":shopping_cart: Shop - Roles [Cancel]",
description: `You have canceled ${optionRole.name}.`,
color: successColor,
fields: [
{
name: "Your balance",
value: `${pluralize(userDB?.credits, "credit")}`,
},
],
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
},
],
embeds: [interactionEmbed],
});
})
.catch(async (error) => {
.catch(async (error: Error) => {
return logger?.silly(`Role could not be deleted. ${error}`);
});
},

View file

@ -1,5 +1,5 @@
import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
import modules from "./modules";
export const moduleData = modules;
@ -13,7 +13,7 @@ export const builder = new SlashCommandBuilder()
.addSubcommand(modules.avatar.builder)
.addSubcommand(modules.ping.builder);
export const execute = async (interaction: CommandInteraction) => {
export const execute = async (interaction: ChatInputCommandInteraction) => {
switch (interaction.options.getSubcommand()) {
case "about":
return modules.about.execute(interaction);

View file

@ -1,9 +1,9 @@
// Dependencies
import {
CommandInteraction,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
CommandInteraction,
EmbedBuilder,
} from "discord.js";

View file

@ -1,7 +1,7 @@
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
import { CommandInteraction, EmbedBuilder } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { CommandInteraction, EmbedBuilder } from "discord.js";
export default {
metadata: { guildOnly: false, ephemeral: false },

View file

@ -1,7 +1,7 @@
import avatar from "./avatar";
import about from "./about";
import stats from "./stats";
import avatar from "./avatar";
import ping from "./ping";
import stats from "./stats";
export default {
avatar,

View file

@ -1,5 +1,5 @@
// Dependencies
import { CommandInteraction } from "discord.js";
import { CommandInteraction, EmbedBuilder } from "discord.js";
// Configurations
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
@ -18,9 +18,9 @@ export default {
interaction.guild
);
const interactionEmbed = {
title: "[:tools:] Ping",
fields: [
const interactionEmbed = new EmbedBuilder()
.setTitle("[:tools:] Ping")
.addFields(
{
name: "📦 Deliver Latency",
value: `${Math.abs(Date.now() - interaction.createdTimestamp)} ms`,
@ -30,15 +30,12 @@ export default {
name: "🤖 API Latency",
value: `${Math.round(interaction.client.ws.ping)} ms`,
inline: true,
},
],
color: successColor,
timestamp: new Date(),
footer: {
iconURL: footerIcon,
text: footerText,
},
};
}
)
.setTimestamp()
.setColor(successColor)
.setFooter({ text: footerText, iconURL: footerIcon });
await interaction.editReply({
embeds: [interactionEmbed],
});

View file

@ -1,4 +1,4 @@
import { Snowflake, ColorResolvable } from "discord.js";
import { ColorResolvable, Snowflake } from "discord.js";
declare global {
namespace NodeJS {