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": "",
|
"token": "",
|
||||||
"logLevel": "",
|
"logLevel": "",
|
||||||
"prefix": ""
|
"prefix": "",
|
||||||
}
|
"owner": ""
|
||||||
|
}
|
||||||
|
|
|
@ -81,6 +81,11 @@ client.on('message', async (msg) => {
|
||||||
|
|
||||||
if(!findCommand) return;
|
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') {
|
if((findCommand.options.runIn === ECommandRunIn.DM) && msg.channel.type !== 'dm') {
|
||||||
await msg.reply('You can only run this command in DMs!');
|
await msg.reply('You can only run this command in DMs!');
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default abstract class Command {
|
||||||
public readonly client: Client;
|
public readonly client: Client;
|
||||||
public readonly options: ICommandOptions;
|
public readonly options: ICommandOptions;
|
||||||
|
|
||||||
public constructor(client: Client, options: ICommandOptions) {
|
protected constructor(client: Client, options: ICommandOptions) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ export const Defaults = {
|
||||||
logLevel: 'info',
|
logLevel: 'info',
|
||||||
},
|
},
|
||||||
configSchema: {
|
configSchema: {
|
||||||
required: ['token', 'logLevel', 'prefix'],
|
required: ['token', 'logLevel', 'prefix', 'owner'],
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
token: {
|
token: {
|
||||||
|
@ -42,6 +42,10 @@ export const Defaults = {
|
||||||
$id: '#/properties/prefix',
|
$id: '#/properties/prefix',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
|
owner: {
|
||||||
|
$id: '#/properties/owner',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,6 +35,7 @@ export interface ICommandOptions {
|
||||||
shortDescription: string;
|
shortDescription: string;
|
||||||
extendedDescription: string;
|
extendedDescription: string;
|
||||||
group: string;
|
group: string;
|
||||||
|
ownerOnly: boolean;
|
||||||
runIn: ECommandRunIn;
|
runIn: ECommandRunIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue