✨ sub command custom options, such as permissions
This commit is contained in:
parent
c19264eb65
commit
112def7c53
54 changed files with 462 additions and 276 deletions
|
@ -4,16 +4,93 @@ import { CommandInteraction, MessageEmbed } from "discord.js";
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
import { errorColor, footerText, footerIcon } from "@config/embed";
|
import { errorColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
export default async (interaction: CommandInteraction) => {
|
export default async (interaction: CommandInteraction) => {
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
|
|
||||||
const { client, guild, commandName, user } = interaction;
|
const { client, guild, commandName, user, memberPermissions } = interaction;
|
||||||
|
|
||||||
const currentCommand = client.commands.get(commandName);
|
const currentCommand = client.commands.get(commandName);
|
||||||
if (!currentCommand) return;
|
if (!currentCommand) {
|
||||||
|
logger.verbose(`Command ${commandName} not found`);
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.deferReply({ ephemeral: true });
|
// logger.warn(currentCommand.modules[interaction.options.getSubcommand()].meta);
|
||||||
|
|
||||||
|
// const meta = { ephemeral: false, guildOnly: false };
|
||||||
|
|
||||||
|
let meta;
|
||||||
|
|
||||||
|
if (!interaction.options.getSubcommandGroup(false)) {
|
||||||
|
meta = currentCommand.modules[interaction.options.getSubcommand()].meta;
|
||||||
|
} else {
|
||||||
|
meta =
|
||||||
|
currentCommand.groups[interaction.options.getSubcommandGroup()].modules[
|
||||||
|
interaction.options.getSubcommand()
|
||||||
|
].meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
await interaction.deferReply({ ephemeral: meta?.ephemeral || false });
|
||||||
|
|
||||||
|
if (
|
||||||
|
meta.permissions &&
|
||||||
|
meta.guildOnly &&
|
||||||
|
!memberPermissions?.has(meta.permissions)
|
||||||
|
) {
|
||||||
|
return interaction?.editReply({
|
||||||
|
embeds: [
|
||||||
|
new MessageEmbed()
|
||||||
|
.setTitle("[:toolbox:] Manage")
|
||||||
|
.setDescription(`You do not have the permission to manage the bot.`)
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.setColor(errorColor)
|
||||||
|
.setFooter({ text: footerText, iconURL: footerIcon }),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta.guildOnly) {
|
||||||
|
if (!guild) {
|
||||||
|
logger.verbose(`Guild is null`);
|
||||||
|
|
||||||
|
return interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new MessageEmbed()
|
||||||
|
.setDescription(
|
||||||
|
i18next.t("guildOnly", {
|
||||||
|
lng: interaction.locale,
|
||||||
|
ns: "errors",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.setColor(errorColor)
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.setFooter({ text: footerText, iconURL: footerIcon }),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta.dmOnly) {
|
||||||
|
if (guild) {
|
||||||
|
logger.verbose(`Guild exist`);
|
||||||
|
|
||||||
|
return interaction.editReply({
|
||||||
|
embeds: [
|
||||||
|
new MessageEmbed()
|
||||||
|
.setDescription(
|
||||||
|
i18next.t("dmOnly", {
|
||||||
|
lng: interaction.locale,
|
||||||
|
ns: "errors",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.setColor(errorColor)
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.setFooter({ text: footerText, iconURL: footerIcon }),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await currentCommand
|
await currentCommand
|
||||||
.execute(interaction)
|
.execute(interaction)
|
||||||
|
|
|
@ -15,7 +15,11 @@ export default async (client: Client) => {
|
||||||
plugins.map(async (pluginName) => {
|
plugins.map(async (pluginName) => {
|
||||||
const plugin = await import(`../plugins/${pluginName}`);
|
const plugin = await import(`../plugins/${pluginName}`);
|
||||||
|
|
||||||
await client.commands.set(plugin.default.data.name, plugin.default);
|
await client.commands.set(
|
||||||
|
plugin.default.data.name,
|
||||||
|
plugin.default,
|
||||||
|
plugin.default.meta
|
||||||
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
// Dependencies
|
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
import modules from "@root/plugins/counters/modules";
|
import modules from "@plugins/counters/modules";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
metadata: { author: "Zyner" },
|
modules,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("counters")
|
.setName("counters")
|
||||||
.setDescription("View guild counters")
|
.setDescription("View guild counters")
|
||||||
|
|
||||||
.addSubcommand(modules.view.data),
|
.addSubcommand(modules.view.data),
|
||||||
|
|
||||||
async execute(interaction: CommandInteraction) {
|
async execute(interaction: CommandInteraction) {
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import view from "./view";
|
import view from "@plugins/counters/modules/view";
|
||||||
|
|
||||||
export default { view };
|
export default { view };
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
// Dependencies
|
|
||||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
|
||||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
|
||||||
import { ChannelType } from "discord-api-types/v10";
|
|
||||||
|
|
||||||
import counterSchema from "@schemas/counter";
|
|
||||||
|
|
||||||
// Configuration
|
|
||||||
import {
|
import {
|
||||||
errorColor,
|
errorColor,
|
||||||
successColor,
|
successColor,
|
||||||
|
@ -13,7 +5,15 @@ import {
|
||||||
footerIcon,
|
footerIcon,
|
||||||
} from "@config/embed";
|
} from "@config/embed";
|
||||||
|
|
||||||
|
import { CommandInteraction, MessageEmbed } from "discord.js";
|
||||||
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
import { ChannelType } from "discord-api-types/v10";
|
||||||
|
|
||||||
|
import counterSchema from "@schemas/counter";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: false },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("view")
|
.setName("view")
|
||||||
|
@ -28,6 +28,7 @@ export default {
|
||||||
.addChannelTypes(ChannelType.GuildText)
|
.addChannelTypes(ChannelType.GuildText)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: async (interaction: CommandInteraction) => {
|
execute: async (interaction: CommandInteraction) => {
|
||||||
const { options, guild } = interaction;
|
const { options, guild } = interaction;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import logger from "@logger";
|
||||||
import modules from "@plugins/credits/modules";
|
import modules from "@plugins/credits/modules";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
modules,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("credits")
|
.setName("credits")
|
||||||
.setDescription("Manage your credits.")
|
.setDescription("Manage your credits.")
|
||||||
|
|
|
@ -13,6 +13,7 @@ import logger from "@logger";
|
||||||
import fetchUser from "@helpers/fetchUser";
|
import fetchUser from "@helpers/fetchUser";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: true },
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("balance")
|
.setName("balance")
|
||||||
|
|
|
@ -22,6 +22,8 @@ import i18next from "i18next";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: true },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("gift")
|
.setName("gift")
|
||||||
|
|
|
@ -13,6 +13,8 @@ import logger from "@logger";
|
||||||
import userSchema, { IUser } from "@schemas/user";
|
import userSchema, { IUser } from "@schemas/user";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: false },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command.setName("top").setDescription(`View the top users`);
|
return command.setName("top").setDescription(`View the top users`);
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,6 +17,8 @@ import fetchUser from "@helpers/fetchUser";
|
||||||
import fetchGuild from "@helpers/fetchGuild";
|
import fetchGuild from "@helpers/fetchGuild";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: true },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command.setName("work").setDescription(`Work to earn credits`);
|
return command.setName("work").setDescription(`Work to earn credits`);
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,8 @@ import logger from "@logger";
|
||||||
import modules from "@plugins/fun/modules";
|
import modules from "@plugins/fun/modules";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
modules,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("fun")
|
.setName("fun")
|
||||||
.setDescription("Fun commands.")
|
.setDescription("Fun commands.")
|
||||||
|
|
|
@ -6,6 +6,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: false, ephemeral: false },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command.setName("meme").setDescription("Get a meme from r/memes)");
|
return command.setName("meme").setDescription("Get a meme from r/memes)");
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,31 +5,33 @@ import { CommandInteraction } from "discord.js";
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import moduleCreate from "./modules/create";
|
import modules from "./modules";
|
||||||
import moduleDelete from "./modules/delete";
|
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
modules,
|
||||||
|
|
||||||
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
||||||
return group
|
return group
|
||||||
.setName("counters")
|
.setName("counters")
|
||||||
.setDescription("Manage guild counters.")
|
.setDescription("Manage guild counters.")
|
||||||
.addSubcommand(moduleCreate.data)
|
.addSubcommand(modules.create.data)
|
||||||
.addSubcommand(moduleDelete.data);
|
.addSubcommand(modules.delete_.data);
|
||||||
},
|
},
|
||||||
|
|
||||||
execute: async (interaction: CommandInteraction) => {
|
execute: async (interaction: CommandInteraction) => {
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
if (options?.getSubcommand() === "create") {
|
if (options?.getSubcommand() === "create") {
|
||||||
logger?.verbose(`Executing create subcommand`);
|
logger?.verbose(`Executing create subcommand`);
|
||||||
|
|
||||||
return moduleCreate.execute(interaction);
|
return modules.create.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.getSubcommand() === "delete") {
|
if (options?.getSubcommand() === "delete") {
|
||||||
logger?.verbose(`Executing delete subcommand`);
|
logger?.verbose(`Executing delete subcommand`);
|
||||||
|
|
||||||
return moduleDelete.execute(interaction);
|
return modules.delete_.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger?.verbose(`Unknown subcommand ${options?.getSubcommand()}`);
|
logger?.verbose(`Unknown subcommand ${options?.getSubcommand()}`);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { MessageEmbed, CommandInteraction } from "discord.js";
|
import { MessageEmbed, CommandInteraction, Permissions } from "discord.js";
|
||||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
import { ChannelType } from "discord-api-types/v10";
|
import { ChannelType } from "discord-api-types/v10";
|
||||||
|
|
||||||
|
@ -19,6 +19,12 @@ import counterSchema from "@schemas/counter";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("create")
|
.setName("create")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
import { CommandInteraction, MessageEmbed, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import {
|
import {
|
||||||
|
@ -19,6 +19,12 @@ import { ChannelType } from "discord-api-types/v10";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("delete")
|
.setName("delete")
|
||||||
|
|
4
src/plugins/manage/groups/counters/modules/index.ts
Normal file
4
src/plugins/manage/groups/counters/modules/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import create from "@plugins/manage/groups/counters/modules/create";
|
||||||
|
import delete_ from "@plugins/manage/groups/counters/modules/delete";
|
||||||
|
|
||||||
|
export default { create, delete_ };
|
|
@ -1,53 +1,43 @@
|
||||||
// Dependencies
|
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
// Modules
|
import modules from "./modules";
|
||||||
import moduleGive from "./modules/give";
|
|
||||||
import moduleSet from "./modules/set";
|
|
||||||
import moduleTake from "./modules/take";
|
|
||||||
import moduleTransfer from "./modules/transfer";
|
|
||||||
|
|
||||||
// Function
|
|
||||||
export default {
|
export default {
|
||||||
|
modules,
|
||||||
|
|
||||||
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
||||||
return group
|
return group
|
||||||
.setName("credits")
|
.setName("credits")
|
||||||
.setDescription("Manage the credits of a user.")
|
.setDescription("Manage the credits of a user.")
|
||||||
.addSubcommand(moduleGive.data)
|
.addSubcommand(modules.give.data)
|
||||||
.addSubcommand(moduleSet.data)
|
.addSubcommand(modules.set.data)
|
||||||
.addSubcommand(moduleTake.data)
|
.addSubcommand(modules.take.data)
|
||||||
.addSubcommand(moduleTransfer.data);
|
.addSubcommand(modules.transfer.data);
|
||||||
},
|
},
|
||||||
execute: async (interaction: CommandInteraction) => {
|
execute: async (interaction: CommandInteraction) => {
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
if (options?.getSubcommand() === "give") {
|
switch (options.getSubcommand()) {
|
||||||
logger?.verbose(`Executing give subcommand`);
|
case "give":
|
||||||
|
logger.verbose(`Executing give subcommand`);
|
||||||
|
|
||||||
return moduleGive.execute(interaction);
|
return modules.give.execute(interaction);
|
||||||
|
case "set":
|
||||||
|
logger.verbose(`Executing set subcommand`);
|
||||||
|
|
||||||
|
return modules.set.execute(interaction);
|
||||||
|
case "take":
|
||||||
|
logger.verbose(`Executing take subcommand`);
|
||||||
|
|
||||||
|
return modules.take.execute(interaction);
|
||||||
|
case "transfer":
|
||||||
|
logger.verbose(`Executing transfer subcommand`);
|
||||||
|
|
||||||
|
return modules.transfer.execute(interaction);
|
||||||
|
default:
|
||||||
|
logger.verbose(`Unknown subcommand ${options.getSubcommand()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.getSubcommand() === "set") {
|
|
||||||
logger?.verbose(`Executing set subcommand`);
|
|
||||||
|
|
||||||
return moduleSet.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "take") {
|
|
||||||
logger?.verbose(`Executing take subcommand`);
|
|
||||||
|
|
||||||
return moduleTake.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "transfer") {
|
|
||||||
logger?.verbose(`Executing transfer subcommand`);
|
|
||||||
|
|
||||||
return moduleTransfer.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger?.verbose(`No subcommand found`);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
import { CommandInteraction, MessageEmbed, Permissions } from "discord.js";
|
||||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
|
@ -21,6 +21,12 @@ import fetchUser from "@helpers/fetchUser";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("give")
|
.setName("give")
|
||||||
|
|
6
src/plugins/manage/groups/credits/modules/index.ts
Normal file
6
src/plugins/manage/groups/credits/modules/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import give from "@plugins/manage/groups/credits/modules/give";
|
||||||
|
import set from "@plugins/manage/groups/credits/modules/set";
|
||||||
|
import take from "@plugins/manage/groups/credits/modules/take";
|
||||||
|
import transfer from "@plugins/manage/groups/credits/modules/transfer";
|
||||||
|
|
||||||
|
export default { give, set, take, transfer };
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
import { CommandInteraction, MessageEmbed, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import {
|
import {
|
||||||
|
@ -20,6 +20,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("set")
|
.setName("set")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
import { CommandInteraction, MessageEmbed, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import {
|
import {
|
||||||
|
@ -21,6 +21,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("take")
|
.setName("take")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
import { CommandInteraction, MessageEmbed, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import {
|
import {
|
||||||
|
@ -21,6 +21,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("transfer")
|
.setName("transfer")
|
||||||
|
|
4
src/plugins/manage/groups/index.ts
Normal file
4
src/plugins/manage/groups/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import counters from "@plugins/manage/groups/counters";
|
||||||
|
import credits from "@plugins/manage/groups/credits";
|
||||||
|
|
||||||
|
export default { counters, credits };
|
|
@ -6,47 +6,33 @@ import { CommandInteraction, Permissions, MessageEmbed } from "discord.js";
|
||||||
import { errorColor, footerText, footerIcon } from "@config/embed";
|
import { errorColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
|
||||||
// Groups
|
// Groups
|
||||||
import credits from "./groups/credits";
|
import groups from "@plugins/manage/groups";
|
||||||
import counters from "./groups/counters";
|
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { author: "Zyner" },
|
groups,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("manage")
|
.setName("manage")
|
||||||
.setDescription("Manage the bot.")
|
.setDescription("Manage the bot.")
|
||||||
.addSubcommandGroup(counters.data)
|
.addSubcommandGroup(groups.counters.data)
|
||||||
.addSubcommandGroup(credits.data),
|
.addSubcommandGroup(groups.credits.data),
|
||||||
|
|
||||||
async execute(interaction: CommandInteraction) {
|
async execute(interaction: CommandInteraction) {
|
||||||
// Destructure
|
// Destructure
|
||||||
const { memberPermissions, options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
// Check permission
|
|
||||||
if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) {
|
|
||||||
return interaction?.editReply({
|
|
||||||
embeds: [
|
|
||||||
new MessageEmbed()
|
|
||||||
.setTitle("[:toolbox:] Manage")
|
|
||||||
.setDescription(`You do not have the permission to manage the bot.`)
|
|
||||||
.setTimestamp(new Date())
|
|
||||||
.setColor(errorColor)
|
|
||||||
.setFooter({ text: footerText, iconURL: footerIcon }),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommandGroup() === "credits") {
|
if (options?.getSubcommandGroup() === "credits") {
|
||||||
logger?.verbose(`Subcommand group is credits`);
|
logger?.verbose(`Subcommand group is credits`);
|
||||||
|
|
||||||
return credits.execute(interaction);
|
return groups.credits.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.getSubcommandGroup() === "counters") {
|
if (options?.getSubcommandGroup() === "counters") {
|
||||||
logger?.verbose(`Subcommand group is counters`);
|
logger?.verbose(`Subcommand group is counters`);
|
||||||
|
|
||||||
return counters.execute(interaction);
|
return groups.counters.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger?.verbose(`Subcommand group is not credits or counters`);
|
logger?.verbose(`Subcommand group is not credits or counters`);
|
||||||
|
|
|
@ -3,34 +3,26 @@ import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import view from "./modules/view";
|
import modules from "@plugins/profile/modules";
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { author: "Zyner" },
|
modules,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("profile")
|
.setName("profile")
|
||||||
.setDescription("Check a profile.")
|
.setDescription("Check a profile.")
|
||||||
.addSubcommand((subcommand) =>
|
.addSubcommand(modules.view.data),
|
||||||
subcommand
|
|
||||||
.setName("view")
|
|
||||||
.setDescription("View a profile.")
|
|
||||||
.addUserOption((option) =>
|
|
||||||
option
|
|
||||||
.setName("target")
|
|
||||||
.setDescription("The profile you wish to view")
|
|
||||||
)
|
|
||||||
),
|
|
||||||
async execute(interaction: CommandInteraction) {
|
async execute(interaction: CommandInteraction) {
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
if (options?.getSubcommand() === "view") {
|
if (options?.getSubcommand() === "view") {
|
||||||
logger?.verbose(`Executing view subcommand`);
|
logger?.verbose(`Executing view subcommand`);
|
||||||
|
|
||||||
return view(interaction);
|
return modules.view.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger?.verbose(`No subcommand found`);
|
logger?.verbose(`No subcommand found`);
|
||||||
|
|
3
src/plugins/profile/modules/index.ts
Normal file
3
src/plugins/profile/modules/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import view from "@plugins/profile/modules/view";
|
||||||
|
|
||||||
|
export default { view };
|
|
@ -8,68 +8,82 @@ import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
import fetchUser from "@helpers/fetchUser";
|
import fetchUser from "@helpers/fetchUser";
|
||||||
|
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default async (interaction: CommandInteraction) => {
|
export default {
|
||||||
// Destructure
|
meta: { guildOnly: true, ephemeral: false },
|
||||||
const { client, options, user, guild } = interaction;
|
|
||||||
|
|
||||||
// Target information
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
const target = options?.getUser("target");
|
return command
|
||||||
|
.setName("view")
|
||||||
|
.setDescription("View a profile.")
|
||||||
|
.addUserOption((option) =>
|
||||||
|
option.setName("target").setDescription("The profile you wish to view")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
// Discord User Information
|
execute: async (interaction: CommandInteraction) => {
|
||||||
const discordUser = await client?.users?.fetch(
|
// Destructure
|
||||||
`${target ? target?.id : user?.id}`
|
const { client, options, user, guild } = interaction;
|
||||||
);
|
|
||||||
|
|
||||||
if (guild === null) {
|
// Target information
|
||||||
return logger?.verbose(`Guild is null`);
|
const target = options?.getUser("target");
|
||||||
}
|
|
||||||
|
|
||||||
// User Information
|
// Discord User Information
|
||||||
const userObj = await fetchUser(discordUser, guild);
|
const discordUser = await client?.users?.fetch(
|
||||||
|
`${target ? target?.id : user?.id}`
|
||||||
|
);
|
||||||
|
|
||||||
// Embed object
|
if (guild === null) {
|
||||||
const embed = {
|
return logger?.verbose(`Guild is null`);
|
||||||
author: {
|
}
|
||||||
name: `${discordUser?.username}#${discordUser?.discriminator}`,
|
|
||||||
icon_url: discordUser?.displayAvatarURL(),
|
// User Information
|
||||||
},
|
const userObj = await fetchUser(discordUser, guild);
|
||||||
color: successColor,
|
|
||||||
fields: [
|
// Embed object
|
||||||
{
|
const embed = {
|
||||||
name: `:dollar: Credits`,
|
author: {
|
||||||
value: `${userObj?.credits || "Not found"}`,
|
name: `${discordUser?.username}#${discordUser?.discriminator}`,
|
||||||
inline: true,
|
icon_url: discordUser?.displayAvatarURL(),
|
||||||
},
|
},
|
||||||
{
|
color: successColor,
|
||||||
name: `:squeeze_bottle: Level`,
|
fields: [
|
||||||
value: `${userObj?.level || "Not found"}`,
|
{
|
||||||
inline: true,
|
name: `:dollar: Credits`,
|
||||||
|
value: `${userObj?.credits || "Not found"}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `:squeeze_bottle: Level`,
|
||||||
|
value: `${userObj?.level || "Not found"}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `:squeeze_bottle: Points`,
|
||||||
|
value: `${userObj?.points || "Not found"}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `:loudspeaker: Reputation`,
|
||||||
|
value: `${userObj?.reputation || "Not found"}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `:rainbow_flag: Language`,
|
||||||
|
value: `${userObj?.language || "Not found"}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: {
|
||||||
|
iconURL: footerIcon,
|
||||||
|
text: footerText,
|
||||||
},
|
},
|
||||||
{
|
};
|
||||||
name: `:squeeze_bottle: Points`,
|
|
||||||
value: `${userObj?.points || "Not found"}`,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: `:loudspeaker: Reputation`,
|
|
||||||
value: `${userObj?.reputation || "Not found"}`,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: `:rainbow_flag: Language`,
|
|
||||||
value: `${userObj?.language || "Not found"}`,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
timestamp: new Date(),
|
|
||||||
footer: {
|
|
||||||
iconURL: footerIcon,
|
|
||||||
text: footerText,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Return interaction reply
|
// Return interaction reply
|
||||||
return interaction?.editReply({ embeds: [embed] });
|
return interaction?.editReply({ embeds: [embed] });
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,25 +3,25 @@ import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import give from "./modules/give";
|
import modules from "./modules";
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { author: "Zyner" },
|
modules,
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("reputation")
|
.setName("reputation")
|
||||||
.setDescription("Manage reputation.")
|
.setDescription("Manage reputation.")
|
||||||
.addSubcommand(give.data),
|
.addSubcommand(modules.give.data),
|
||||||
async execute(interaction: CommandInteraction) {
|
async execute(interaction: CommandInteraction) {
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
if (options?.getSubcommand() === "give") {
|
if (options?.getSubcommand() === "give") {
|
||||||
logger?.verbose(`Executing give subcommand`);
|
logger?.verbose(`Executing give subcommand`);
|
||||||
|
|
||||||
await give.execute(interaction);
|
await modules.give.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger?.verbose(`No subcommand found`);
|
logger?.verbose(`No subcommand found`);
|
||||||
|
|
|
@ -21,6 +21,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: true },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("give")
|
.setName("give")
|
||||||
|
|
3
src/plugins/reputation/modules/index.ts
Normal file
3
src/plugins/reputation/modules/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import give from "@plugins/reputation/modules/give";
|
||||||
|
|
||||||
|
export default { give };
|
63
src/plugins/settings/groups/guild/index.ts
Normal file
63
src/plugins/settings/groups/guild/index.ts
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
// Dependencies
|
||||||
|
import { Permissions, CommandInteraction } from "discord.js";
|
||||||
|
|
||||||
|
// Configurations
|
||||||
|
import { errorColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
|
||||||
|
// Handlers
|
||||||
|
import logger from "@logger";
|
||||||
|
|
||||||
|
// Modules
|
||||||
|
import modules from "./modules";
|
||||||
|
|
||||||
|
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
|
// Function
|
||||||
|
export default {
|
||||||
|
modules,
|
||||||
|
|
||||||
|
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
||||||
|
return group
|
||||||
|
.setName("guild")
|
||||||
|
.setDescription("Guild settings.")
|
||||||
|
.addSubcommand(modules.pterodactyl.data)
|
||||||
|
.addSubcommand(modules.credits.data)
|
||||||
|
.addSubcommand(modules.points.data)
|
||||||
|
.addSubcommand(modules.welcome.data)
|
||||||
|
.addSubcommand(modules.audits.data)
|
||||||
|
.addSubcommand(modules.shop.data);
|
||||||
|
},
|
||||||
|
execute: async (interaction: CommandInteraction) => {
|
||||||
|
// Destructure member
|
||||||
|
const { options } = interaction;
|
||||||
|
|
||||||
|
switch (options?.getSubcommand()) {
|
||||||
|
case "pterodactyl":
|
||||||
|
logger?.verbose(`Subcommand is pterodactyl`);
|
||||||
|
|
||||||
|
return modules.pterodactyl.execute(interaction);
|
||||||
|
case "credits":
|
||||||
|
logger?.verbose(`Subcommand is credits`);
|
||||||
|
|
||||||
|
return modules.credits.execute(interaction);
|
||||||
|
case "points":
|
||||||
|
logger?.verbose(`Subcommand is points`);
|
||||||
|
|
||||||
|
return modules.points.execute(interaction);
|
||||||
|
case "welcome":
|
||||||
|
logger?.verbose(`Subcommand is welcome`);
|
||||||
|
|
||||||
|
return modules.welcome.execute(interaction);
|
||||||
|
case "audits":
|
||||||
|
logger?.verbose(`Subcommand is audits`);
|
||||||
|
|
||||||
|
return modules.audits.execute(interaction);
|
||||||
|
case "shop":
|
||||||
|
logger?.verbose(`Subcommand is shop`);
|
||||||
|
|
||||||
|
return modules.shop.execute(interaction);
|
||||||
|
default:
|
||||||
|
logger?.verbose(`Subcommand is not found`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import { successColor, footerText, footerIcon } from "@config/embed";
|
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
@ -14,6 +14,12 @@ import { ChannelType } from "discord-api-types/v10";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("audits")
|
.setName("audits")
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import { successColor, footerText, footerIcon } from "@config/embed";
|
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
@ -13,6 +13,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("credits")
|
.setName("credits")
|
8
src/plugins/settings/groups/guild/modules/index.ts
Normal file
8
src/plugins/settings/groups/guild/modules/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import audits from "@plugins/settings/groups/guild/modules/audits";
|
||||||
|
import credits from "@plugins/settings/groups/guild/modules/credits";
|
||||||
|
import points from "@plugins/settings/groups/guild/modules/points";
|
||||||
|
import pterodactyl from "@plugins/settings/groups/guild/modules/pterodactyl";
|
||||||
|
import shop from "@plugins/settings/groups/guild/modules/shop";
|
||||||
|
import welcome from "@plugins/settings/groups/guild/modules/welcome";
|
||||||
|
|
||||||
|
export default { audits, credits, points, pterodactyl, shop, welcome };
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import { successColor, footerText, footerIcon } from "@config/embed";
|
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
@ -13,6 +13,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("points")
|
.setName("points")
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import { successColor, footerText, footerIcon } from "@config/embed";
|
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
@ -14,6 +14,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("pterodactyl")
|
.setName("pterodactyl")
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import { successColor, footerText, footerIcon } from "@config/embed";
|
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
@ -13,6 +13,12 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("shop")
|
.setName("shop")
|
|
@ -1,5 +1,5 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction, Permissions } from "discord.js";
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
import { successColor, footerText, footerIcon } from "@config/embed";
|
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
@ -14,6 +14,12 @@ import { ChannelType } from "discord-api-types/v10";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: {
|
||||||
|
guildOnly: true,
|
||||||
|
ephemeral: true,
|
||||||
|
permissions: [Permissions.FLAGS.MANAGE_GUILD],
|
||||||
|
},
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("welcome")
|
.setName("welcome")
|
3
src/plugins/settings/groups/index.ts
Normal file
3
src/plugins/settings/groups/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import guild from "@plugins/settings/groups/guild";
|
||||||
|
|
||||||
|
export default { guild };
|
|
@ -1,94 +0,0 @@
|
||||||
// Dependencies
|
|
||||||
import { Permissions, CommandInteraction } from "discord.js";
|
|
||||||
|
|
||||||
// Configurations
|
|
||||||
import { errorColor, footerText, footerIcon } from "@config/embed";
|
|
||||||
|
|
||||||
// Handlers
|
|
||||||
import logger from "@logger";
|
|
||||||
|
|
||||||
// Modules
|
|
||||||
import pterodactyl from "./modules/pterodactyl";
|
|
||||||
import credits from "./modules/credits";
|
|
||||||
import points from "./modules/points";
|
|
||||||
import welcome from "./modules/welcome";
|
|
||||||
import audits from "./modules/audits";
|
|
||||||
import shop from "./modules/shop";
|
|
||||||
import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
|
||||||
|
|
||||||
// Function
|
|
||||||
export default {
|
|
||||||
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
|
||||||
return group
|
|
||||||
.setName("guild")
|
|
||||||
.setDescription("Guild settings.")
|
|
||||||
.addSubcommand(pterodactyl.data)
|
|
||||||
.addSubcommand(credits.data)
|
|
||||||
.addSubcommand(points.data)
|
|
||||||
.addSubcommand(welcome.data)
|
|
||||||
.addSubcommand(audits.data)
|
|
||||||
.addSubcommand(shop.data);
|
|
||||||
},
|
|
||||||
execute: async (interaction: CommandInteraction) => {
|
|
||||||
// Destructure member
|
|
||||||
const { memberPermissions, options } = interaction;
|
|
||||||
|
|
||||||
// Check permission
|
|
||||||
if (!memberPermissions?.has(Permissions?.FLAGS?.MANAGE_GUILD)) {
|
|
||||||
logger?.verbose(`User does not have permission to execute command.`);
|
|
||||||
|
|
||||||
return interaction?.editReply({
|
|
||||||
embeds: [
|
|
||||||
{
|
|
||||||
title: ":tools: Settings - Guild",
|
|
||||||
color: errorColor,
|
|
||||||
description: "You do not have permission to use this command.",
|
|
||||||
timestamp: new Date(),
|
|
||||||
footer: {
|
|
||||||
iconURL: footerIcon as string,
|
|
||||||
text: footerText as string,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "pterodactyl") {
|
|
||||||
logger?.verbose(`Executing pterodactyl subcommand`);
|
|
||||||
|
|
||||||
return pterodactyl.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "credits") {
|
|
||||||
logger?.verbose(`Executing credits subcommand`);
|
|
||||||
|
|
||||||
return credits.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "points") {
|
|
||||||
logger?.verbose(`Executing points subcommand`);
|
|
||||||
|
|
||||||
return points.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "welcome") {
|
|
||||||
logger?.verbose(`Executing welcome subcommand`);
|
|
||||||
|
|
||||||
return welcome.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "audits") {
|
|
||||||
logger?.verbose(`Executing audit subcommand`);
|
|
||||||
|
|
||||||
return audits.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.getSubcommand() === "shop") {
|
|
||||||
logger?.verbose(`Executing shop subcommand`);
|
|
||||||
|
|
||||||
return shop.execute(interaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger?.verbose(`No subcommand found`);
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -3,19 +3,20 @@ import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
|
|
||||||
// Groups
|
// Groups
|
||||||
import guildGroup from "./guild";
|
import groups from "./groups";
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
import logger from "@logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { author: "Zyner" },
|
groups,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("settings")
|
.setName("settings")
|
||||||
.setDescription("Manage settings.")
|
.setDescription("Manage settings.")
|
||||||
|
|
||||||
.addSubcommandGroup(guildGroup.data),
|
.addSubcommandGroup(groups.guild.data),
|
||||||
|
|
||||||
async execute(interaction: CommandInteraction) {
|
async execute(interaction: CommandInteraction) {
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
@ -23,7 +24,7 @@ export default {
|
||||||
if (options.getSubcommandGroup() === "guild") {
|
if (options.getSubcommandGroup() === "guild") {
|
||||||
logger.verbose(`Executing guild subcommand`);
|
logger.verbose(`Executing guild subcommand`);
|
||||||
|
|
||||||
return guildGroup.execute(interaction);
|
return groups.guild.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.verbose(`No subcommand group found`);
|
logger.verbose(`No subcommand group found`);
|
||||||
|
|
3
src/plugins/shop/groups/index.ts
Normal file
3
src/plugins/shop/groups/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import roles from "./roles";
|
||||||
|
|
||||||
|
export default { roles };
|
|
@ -3,24 +3,25 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
import logger from "../../../logger";
|
import logger from "@logger";
|
||||||
|
|
||||||
import { errorColor, footerText, footerIcon } from "@config/embed";
|
import { errorColor, footerText, footerIcon } from "@config/embed";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import buy from "./modules/buy";
|
import modules from "./modules";
|
||||||
import cancel from "./modules/cancel";
|
|
||||||
|
|
||||||
import guildSchema from "@schemas/guild";
|
import guildSchema from "@schemas/guild";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
modules,
|
||||||
|
|
||||||
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
data: (group: SlashCommandSubcommandGroupBuilder) => {
|
||||||
return group
|
return group
|
||||||
.setName("roles")
|
.setName("roles")
|
||||||
.setDescription("Shop for custom roles.")
|
.setDescription("Shop for custom roles.")
|
||||||
.addSubcommand(buy.data)
|
.addSubcommand(modules.buy.data)
|
||||||
.addSubcommand(cancel.data);
|
.addSubcommand(modules.cancel.data);
|
||||||
},
|
},
|
||||||
execute: async (interaction: CommandInteraction) => {
|
execute: async (interaction: CommandInteraction) => {
|
||||||
const { options, guild } = interaction;
|
const { options, guild } = interaction;
|
||||||
|
@ -53,13 +54,13 @@ export default {
|
||||||
if (options?.getSubcommand() === "buy") {
|
if (options?.getSubcommand() === "buy") {
|
||||||
logger.verbose(`Executing buy subcommand`);
|
logger.verbose(`Executing buy subcommand`);
|
||||||
|
|
||||||
await buy.execute(interaction);
|
await modules.buy.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.getSubcommand() === "cancel") {
|
if (options?.getSubcommand() === "cancel") {
|
||||||
logger.verbose(`Executing cancel subcommand`);
|
logger.verbose(`Executing cancel subcommand`);
|
||||||
|
|
||||||
await cancel.execute(interaction);
|
await modules.cancel.execute(interaction);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -25,6 +25,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: true },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("buy")
|
.setName("buy")
|
|
@ -20,6 +20,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: true },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("cancel")
|
.setName("cancel")
|
7
src/plugins/shop/groups/roles/modules/index.ts
Normal file
7
src/plugins/shop/groups/roles/modules/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import buy from "./buy";
|
||||||
|
import cancel from "./cancel";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
buy,
|
||||||
|
cancel,
|
||||||
|
};
|
|
@ -3,35 +3,37 @@ import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import pterodactyl from "./modules/pterodactyl";
|
import modules from "./modules";
|
||||||
|
|
||||||
// Groups
|
// Groups
|
||||||
import roles from "./roles";
|
import groups from "./groups";
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
import logger from "../../logger";
|
import logger from "../../logger";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { author: "Zyner" },
|
modules,
|
||||||
|
groups,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("shop")
|
.setName("shop")
|
||||||
.setDescription("Shop for credits and custom roles.")
|
.setDescription("Shop for credits and custom roles.")
|
||||||
.addSubcommand(pterodactyl.data)
|
.addSubcommand(modules.pterodactyl.data)
|
||||||
.addSubcommandGroup(roles.data),
|
.addSubcommandGroup(groups.roles.data),
|
||||||
async execute(interaction: CommandInteraction) {
|
async execute(interaction: CommandInteraction) {
|
||||||
const { options } = interaction;
|
const { options } = interaction;
|
||||||
|
|
||||||
if (options?.getSubcommand() === "pterodactyl") {
|
if (options?.getSubcommand() === "pterodactyl") {
|
||||||
logger.verbose(`Executing pterodactyl subcommand`);
|
logger.verbose(`Executing pterodactyl subcommand`);
|
||||||
|
|
||||||
return pterodactyl.execute(interaction);
|
return modules.pterodactyl.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.getSubcommandGroup() === "roles") {
|
if (options?.getSubcommandGroup() === "roles") {
|
||||||
logger?.verbose(`Subcommand group is roles`);
|
logger?.verbose(`Subcommand group is roles`);
|
||||||
|
|
||||||
return roles.execute(interaction);
|
return groups.roles.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger?.verbose(`No subcommand found.`);
|
logger?.verbose(`No subcommand found.`);
|
||||||
|
|
3
src/plugins/shop/modules/index.ts
Normal file
3
src/plugins/shop/modules/index.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import pterodactyl from "@plugins/shop/modules/pterodactyl";
|
||||||
|
|
||||||
|
export default { pterodactyl };
|
|
@ -25,6 +25,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: true, ephemeral: true },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("pterodactyl")
|
.setName("pterodactyl")
|
||||||
|
|
|
@ -10,7 +10,8 @@ import logger from "../../logger";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
metadata: { author: "Zyner" },
|
modules,
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("utility")
|
.setName("utility")
|
||||||
.setDescription("Common utility.")
|
.setDescription("Common utility.")
|
||||||
|
|
|
@ -9,6 +9,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: false, ephemeral: false },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command.setName("about").setDescription("About this bot!)");
|
return command.setName("about").setDescription("About this bot!)");
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,8 @@ import { CommandInteraction, MessageEmbed } from "discord.js";
|
||||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: false, ephemeral: false },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("avatar")
|
.setName("avatar")
|
||||||
|
|
|
@ -17,6 +17,8 @@ import logger from "@logger";
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: false, ephemeral: false },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command
|
return command
|
||||||
.setName("lookup")
|
.setName("lookup")
|
||||||
|
|
|
@ -2,6 +2,8 @@ import { successColor, footerText, footerIcon } from "@config/embed";
|
||||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
export default {
|
export default {
|
||||||
|
meta: { guildOnly: false, ephemeral: false },
|
||||||
|
|
||||||
data: (command: SlashCommandSubcommandBuilder) => {
|
data: (command: SlashCommandSubcommandBuilder) => {
|
||||||
return command.setName("stats").setDescription("Check bot statistics!)");
|
return command.setName("stats").setDescription("Check bot statistics!)");
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue