@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.
58 lines (57 loc) • 2.16 kB
JavaScript
import { Utils } from '@sodacore/di';
export function Interaction() {
return (target, key, index) => {
const args = Utils.getMeta('args', 'discord')(target, key, []);
args.push({ index, type: 'interaction' });
Utils.setMeta('args', 'discord')(target, args, key);
};
}
export function User() {
return (target, key, index) => {
const args = Utils.getMeta('args', 'discord')(target, key, []);
args.push({ index, type: 'user' });
Utils.setMeta('args', 'discord')(target, args, key);
};
}
export function Guild() {
return (target, key, index) => {
const args = Utils.getMeta('args', 'discord')(target, key, []);
args.push({ index, type: 'guild' });
Utils.setMeta('args', 'discord')(target, args, key);
};
}
export function Channel() {
return (target, key, index) => {
const args = Utils.getMeta('args', 'discord')(target, key, []);
args.push({ index, type: 'channel' });
Utils.setMeta('args', 'discord')(target, args, key);
};
}
export function Client() {
return (target, key, index) => {
const args = Utils.getMeta('args', 'discord')(target, key, []);
args.push({ index, type: 'client' });
Utils.setMeta('args', 'discord')(target, args, key);
};
}
export function Query() {
return (target, key, index) => {
const args = Utils.getMeta('args', 'discord')(target, key, []);
args.push({ index, type: 'query' });
Utils.setMeta('args', 'discord')(target, args, key);
};
}
export function Option(name, sendAll = false) {
return (target, propertyKey, index) => {
const args = Utils.getMeta('args', 'discord')(target, propertyKey, []);
args.push({ index, type: 'option', name, format: sendAll });
Utils.setMeta('args', 'discord')(target, args, propertyKey);
};
}
export function Field(name) {
return (target, propertyKey, index) => {
const args = Utils.getMeta('args', 'discord')(target, propertyKey, []);
args.push({ index, type: 'field', name });
Utils.setMeta('args', 'discord')(target, args, propertyKey);
};
}