mirror of
https://github.com/sern-handler/awesome-plugins
synced 2026-06-21 07:12:21 +00:00
@@ -7,54 +7,31 @@
|
||||
* @license: MIT
|
||||
* @example:
|
||||
* ```ts
|
||||
* import { publish } from '../path/to/your/plugin/folder';
|
||||
* import { sernModule, CommandType } from '@sern/handler';
|
||||
*
|
||||
* export default sernModule<CommandType.Slash>([publish()], { // Put guild id in array for guild commands
|
||||
* // Your code goes here
|
||||
* });
|
||||
* import { publish } from "../path/to/your/plugin/folder";
|
||||
* import { sernModule, CommandType } from "@sern/handler";
|
||||
* export default sernModule<CommandType.Slash>([publish()], { // put guild id in array for guild commands
|
||||
* // your code
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
|
||||
import {
|
||||
CommandPlugin,
|
||||
CommandType,
|
||||
PluginType,
|
||||
SernOptionsData,
|
||||
} from '@sern/handler';
|
||||
|
||||
import {
|
||||
ApplicationCommandData,
|
||||
ApplicationCommandType
|
||||
} from 'discord.js';
|
||||
} from "@sern/handler";
|
||||
import { ApplicationCommandData, ApplicationCommandType } from "discord.js";
|
||||
|
||||
export function publish(
|
||||
guildIds: string | Array<string> = []
|
||||
): CommandPlugin<CommandType.Slash | CommandType.Both> {
|
||||
return {
|
||||
type: PluginType.Command,
|
||||
description: 'Manage Slash Commands',
|
||||
name: 'slash-auto-publish-ts',
|
||||
async execute(
|
||||
client: {
|
||||
application: any;
|
||||
guilds: {
|
||||
fetch: (arg0: string) => Promise<any>
|
||||
};
|
||||
},
|
||||
module: {
|
||||
name: any;
|
||||
type: string | number;
|
||||
description: any;
|
||||
options: any;
|
||||
},
|
||||
controller: {
|
||||
next: () => any;
|
||||
stop: () => any
|
||||
}
|
||||
) {
|
||||
description: "Manage Slash Commands",
|
||||
name: "slash-auto-publish",
|
||||
async execute(client, module, controller) {
|
||||
function c(e: unknown) {
|
||||
console.error('publish command didnt work for', module.name!);
|
||||
console.error("publish command didnt work for", module.name!);
|
||||
console.error(e);
|
||||
}
|
||||
try {
|
||||
@@ -87,7 +64,7 @@ export function publish(
|
||||
await client
|
||||
.application!.commands.create(commandData)
|
||||
.catch(c);
|
||||
console.log('Command created', module.name!);
|
||||
console.log("Command created", module.name!);
|
||||
return controller.next();
|
||||
}
|
||||
|
||||
@@ -112,14 +89,14 @@ export function publish(
|
||||
}
|
||||
await guild.commands.create(commandData).catch(c);
|
||||
console.log(
|
||||
'Guild Command created',
|
||||
"Guild Command created",
|
||||
module.name!,
|
||||
guild.name
|
||||
);
|
||||
}
|
||||
return controller.next();
|
||||
} catch (e) {
|
||||
console.log('Command did not register' + module.name!);
|
||||
console.log("Command did not register" + module.name!);
|
||||
console.log(e);
|
||||
return controller.stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user