mirror of
https://github.com/sern-handler/awesome-plugins
synced 2026-06-06 01:16:51 +00:00
chore: update JavaScript plugins Co-authored-by: EvolutionX-10 <EvolutionX-10@users.noreply.github.com>
34 lines
878 B
JavaScript
34 lines
878 B
JavaScript
// @ts-nocheck
|
|
|
|
/**
|
|
* 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
|
|
* }
|
|
* })
|
|
* ```
|
|
*/
|
|
import { CommandControlPlugin, controller } from "@sern/handler";
|
|
export function dmOnly(content, ephemeral) {
|
|
// For discord.js you should have the Partials.Channel and DirectMessages intent enabled.
|
|
return CommandControlPlugin(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();
|
|
});
|
|
}
|