Archived
0
0
Fork 0

feat(commands): added ability for commands to be ran by owner only

This commit is contained in:
Daryl Ronningen 2021-06-20 05:41:26 -07:00
parent 8af7fcf728
commit c081b68c29
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
5 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,6 @@
{
"token": "",
"logLevel": "",
"prefix": ""
}
"prefix": "",
"owner": ""
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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,
},

View file

@ -35,6 +35,7 @@ export interface ICommandOptions {
shortDescription: string;
extendedDescription: string;
group: string;
ownerOnly: boolean;
runIn: ECommandRunIn;
}