UNPKG

@sodacore/discord

Version:

Sodacore Discord is a plugin that offers Discord SSO/OAuth2 support and the ability to create bots in a similar controller pattern.

23 lines (22 loc) 1.43 kB
import { Utils } from '@sodacore/di'; import { ApplicationCommandType, ContextMenuCommandBuilder } from 'discord.js'; export function MessageContext(name) { return (target, propertyKey) => { Utils.setMeta('type', 'discord')(target, 'add.messagecontext', propertyKey); Utils.setMeta('unique', 'discord')(target, name, propertyKey); Utils.setMeta('builder', 'discord')(target, new ContextMenuCommandBuilder().setName(name).setType(ApplicationCommandType.Message), propertyKey); const methods = Utils.getMeta('methods', 'discord')(target, undefined, []); methods.push({ key: String(propertyKey), unique: name, type: 'contextmenu', subType: 'message', auth: [] }); Utils.setMeta('methods', 'discord')(target, methods); }; } export function UserContext(name) { return (target, propertyKey) => { Utils.setMeta('type', 'discord')(target, 'add.usercontext', propertyKey); Utils.setMeta('unique', 'discord')(target, name, propertyKey); Utils.setMeta('builder', 'discord')(target, new ContextMenuCommandBuilder().setName(name).setType(ApplicationCommandType.User), propertyKey); const commands = Utils.getMeta('commands', 'discord')(target, undefined, []); commands.push({ key: String(propertyKey), type: 'contextmenu', subType: 'user', unique: name, auth: [] }); Utils.setMeta('methods', 'discord')(target, commands); }; }