Files
awesome-plugins/plugins/dmOnly.ts
EvolutionX-10 efd52f5357 style: run prettier
Signed-off-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-09-02 06:03:11 +00:00

31 lines
931 B
TypeScript

// @ts-nocheck
/**
* @plugin
* This is dmOnly plugin, it allows commands to be run only in DMs.
*
* @author @EvolutionX-10 [<@697795666373640213>]
* @version 1.0.0
* @example
* ```ts
* import { dmOnly } from "../plugins/dmOnly";
* import { commandModule } from "@sern/handler";
* export default commandModule({
* plugins: [dmOnly()],
* execute: (ctx) => {
* //your code here
* }
* })
* ```
* @end
*/
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();
});
}