commit
58e054bbe5
5 changed files with 130 additions and 4 deletions
|
@ -65,7 +65,7 @@ const guildSchema = new Schema<IGuild>(
|
||||||
roles: {
|
roles: {
|
||||||
status: {
|
status: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: false,
|
||||||
},
|
},
|
||||||
pricePerHour: {
|
pricePerHour: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import modules from "@events/messageCreate/modules";
|
||||||
export default {
|
export default {
|
||||||
name: "messageCreate",
|
name: "messageCreate",
|
||||||
async execute(message: Message) {
|
async execute(message: Message) {
|
||||||
await modules.counters.execute(message);
|
await modules.credits.execute(message);
|
||||||
await modules.points.execute(message);
|
await modules.points.execute(message);
|
||||||
await modules.counters.execute(message);
|
await modules.counters.execute(message);
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,6 +13,7 @@ import credits from "./modules/credits";
|
||||||
import points from "./modules/points";
|
import points from "./modules/points";
|
||||||
import welcome from "./modules/welcome";
|
import welcome from "./modules/welcome";
|
||||||
import audits from "./modules/audits";
|
import audits from "./modules/audits";
|
||||||
|
import shop from "./modules/shop";
|
||||||
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
|
@ -25,7 +26,8 @@ export default {
|
||||||
.addSubcommand(credits.data)
|
.addSubcommand(credits.data)
|
||||||
.addSubcommand(points.data)
|
.addSubcommand(points.data)
|
||||||
.addSubcommand(welcome.data)
|
.addSubcommand(welcome.data)
|
||||||
.addSubcommand(audits.data);
|
.addSubcommand(audits.data)
|
||||||
|
.addSubcommand(shop.data);
|
||||||
},
|
},
|
||||||
execute: async (interaction: CommandInteraction) => {
|
execute: async (interaction: CommandInteraction) => {
|
||||||
// Destructure member
|
// Destructure member
|
||||||
|
@ -81,6 +83,12 @@ export default {
|
||||||
return audits.execute(interaction);
|
return audits.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options?.getSubcommand() === "shop") {
|
||||||
|
logger?.verbose(`Executing shop subcommand`);
|
||||||
|
|
||||||
|
return shop.execute(interaction);
|
||||||
|
}
|
||||||
|
|
||||||
logger?.verbose(`No subcommand found`);
|
logger?.verbose(`No subcommand found`);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
89
src/plugins/settings/guild/modules/shop.ts
Normal file
89
src/plugins/settings/guild/modules/shop.ts
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
// Dependencies
|
||||||
|
import { CommandInteraction } from "discord.js";
|
||||||
|
|
||||||
|
// Configurations
|
||||||
|
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
|
||||||
|
// Handlers
|
||||||
|
import logger from "@logger";
|
||||||
|
|
||||||
|
// Models
|
||||||
|
import guildSchema from "@schemas/guild";
|
||||||
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
import { ChannelType } from "discord-api-types/v10";
|
||||||
|
|
||||||
|
// Function
|
||||||
|
export default {
|
||||||
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
|
return command
|
||||||
|
.setName("shop")
|
||||||
|
.setDescription("Shop")
|
||||||
|
.addBooleanOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("roles-status")
|
||||||
|
.setDescription("Should roles be enabled?")
|
||||||
|
)
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("roles-price-per-hour")
|
||||||
|
.setDescription("Price per hour for roles.")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
execute: async (interaction: CommandInteraction) => {
|
||||||
|
// Destructure member
|
||||||
|
const { options, guild } = interaction;
|
||||||
|
|
||||||
|
// Get options
|
||||||
|
const rolesStatus = options?.getBoolean("roles-status");
|
||||||
|
const rolesPricePerHour = options?.getNumber("roles-price-per-hour");
|
||||||
|
|
||||||
|
// Get guild object
|
||||||
|
const guildDB = await guildSchema?.findOne({
|
||||||
|
guildId: guild?.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (guildDB === null) {
|
||||||
|
return logger?.verbose(`Guild not found in database.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify values
|
||||||
|
guildDB.shop.roles.status =
|
||||||
|
rolesStatus !== null ? rolesStatus : guildDB?.shop?.roles?.status;
|
||||||
|
guildDB.shop.roles.pricePerHour =
|
||||||
|
rolesPricePerHour !== null
|
||||||
|
? rolesPricePerHour
|
||||||
|
: guildDB?.shop?.roles?.pricePerHour;
|
||||||
|
|
||||||
|
// Save guild
|
||||||
|
await guildDB?.save()?.then(async () => {
|
||||||
|
logger?.verbose(`Guild shop updated.`);
|
||||||
|
|
||||||
|
return interaction?.editReply({
|
||||||
|
embeds: [
|
||||||
|
{
|
||||||
|
title: ":hammer: Settings - Guild [Shop]",
|
||||||
|
description: `Shop settings updated.`,
|
||||||
|
color: successColor,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "🤖 Roles Status",
|
||||||
|
value: `${guildDB?.shop?.roles.status}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "🌊 Roles Price Per Hour",
|
||||||
|
value: `${guildDB?.shop?.roles.pricePerHour}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: {
|
||||||
|
iconURL: footerIcon,
|
||||||
|
text: footerText,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
|
@ -5,10 +5,14 @@ import { CommandInteraction } from "discord.js";
|
||||||
// Handlers
|
// Handlers
|
||||||
import logger from "../../../logger";
|
import logger from "../../../logger";
|
||||||
|
|
||||||
|
import { errorColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import buy from "./modules/buy";
|
import buy from "./modules/buy";
|
||||||
import cancel from "./modules/cancel";
|
import cancel from "./modules/cancel";
|
||||||
|
|
||||||
|
import guildSchema from "@schemas/guild";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
||||||
|
@ -19,7 +23,32 @@ export default {
|
||||||
.addSubcommand(cancel.data);
|
.addSubcommand(cancel.data);
|
||||||
},
|
},
|
||||||
execute: async (interaction: CommandInteraction) => {
|
execute: async (interaction: CommandInteraction) => {
|
||||||
const { options } = interaction;
|
const { options, guild } = interaction;
|
||||||
|
|
||||||
|
const guildDB = await guildSchema?.findOne({
|
||||||
|
guildId: guild?.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (guildDB === null) return;
|
||||||
|
|
||||||
|
if (!guildDB.shop.roles.status) {
|
||||||
|
logger.verbose(`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 (options?.getSubcommand() === "buy") {
|
if (options?.getSubcommand() === "buy") {
|
||||||
logger.verbose(`Executing buy subcommand`);
|
logger.verbose(`Executing buy subcommand`);
|
||||||
|
|
Loading…
Add table
Reference in a new issue