chore: Update JavaScript plugins (#69)

chore: update JavaScript plugins

Co-authored-by: EvolutionX-10 <EvolutionX-10@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2023-01-28 23:47:35 +05:30
committed by GitHub
parent 98ab449203
commit b2ee0996f1
24 changed files with 876 additions and 917 deletions

View File

@@ -29,30 +29,35 @@
import { CommandControlPlugin, CommandType, controller } from "@sern/handler";
import type { ModalSubmitInteraction } from "discord.js";
type Assertion =
| RegExp
| ((value : string) => boolean);
type Assertion = RegExp | ((value: string) => boolean);
export function assertFields(config: {
fields: Record<string, Assertion>,
failure: (errors: string[], interaction: ModalSubmitInteraction) => any
fields: Record<string, Assertion>;
failure: (errors: string[], interaction: ModalSubmitInteraction) => any;
}) {
return CommandControlPlugin<CommandType.Modal>(modal => {
const pairs = Object.entries(config.fields);
const errors = [];
for(const [ field, assertion ] of pairs) {
// Keep in mind this doesn't check for typos!
// feel free to add more checks.
const input = modal.fields.getTextInputValue(field)
const resolvedAssertion = assertion instanceof RegExp ? (value: string) => assertion.test(value) : assertion;
if(!resolvedAssertion(input)) {
errors.push(input + " failed to pass assertion " + resolvedAssertion.toString() )
}
}
if(errors.length > 0) {
config.failure(errors, modal);
return controller.stop();
}
return controller.next();
})
}
return CommandControlPlugin<CommandType.Modal>((modal) => {
const pairs = Object.entries(config.fields);
const errors = [];
for (const [field, assertion] of pairs) {
// Keep in mind this doesn't check for typos!
// feel free to add more checks.
const input = modal.fields.getTextInputValue(field);
const resolvedAssertion =
assertion instanceof RegExp
? (value: string) => assertion.test(value)
: assertion;
if (!resolvedAssertion(input)) {
errors.push(
input +
" failed to pass assertion " +
resolvedAssertion.toString()
);
}
}
if (errors.length > 0) {
config.failure(errors, modal);
return controller.stop();
}
return controller.next();
});
}

View File

@@ -19,91 +19,84 @@
* ```
*/
import {CommandControlPlugin, CommandType, controller} from "@sern/handler";
import { CommandControlPlugin, CommandType, controller } from "@sern/handler";
import {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
ComponentType,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
ComponentType,
} from "discord.js";
export function confirmation(
options?: Partial<ConfirmationOptions>
) {
return CommandControlPlugin<CommandType.Both>(async (ctx, args) => {
options = {
content: "Do you want to proceed?",
denialMessage: "Cancelled",
labels: ["No", "Yes"],
time: 60_000,
wrongUserResponse: "Not for you!",
...options,
};
export function confirmation(options?: Partial<ConfirmationOptions>) {
return CommandControlPlugin<CommandType.Both>(async (ctx, args) => {
options = {
content: "Do you want to proceed?",
denialMessage: "Cancelled",
labels: ["No", "Yes"],
time: 60_000,
wrongUserResponse: "Not for you!",
...options,
};
const buttons = options.labels!.map((l, i) => {
return new ButtonBuilder()
.setCustomId(l)
.setLabel(l)
.setStyle(
i === 0 ? ButtonStyle.Danger : ButtonStyle.Success
);
});
const sent = await ctx.reply({
content: options.content,
components: [
new ActionRowBuilder<ButtonBuilder>().setComponents(
buttons
),
],
});
const buttons = options.labels!.map((l, i) => {
return new ButtonBuilder()
.setCustomId(l)
.setLabel(l)
.setStyle(i === 0 ? ButtonStyle.Danger : ButtonStyle.Success);
});
const sent = await ctx.reply({
content: options.content,
components: [
new ActionRowBuilder<ButtonBuilder>().setComponents(buttons),
],
});
const collector = sent.createMessageComponentCollector({
componentType: ComponentType.Button,
filter: (i) => i.user.id === ctx.user.id,
time: options.time,
});
const collector = sent.createMessageComponentCollector({
componentType: ComponentType.Button,
filter: (i) => i.user.id === ctx.user.id,
time: options.time,
});
return new Promise((resolve) => {
collector.on("collect", async (i) => {
await i.update({ components: [] });
collector.stop();
if (i.customId === options!.labels![1]) {
resolve(controller.next());
return;
}
await i.editReply({
content: options?.denialMessage,
});
resolve(controller.stop());
});
return new Promise((resolve) => {
collector.on("collect", async (i) => {
await i.update({ components: [] });
collector.stop();
if (i.customId === options!.labels![1]) {
resolve(controller.next());
return;
}
await i.editReply({
content: options?.denialMessage,
});
resolve(controller.stop());
});
collector.on("end", async (c) => {
if (c.size) return;
buttons.forEach((b) => b.setDisabled());
await sent.edit({
components: [
new ActionRowBuilder<ButtonBuilder>().setComponents(
buttons
),
],
});
});
collector.on("end", async (c) => {
if (c.size) return;
buttons.forEach((b) => b.setDisabled());
await sent.edit({
components: [
new ActionRowBuilder<ButtonBuilder>().setComponents(
buttons
),
],
});
});
collector.on("ignore", async (i) => {
await i.reply({
content: options?.wrongUserResponse,
ephemeral: true,
});
});
});
});
collector.on("ignore", async (i) => {
await i.reply({
content: options?.wrongUserResponse,
ephemeral: true,
});
});
});
});
}
interface ConfirmationOptions {
content: string;
denialMessage: string;
time: number;
labels: [string, string];
wrongUserResponse: string;
content: string;
denialMessage: string;
time: number;
labels: [string, string];
wrongUserResponse: string;
}

View File

@@ -18,23 +18,20 @@
* ```
*/
import { ChannelType } from "discord.js";
import {CommandControlPlugin, CommandType, controller } from "@sern/handler";
export function channelType(
channelType: ChannelType[],
onFail?: string
){
return CommandControlPlugin<CommandType.Both>(async (ctx, args) => {
let channel = ctx.channel?.type;
//for some reason the dm channel type was returning undefined at some points
if (channel === undefined) {
channel = ChannelType.DM;
}
if (channelType.includes(channel)) {
return controller.next();
}
if (onFail) {
await ctx.reply(onFail);
}
return controller.stop();
})
}
import { CommandControlPlugin, CommandType, controller } from "@sern/handler";
export function channelType(channelType: ChannelType[], onFail?: string) {
return CommandControlPlugin<CommandType.Both>(async (ctx, args) => {
let channel = ctx.channel?.type;
//for some reason the dm channel type was returning undefined at some points
if (channel === undefined) {
channel = ChannelType.DM;
}
if (channelType.includes(channel)) {
return controller.next();
}
if (onFail) {
await ctx.reply(onFail);
}
return controller.stop();
});
}

View File

@@ -20,7 +20,12 @@
* ```
*/
import {CommandControlPlugin, CommandType, Context, controller } from "@sern/handler";
import {
CommandControlPlugin,
CommandType,
Context,
controller,
} from "@sern/handler";
import type { Awaitable, Message, MessageReaction, User } from "discord.js";
type Callback<T> = Awaitable<T> | ((context: Context) => Awaitable<T>);
@@ -58,76 +63,73 @@ const defaultOptions: ConfirmationOptions = {
},
};
export function confirmation(
raw: Partial<ConfirmationOptions> = {}
) {
export function confirmation(raw: Partial<ConfirmationOptions> = {}) {
const options: ConfirmationOptions = Object.assign({}, defaultOptions, raw);
return CommandControlPlugin<CommandType.Both>(async (context, _) => {
if (typeof options.message === "function") {
options.message = await options.message(context);
if (typeof options.message === "function") {
options.message = await options.message(context);
}
const response = await context.reply(await options.message);
let { yes, no } = options.emojis;
if (typeof yes === "function") {
yes = await yes(context);
}
if (typeof no === "function") {
no = await no(context);
}
await response.react(await yes);
await response.react(await no);
function filter(reaction: MessageReaction, user: User) {
return (
([yes, no].includes(reaction.emoji.name!) ||
[yes, no].includes(reaction.emoji.identifier)) &&
user.id === context.user.id
);
}
const recieved = await response.awaitReactions({
filter,
max: 1,
time: options.timeout,
});
if (recieved.size === 0) {
if (typeof options.onTimeout === "function") {
await options.onTimeout(context, response);
} else {
await response.edit(await options.onTimeout);
await response.reactions.removeAll();
}
return controller.stop();
}
const reaction = recieved.first();
if (!reaction) {
return controller.stop();
}
const response = await context.reply(await options.message);
let {yes, no} = options.emojis;
if (typeof yes === "function") {
yes = await yes(context);
}
if (typeof no === "function") {
no = await no(context);
}
await response.react(await yes);
await response.react(await no);
function filter(reaction: MessageReaction, user: User) {
return (
([yes, no].includes(reaction.emoji.name!) ||
[yes, no].includes(reaction.emoji.identifier)) &&
user.id === context.user.id
);
}
const recieved = await response.awaitReactions({
filter,
max: 1,
time: options.timeout,
});
if (recieved.size === 0) {
if (typeof options.onTimeout === "function") {
await options.onTimeout(context, response);
switch (reaction.emoji.name) {
case await yes:
if (typeof options.onConfirm === "function") {
await options.onConfirm(context, response);
} else {
await response.edit(await options.onTimeout);
await response.edit(await options.onConfirm);
await response.reactions.removeAll();
}
return controller.next();
case await no:
if (typeof options.onCancel === "function") {
await options.onCancel(context, response);
} else {
await response.edit(await options.onCancel);
await response.reactions.removeAll();
}
return controller.stop();
}
const reaction = recieved.first();
if (!reaction) {
return controller.stop();
}
switch (reaction.emoji.name) {
case await yes:
if (typeof options.onConfirm === "function") {
await options.onConfirm(context, response);
} else {
await response.edit(await options.onConfirm);
await response.reactions.removeAll();
}
return controller.next();
case await no:
if (typeof options.onCancel === "function") {
await options.onCancel(context, response);
} else {
await response.edit(await options.onCancel);
await response.reactions.removeAll();
}
return controller.stop();
}
return controller.next()
}
)
return controller.next();
});
}

View File

@@ -17,7 +17,12 @@
* ```
*/
import {CommandControlPlugin, CommandType, Context, controller } from "@sern/handler";
import {
CommandControlPlugin,
CommandType,
Context,
controller,
} from "@sern/handler";
import { GuildMember } from "discord.js";
/**
* actions/seconds

View File

@@ -16,16 +16,13 @@
* })
* ```
*/
import {CommandControlPlugin, CommandType, controller } from "@sern/handler";
export function dmOnly(
content?: string,
ephemeral?: boolean
) {
// For discord.js you should have the Partials.Channel and DirectMessages intent enabled.
return CommandControlPlugin<CommandType.Both>(async (ctx, _) => {
if (ctx.channel?.isDMBased()) return controller.next();
import { CommandControlPlugin, CommandType, controller } from "@sern/handler";
export function dmOnly(content?: string, ephemeral?: boolean) {
// For discord.js you should have the Partials.Channel and DirectMessages intent enabled.
return CommandControlPlugin<CommandType.Both>(async (ctx, _) => {
if (ctx.channel?.isDMBased()) return controller.next();
if (content) await ctx.reply({ content, ephemeral }); // Change this if you want or remove it for silent deny
return controller.stop();
})
if (content) await ctx.reply({ content, ephemeral }); // Change this if you want or remove it for silent deny
return controller.stop();
});
}

View File

@@ -17,40 +17,37 @@
* ```
*/
import {
ChannelType,
GuildTextBasedChannel,
TextBasedChannel,
TextChannel,
ChannelType,
GuildTextBasedChannel,
TextBasedChannel,
TextChannel,
} from "discord.js";
import {CommandControlPlugin, CommandType, controller } from "@sern/handler";
import { CommandControlPlugin, CommandType, controller } from "@sern/handler";
function isGuildText(
channel: TextBasedChannel | null
channel: TextBasedChannel | null
): channel is GuildTextBasedChannel {
return (
channel?.type == ChannelType.GuildPublicThread ||
channel?.type == ChannelType.GuildPrivateThread
);
return (
channel?.type == ChannelType.GuildPublicThread ||
channel?.type == ChannelType.GuildPrivateThread
);
}
export function nsfwOnly(
onFail: string,
ephemeral: boolean
) {
return CommandControlPlugin<CommandType.Both>(async (ctx, _) => {
if (ctx.guild === null) {
await ctx.reply({ content: onFail, ephemeral });
return controller.stop();
}
//channel is thread (not supported by nsfw)
if (isGuildText(ctx.channel) == true) {
await ctx.reply({ content: onFail, ephemeral });
return controller.stop();
}
if (!(ctx.channel! as TextChannel).nsfw) {
//channel is not nsfw
await ctx.reply({ content: onFail, ephemeral });
return controller.stop();
}
//continues to command if nsfw
return controller.next();
});
export function nsfwOnly(onFail: string, ephemeral: boolean) {
return CommandControlPlugin<CommandType.Both>(async (ctx, _) => {
if (ctx.guild === null) {
await ctx.reply({ content: onFail, ephemeral });
return controller.stop();
}
//channel is thread (not supported by nsfw)
if (isGuildText(ctx.channel) == true) {
await ctx.reply({ content: onFail, ephemeral });
return controller.stop();
}
if (!(ctx.channel! as TextChannel).nsfw) {
//channel is not nsfw
await ctx.reply({ content: onFail, ephemeral });
return controller.stop();
}
//continues to command if nsfw
return controller.next();
});
}

View File

@@ -20,10 +20,10 @@
import { CommandType, CommandControlPlugin, controller } from "@sern/handler";
const ownerIDs = ["697795666373640213"]; //! Fill your ID
export function ownerOnly() {
return CommandControlPlugin<CommandType.Both>((ctx,args) => {
return CommandControlPlugin<CommandType.Both>((ctx, args) => {
if (ownerIDs.includes(ctx.user.id)) return controller.next();
//* If you want to reply when the command fails due to user not being owner, you can use following
// await ctx.reply("Only owner can run it!!!");
return controller.stop(); //! Important: It stops the execution of command!
})
});
}

View File

@@ -18,11 +18,8 @@
*/
import type { GuildMember, PermissionResolvable } from "discord.js";
import {CommandControlPlugin, CommandType, controller } from "@sern/handler";
export function permCheck(
perm: PermissionResolvable,
response: string
) {
import { CommandControlPlugin, CommandType, controller } from "@sern/handler";
export function permCheck(perm: PermissionResolvable, response: string) {
return CommandControlPlugin<CommandType.Both>(async (ctx, args) => {
if (ctx.guild === null) {
await ctx.reply("This command cannot be used here");
@@ -36,5 +33,5 @@ export function permCheck(
return controller.stop();
}
return controller.next();
})
});
}

View File

@@ -17,184 +17,180 @@
* })
* ```
*/
import {CommandInitPlugin, CommandType, controller, SernOptionsData, SlashCommand} from '@sern/handler'
import {ApplicationCommandData, ApplicationCommandType, PermissionResolvable} from "discord.js";
import {useContainer} from "../index.js";
import {
CommandInitPlugin,
CommandType,
controller,
SernOptionsData,
SlashCommand,
} from "@sern/handler";
import {
ApplicationCommandData,
ApplicationCommandType,
PermissionResolvable,
} from "discord.js";
import { useContainer } from "../index.js";
export const CommandTypeRaw = {
[CommandType.Both]: ApplicationCommandType.ChatInput,
[CommandType.CtxUser]: ApplicationCommandType.Message,
[CommandType.CtxMsg]: ApplicationCommandType.User,
[CommandType.Slash]: ApplicationCommandType.ChatInput,
[CommandType.Both]: ApplicationCommandType.ChatInput,
[CommandType.CtxUser]: ApplicationCommandType.Message,
[CommandType.CtxMsg]: ApplicationCommandType.User,
[CommandType.Slash]: ApplicationCommandType.ChatInput,
} as const;
export function publish<T extends
| CommandType.Both
| CommandType.Slash
| CommandType.CtxMsg
| CommandType.CtxUser
>(
options?: PublishOptions
) {
return CommandInitPlugin<T>(async ({ module }) => {
// Users need to provide their own useContainer function.
const [client] = useContainer("@sern/client");
const defaultOptions = {
guildIds: [],
dmPermission: undefined,
defaultMemberPermissions: null,
};
export function publish<
T extends
| CommandType.Both
| CommandType.Slash
| CommandType.CtxMsg
| CommandType.CtxUser
>(options?: PublishOptions) {
return CommandInitPlugin<T>(async ({ module }) => {
// Users need to provide their own useContainer function.
const [client] = useContainer("@sern/client");
const defaultOptions = {
guildIds: [],
dmPermission: undefined,
defaultMemberPermissions: null,
};
options = {...defaultOptions, ...options} as PublishOptions &
ValidPublishOptions;
let {defaultMemberPermissions, dmPermission, guildIds} =
options as unknown as ValidPublishOptions;
options = { ...defaultOptions, ...options } as PublishOptions &
ValidPublishOptions;
let { defaultMemberPermissions, dmPermission, guildIds } =
options as unknown as ValidPublishOptions;
function c(e: unknown) {
console.error("publish command didnt work for", module.name);
console.error(e);
}
function c(e: unknown) {
console.error("publish command didnt work for", module.name);
console.error(e);
}
const log =
(...message: any[]) =>
() =>
console.log(...message);
const logged = (...message: any[]) => log(message);
/**
* a local function that returns either one value or the other,
* depending on {t}'s CommandType. If the commandtype of
* this module is CommandType.Both or CommandType.Text or CommandType.Slash,
* return 'is', else return 'els'
* @param t
* @returns S | T
*/
const appCmd = <V extends CommandType, S, T>(t: V) => {
return (is: S, els: T) =>
(t & CommandType.Both) !== 0 ? is : els;
};
const curAppType = CommandTypeRaw[module.type];
const createCommandData = () => {
const cmd = appCmd(module.type);
return {
name: module.name,
type: curAppType,
description: cmd(module.description, ""),
options: cmd(
optionsTransformer(
(module as SlashCommand).options ?? []
),
[]
),
defaultMemberPermissions,
dmPermission,
} as ApplicationCommandData;
};
const log =
(...message: any[]) =>
() =>
console.log(...message);
const logged = (...message: any[]) => log(message);
/**
* a local function that returns either one value or the other,
* depending on {t}'s CommandType. If the commandtype of
* this module is CommandType.Both or CommandType.Text or CommandType.Slash,
* return 'is', else return 'els'
* @param t
* @returns S | T
*/
const appCmd = <V extends CommandType, S, T>(t: V) => {
return (is: S, els: T) => ((t & CommandType.Both) !== 0 ? is : els);
};
const curAppType = CommandTypeRaw[module.type];
const createCommandData = () => {
const cmd = appCmd(module.type);
return {
name: module.name,
type: curAppType,
description: cmd(module.description, ""),
options: cmd(
optionsTransformer((module as SlashCommand).options ?? []),
[]
),
defaultMemberPermissions,
dmPermission,
} as ApplicationCommandData;
};
try {
const commandData = createCommandData();
try {
const commandData = createCommandData();
if (!guildIds.length) {
const cmd = (
await client.application!.commands.fetch()
).find(
(c) => c.name === module.name && c.type === curAppType
);
if (cmd) {
if (!cmd.equals(commandData, true)) {
logged(
`Found differences in global command ${module.name}`
);
cmd.edit(commandData).then(
log(
`${module.name} updated with new data successfully!`
)
);
}
return controller.next();
}
client
.application!.commands.create(commandData)
.then(log("Command created", module.name))
.catch(c);
return controller.next();
}
if (!guildIds.length) {
const cmd = (await client.application!.commands.fetch()).find(
(c) => c.name === module.name && c.type === curAppType
);
if (cmd) {
if (!cmd.equals(commandData, true)) {
logged(
`Found differences in global command ${module.name}`
);
cmd.edit(commandData).then(
log(
`${module.name} updated with new data successfully!`
)
);
}
return controller.next();
}
client
.application!.commands.create(commandData)
.then(log("Command created", module.name))
.catch(c);
return controller.next();
}
for (const id of guildIds) {
const guild = await client.guilds.fetch(id).catch(c);
if (!guild) continue;
const guildCmd = (await guild.commands.fetch()).find(
(c) => c.name === module.name && c.type === curAppType
);
if (guildCmd) {
if (!guildCmd.equals(commandData, true)) {
logged(
`Found differences in command ${module.name}`
);
guildCmd
.edit(commandData)
.then(
log(
`${module.name} updated with new data successfully!`
)
)
.catch(c);
continue;
}
continue;
}
guild.commands
.create(commandData)
.then(
log(
"Guild Command created",
module.name,
guild.name
)
)
.catch(c);
}
return controller.next();
} catch (e) {
logged("Command did not register" + module.name);
logged(e);
return controller.stop();
}
})
for (const id of guildIds) {
const guild = await client.guilds.fetch(id).catch(c);
if (!guild) continue;
const guildCmd = (await guild.commands.fetch()).find(
(c) => c.name === module.name && c.type === curAppType
);
if (guildCmd) {
if (!guildCmd.equals(commandData, true)) {
logged(`Found differences in command ${module.name}`);
guildCmd
.edit(commandData)
.then(
log(
`${module.name} updated with new data successfully!`
)
)
.catch(c);
continue;
}
continue;
}
guild.commands
.create(commandData)
.then(log("Guild Command created", module.name, guild.name))
.catch(c);
}
return controller.next();
} catch (e) {
logged("Command did not register" + module.name);
logged(e);
return controller.stop();
}
});
}
export function optionsTransformer(ops: Array<SernOptionsData>) {
return ops.map((el) =>
el.autocomplete ? (({command, ...el}) => el)(el) : el
);
return ops.map((el) =>
el.autocomplete ? (({ command, ...el }) => el)(el) : el
);
}
export type NonEmptyArray<T extends `${number}` = `${number}`> = [T, ...T[]];
export interface ValidPublishOptions {
guildIds: string[];
dmPermission: boolean;
defaultMemberPermissions: PermissionResolvable;
guildIds: string[];
dmPermission: boolean;
defaultMemberPermissions: PermissionResolvable;
}
interface GuildPublishOptions {
guildIds?: NonEmptyArray;
defaultMemberPermissions?: PermissionResolvable;
dmPermission?: never;
guildIds?: NonEmptyArray;
defaultMemberPermissions?: PermissionResolvable;
dmPermission?: never;
}
interface GlobalPublishOptions {
defaultMemberPermissions?: PermissionResolvable;
dmPermission?: false;
guildIds?: never;
defaultMemberPermissions?: PermissionResolvable;
dmPermission?: false;
guildIds?: never;
}
type BasePublishOptions = GuildPublishOptions | GlobalPublishOptions;
export type PublishOptions = BasePublishOptions &
(
| Required<Pick<BasePublishOptions, "defaultMemberPermissions">>
| (
| Required<Pick<BasePublishOptions, "dmPermission">>
| Required<Pick<BasePublishOptions, "guildIds">>
)
);
(
| Required<Pick<BasePublishOptions, "defaultMemberPermissions">>
| (
| Required<Pick<BasePublishOptions, "dmPermission">>
| Required<Pick<BasePublishOptions, "guildIds">>
)
);

View File

@@ -19,9 +19,7 @@
*/
import type { GuildMember, PermissionResolvable } from "discord.js";
import {
CommandType, CommandControlPlugin, controller,
} from "@sern/handler";
import { CommandType, CommandControlPlugin, controller } from "@sern/handler";
function payload(resp?: string) {
return {
@@ -73,10 +71,7 @@ export function requirePermission(
return controller.next();
//*********************************************************************************************************************//
case "both":
if (
!bot.permissions.has(perm) ||
!memm.permissions.has(perm)
) {
if (!bot.permissions.has(perm) || !memm.permissions.has(perm)) {
if (!response)
response = `Please ensure <@${bot.user.id}> and <@${
memm.user.id
@@ -87,12 +82,9 @@ export function requirePermission(
return controller.next();
//*********************************************************************************************************************//
default:
console.warn(
"Perm Check >>> You didn't specify user or bot."
);
console.warn("Perm Check >>> You didn't specify user or bot.");
ctx.reply(payload("User or Bot was not specified."));
return controller.stop();
}
});
}

View File

@@ -22,21 +22,21 @@
import { CommandType, controller, CommandControlPlugin } from "@sern/handler";
export function serverOnly(
guildId: string[],
failMessage = "This command is not available in this guild. \nFor permission to use in your server, please contact my developer."
guildId: string[],
failMessage = "This command is not available in this guild. \nFor permission to use in your server, please contact my developer."
) {
return CommandControlPlugin<CommandType.Both>(async ( ctx, _) => {
if(ctx.guildId == null) {
return controller.stop()
}
if (!guildId.includes(ctx.guildId)) {
ctx.reply(failMessage).then(async (m) => {
setTimeout(async () => {
await m.delete();
}, 3000);
});
return controller.stop();
}
return controller.next();
})
return CommandControlPlugin<CommandType.Both>(async (ctx, _) => {
if (ctx.guildId == null) {
return controller.stop();
}
if (!guildId.includes(ctx.guildId)) {
ctx.reply(failMessage).then(async (m) => {
setTimeout(async () => {
await m.delete();
}, 3000);
});
return controller.stop();
}
return controller.next();
});
}