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

@@ -19,29 +19,23 @@
* ```
*/
import { ChannelType } from "discord.js";
import { PluginType } from "@sern/handler";
import { CommandControlPlugin, controller } from "@sern/handler";
export function channelType(channelType, onFail) {
return {
type: PluginType.Event,
description: "Checks the channel type.",
return CommandControlPlugin(async (ctx, args) => {
let channel = ctx.channel?.type; //for some reason the dm channel type was returning undefined at some points
async execute(event, controller) {
const [ctx] = event;
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 (channel === undefined) {
channel = ChannelType.DM;
}
if (channelType.includes(channel)) {
return controller.next();
}
if (channelType.includes(channel)) {
return controller.next();
}
if (onFail) {
await ctx.reply(onFail);
}
if (onFail) {
await ctx.reply(onFail);
}
return controller.stop();
},
};
return controller.stop();
});
}