🎨 Shop Command is now using guard classes
This commit is contained in:
parent
6589ac3ba3
commit
0816d0abe2
7 changed files with 52 additions and 57 deletions
|
@ -3,18 +3,18 @@ import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { ChatInputCommandInteraction } from "discord.js";
|
import { ChatInputCommandInteraction } from "discord.js";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import modules from "./modules";
|
import moduleCpgg from "./modules/cpgg";
|
||||||
|
import moduleRoles from "./modules/roles";
|
||||||
// Handlers
|
|
||||||
|
|
||||||
export const moduleData = modules;
|
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export const builder = new SlashCommandBuilder()
|
export const builder = new SlashCommandBuilder()
|
||||||
.setName("shop")
|
.setName("shop")
|
||||||
.setDescription("Shop for credits and custom roles.")
|
.setDescription("Shop for credits and custom roles.")
|
||||||
.addSubcommand(modules.cpgg.builder)
|
.setDMPermission(false)
|
||||||
.addSubcommandGroup(modules.roles.builder);
|
|
||||||
|
// Modules
|
||||||
|
.addSubcommand(moduleCpgg.builder)
|
||||||
|
.addSubcommandGroup(moduleRoles.builder);
|
||||||
|
|
||||||
// Execute the command
|
// Execute the command
|
||||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||||
|
@ -22,7 +22,7 @@ export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||||
|
|
||||||
switch (options.getSubcommand()) {
|
switch (options.getSubcommand()) {
|
||||||
case "cpgg": {
|
case "cpgg": {
|
||||||
await modules.cpgg.execute(interaction);
|
await moduleCpgg.execute(interaction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -32,7 +32,7 @@ export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||||
|
|
||||||
switch (options.getSubcommandGroup()) {
|
switch (options.getSubcommandGroup()) {
|
||||||
case "roles": {
|
case "roles": {
|
||||||
await modules.roles.execute(interaction);
|
await moduleRoles.execute(interaction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -10,13 +10,12 @@ import {
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import prisma from "../../../../handlers/database";
|
import prisma from "../../../../handlers/database";
|
||||||
|
import deferReply from "../../../../handlers/deferReply";
|
||||||
import encryption from "../../../../helpers/encryption";
|
import encryption from "../../../../helpers/encryption";
|
||||||
import getEmbedData from "../../../../helpers/getEmbedData";
|
import getEmbedData from "../../../../helpers/getEmbedData";
|
||||||
import logger from "../../../../middlewares/logger";
|
import logger from "../../../../middlewares/logger";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
metadata: { guildOnly: true, ephemeral: true },
|
|
||||||
|
|
||||||
builder: (command: SlashCommandSubcommandBuilder) => {
|
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("cpgg")
|
.setName("cpgg")
|
||||||
|
@ -29,6 +28,8 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
execute: async (interaction: ChatInputCommandInteraction) => {
|
execute: async (interaction: ChatInputCommandInteraction) => {
|
||||||
|
await deferReply(interaction, true);
|
||||||
|
|
||||||
const { errorColor, successColor, footerText, footerIcon } =
|
const { errorColor, successColor, footerText, footerIcon } =
|
||||||
await getEmbedData(interaction.guild);
|
await getEmbedData(interaction.guild);
|
||||||
const { options, guild, user, client } = interaction;
|
const { options, guild, user, client } = interaction;
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
import cpgg from "./cpgg";
|
|
||||||
import * as roles from "./roles";
|
|
||||||
|
|
||||||
export default { cpgg, roles };
|
|
|
@ -5,22 +5,24 @@ import { ChatInputCommandInteraction } from "discord.js";
|
||||||
// Handlers
|
// Handlers
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import modules from "./modules";
|
import moduleBuy from "./modules/buy";
|
||||||
|
import moduleCancel from "./modules/cancel";
|
||||||
|
|
||||||
import guildSchema from "../../../../models/guild";
|
import guildSchema from "../../../../models/guild";
|
||||||
|
|
||||||
export const moduleData = modules;
|
export default {
|
||||||
|
builder: (group: SlashCommandSubcommandGroupBuilder) => {
|
||||||
// Function
|
return (
|
||||||
export const builder = (group: SlashCommandSubcommandGroupBuilder) => {
|
group
|
||||||
return group
|
|
||||||
.setName("roles")
|
.setName("roles")
|
||||||
.setDescription("Shop for custom roles.")
|
.setDescription("Shop for custom roles.")
|
||||||
.addSubcommand(modules.buy.builder)
|
|
||||||
.addSubcommand(modules.cancel.builder);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
// Modules
|
||||||
|
.addSubcommand(moduleBuy.builder)
|
||||||
|
.addSubcommand(moduleCancel.builder)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
execute: async (interaction: ChatInputCommandInteraction) => {
|
||||||
if (!interaction.guild) return;
|
if (!interaction.guild) return;
|
||||||
const { options, guild } = interaction;
|
const { options, guild } = interaction;
|
||||||
|
|
||||||
|
@ -34,10 +36,11 @@ export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||||
throw new Error("This server has disabled shop roles.");
|
throw new Error("This server has disabled shop roles.");
|
||||||
|
|
||||||
if (options?.getSubcommand() === "buy") {
|
if (options?.getSubcommand() === "buy") {
|
||||||
await modules.buy.execute(interaction);
|
await moduleBuy.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.getSubcommand() === "cancel") {
|
if (options?.getSubcommand() === "cancel") {
|
||||||
await modules.cancel.execute(interaction);
|
await moduleCancel.execute(interaction);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
// Helpers
|
// Helpers
|
||||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
import { ChatInputCommandInteraction } from "discord.js";
|
import { ChatInputCommandInteraction } from "discord.js";
|
||||||
|
import deferReply from "../../../../../../handlers/deferReply";
|
||||||
// Configurations
|
// Configurations
|
||||||
// import fetchUser from "../../../../../../helpers/userData";
|
// import fetchUser from "../../../../../../helpers/userData";
|
||||||
// Models
|
// Models
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { guildOnly: true, ephemeral: true },
|
|
||||||
|
|
||||||
builder: (command: SlashCommandSubcommandBuilder) => {
|
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("buy")
|
.setName("buy")
|
||||||
|
@ -28,6 +27,8 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
execute: async (interaction: ChatInputCommandInteraction) => {
|
execute: async (interaction: ChatInputCommandInteraction) => {
|
||||||
|
await deferReply(interaction, true);
|
||||||
|
|
||||||
// const { successColor, footerText, footerIcon } = await getEmbedConfig(
|
// const { successColor, footerText, footerIcon } = await getEmbedConfig(
|
||||||
// interaction.guild
|
// interaction.guild
|
||||||
// );
|
// );
|
||||||
|
|
|
@ -5,11 +5,10 @@ import { ChatInputCommandInteraction } from "discord.js";
|
||||||
// Configurations
|
// Configurations
|
||||||
// import fetchUser from "../../../../../../helpers/userData";
|
// import fetchUser from "../../../../../../helpers/userData";
|
||||||
// Models
|
// Models
|
||||||
|
import deferReply from "../../../../../../handlers/deferReply";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { guildOnly: true, ephemeral: true },
|
|
||||||
|
|
||||||
builder: (command: SlashCommandSubcommandBuilder) => {
|
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("cancel")
|
.setName("cancel")
|
||||||
|
@ -22,6 +21,8 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
execute: async (interaction: ChatInputCommandInteraction) => {
|
execute: async (interaction: ChatInputCommandInteraction) => {
|
||||||
|
await deferReply(interaction, true);
|
||||||
|
|
||||||
// const { successColor, footerText, footerIcon } = await getEmbedConfig(
|
// const { successColor, footerText, footerIcon } = await getEmbedConfig(
|
||||||
// interaction.guild
|
// interaction.guild
|
||||||
// );
|
// );
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
import buy from "./buy";
|
|
||||||
import cancel from "./cancel";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
buy,
|
|
||||||
cancel,
|
|
||||||
};
|
|
Loading…
Add table
Reference in a new issue