File tree 3 files changed +17
-2
lines changed 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,13 @@ import { CronJob } from 'cron';
2
2
import { ChatInputCommandInteraction } from 'discord.js' ;
3
3
4
4
import { getCronTime } from './helpers/get-cron-time' ;
5
+ import { isModo } from './helpers/roles' ;
5
6
6
- export const addCron = ( interaction : ChatInputCommandInteraction ) : void => {
7
+ export const addCron = async ( interaction : ChatInputCommandInteraction ) : Promise < void > => {
8
+ if ( ! isModo ( interaction . member ) ) {
9
+ await interaction . reply ( 'You are not allowed to use this command' ) ;
10
+ return ;
11
+ }
7
12
const frequency = interaction . options . getString ( 'every' , true ) ;
8
13
const message = interaction . options . getString ( 'message' , true ) ;
9
14
@@ -17,4 +22,6 @@ export const addCron = (interaction: ChatInputCommandInteraction): void => {
17
22
'Europe/Paris' ,
18
23
) ;
19
24
job . start ( ) ;
25
+
26
+ await interaction . reply ( `Recurring message added every ${ frequency } ` ) ;
20
27
} ;
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export const handleInteractionCreation = async (interaction: Interaction): Promi
29
29
await interaction . reply ( 'Unknown subcommand' ) ;
30
30
return ;
31
31
}
32
- addCron ( interaction ) ;
32
+ await addCron ( interaction ) ;
33
33
break ;
34
34
}
35
35
} ;
Original file line number Diff line number Diff line change
1
+ import { type APIInteractionGuildMember , GuildMember } from 'discord.js' ;
2
+
3
+ export const isAdmin = ( member : GuildMember | APIInteractionGuildMember | null ) : boolean =>
4
+ member instanceof GuildMember && member . roles . cache . some ( ( role ) => role . name === 'Admin' ) ;
5
+
6
+ export const isModo = ( member : GuildMember | APIInteractionGuildMember | null ) : boolean =>
7
+ member instanceof GuildMember &&
8
+ member . roles . cache . some ( ( role ) => role . name === 'Admin' || role . name === 'Modo' ) ;
You can’t perform that action at this time.
0 commit comments