-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat; add command role permission requirements
- Loading branch information
Showing
14 changed files
with
120 additions
and
51 deletions.
There are no files selected for viewing
76 changes: 39 additions & 37 deletions
76
src/modules/command/commands/activate-birthday-shoutout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
import { | ||
CacheType, | ||
CommandInteraction, | ||
SlashCommandBuilder, | ||
} from 'discord.js'; | ||
import { ACommand } from '../command.abstract'; | ||
import { Inject } from '@nestjs/common'; | ||
import { CacheType, CommandInteraction, SlashCommandBuilder } from 'discord.js'; | ||
import { ACommand } from '../command.abstract'; | ||
import { Inject } from '@nestjs/common'; | ||
import { BirthdayEntryService } from '../../models/birthday/service/birthday-entry.service'; | ||
import { CreateOrUpdateBirthdayEntryDto } from '../../models/birthday/dto/create-or-update-birthday-entry.dto'; | ||
|
||
export default class ActivateBirthdayEntryShoutoutCommand extends ACommand { | ||
constructor( | ||
@Inject(BirthdayEntryService) | ||
private readonly birthdayEntryService: BirthdayEntryService, | ||
) { | ||
super(); | ||
} | ||
data = new SlashCommandBuilder() | ||
.setName('activate-birthday-shoutout') | ||
.setDescription( | ||
'Use this if you want Bingus to shout you out on your birthday (default)!', | ||
); | ||
|
||
async execute(arg: CommandInteraction<CacheType>): Promise<boolean> { | ||
await arg.deferReply(); | ||
const instance: CreateOrUpdateBirthdayEntryDto ={ | ||
username: arg.user.username, | ||
secName: arg.user.displayName, | ||
active: true | ||
}; | ||
const inactive = | ||
await this.birthdayEntryService.updateBirthdayEntry(instance); | ||
if (!inactive) { | ||
await arg.editReply({ content: 'I don\'t know your birthday yet! 🎉'}); | ||
} else { | ||
await arg.editReply({ content: 'You will now receive a birthday shoutout from Bingus! 🎉'}); | ||
} | ||
return true; | ||
import { | ||
CommandAccessLevel, | ||
Role, | ||
} from '../../../common/decoratos/role.decorator'; | ||
|
||
export default class ActivateBirthdayEntryShoutoutCommand extends ACommand { | ||
constructor( | ||
@Inject(BirthdayEntryService) | ||
private readonly birthdayEntryService: BirthdayEntryService, | ||
) { | ||
super(); | ||
} | ||
data = new SlashCommandBuilder() | ||
.setName('activate-birthday-shoutout') | ||
.setDescription( | ||
'Use this if you want Bingus to shout you out on your birthday (default)!', | ||
); | ||
|
||
@Role(CommandAccessLevel.member) | ||
async execute(arg: CommandInteraction<CacheType>): Promise<boolean> { | ||
await arg.deferReply(); | ||
const instance: CreateOrUpdateBirthdayEntryDto = { | ||
username: arg.user.username, | ||
secName: arg.user.displayName, | ||
active: true, | ||
}; | ||
const inactive = | ||
await this.birthdayEntryService.updateBirthdayEntry(instance); | ||
if (!inactive) { | ||
await arg.editReply({ content: "I don't know your birthday yet! 🎉" }); | ||
} else { | ||
await arg.editReply({ | ||
content: 'You will now receive a birthday shoutout from Bingus! 🎉', | ||
}); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters