feat(commands): added ability for commands to be ran by owner only
This commit is contained in:
parent
8af7fcf728
commit
c081b68c29
5 changed files with 15 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"token": "",
|
||||
"logLevel": "",
|
||||
"prefix": ""
|
||||
"prefix": "",
|
||||
"owner": ""
|
||||
}
|
|
@ -81,6 +81,11 @@ client.on('message', async (msg) => {
|
|||
|
||||
if(!findCommand) return;
|
||||
|
||||
if(findCommand.options.ownerOnly && msg.author.id !== config.get('owner')) {
|
||||
await msg.reply('Only the bot owner can run this command!');
|
||||
return;
|
||||
}
|
||||
|
||||
if((findCommand.options.runIn === ECommandRunIn.DM) && msg.channel.type !== 'dm') {
|
||||
await msg.reply('You can only run this command in DMs!');
|
||||
return;
|
||||
|
|
|
@ -21,7 +21,7 @@ export default abstract class Command {
|
|||
public readonly client: Client;
|
||||
public readonly options: ICommandOptions;
|
||||
|
||||
public constructor(client: Client, options: ICommandOptions) {
|
||||
protected constructor(client: Client, options: ICommandOptions) {
|
||||
this.client = client;
|
||||
this.options = options;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export const Defaults = {
|
|||
logLevel: 'info',
|
||||
},
|
||||
configSchema: {
|
||||
required: ['token', 'logLevel', 'prefix'],
|
||||
required: ['token', 'logLevel', 'prefix', 'owner'],
|
||||
type: 'object',
|
||||
properties: {
|
||||
token: {
|
||||
|
@ -42,6 +42,10 @@ export const Defaults = {
|
|||
$id: '#/properties/prefix',
|
||||
type: 'string',
|
||||
},
|
||||
owner: {
|
||||
$id: '#/properties/owner',
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
|
|
|
@ -35,6 +35,7 @@ export interface ICommandOptions {
|
|||
shortDescription: string;
|
||||
extendedDescription: string;
|
||||
group: string;
|
||||
ownerOnly: boolean;
|
||||
runIn: ECommandRunIn;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue