-
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.
Merge pull request #128 from BingusBoingus-Developer-Team/dev
Dev
- Loading branch information
Showing
32 changed files
with
417 additions
and
131 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
CacheType, | ||
CommandInteraction, | ||
EmbedBuilder, | ||
SlashCommandBuilder, | ||
} from 'discord.js'; | ||
import { ACommand } from '../command.abstract'; | ||
import { Inject } from '@nestjs/common'; | ||
import { ServerConfigService } from '../../models/config/service/server-config.service'; | ||
import { CreateOrUpdateServerConfigDto } from '../../models/config/dto/create-or-update-server-config.dto'; | ||
|
||
export default class ConfigureServerChannelCommand extends ACommand { | ||
constructor( | ||
@Inject(ServerConfigService) | ||
private readonly configService: ServerConfigService, | ||
) { | ||
super(); | ||
} | ||
data = new SlashCommandBuilder() | ||
.setName('configure') | ||
.setDescription( | ||
'set the channel id where the bot will send all scheduled messages', | ||
) | ||
.addStringOption((option) => | ||
option.setName('channelid').setDescription('the Id of the text-channel'), | ||
); | ||
|
||
// @Role(CommandAccessLevel.member) | ||
async execute(arg: CommandInteraction<CacheType>): Promise<boolean> { | ||
const channelId = arg.options.get('channelid'); | ||
if (!channelId) { | ||
await arg.reply({ | ||
content: 'you need to provide a valid channel Id! π€', | ||
ephemeral: true, | ||
}); | ||
return false; | ||
} | ||
await arg.deferReply(); | ||
const channelIdValue = channelId.value as unknown as string; | ||
const instance: CreateOrUpdateServerConfigDto = { | ||
channelId: channelIdValue, | ||
serverId: arg.guildId, | ||
}; | ||
const created = | ||
await this.configService.createOrUpdateServerConfig(instance); | ||
const quoteEmbed = new EmbedBuilder() | ||
.setTitle('Your scheduled messages textchannel was configured! π€') | ||
.setDescription('π€') | ||
.setFooter({ | ||
text: 'scheduled messages activated', | ||
}) | ||
.setTimestamp(new Date()); | ||
await arg.editReply({ embeds: [quoteEmbed] }); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,46 @@ | ||
import { EmbedBuilder, TextChannel } from 'discord.js' | ||
import { ITask } from './interfaces/task.interface' | ||
import { BirthdayEntryService } from '../../models/birthday/service/birthday-entry.service' | ||
import { EmbedBuilder, TextChannel } from 'discord.js'; | ||
import { ITask } from './interfaces/task.interface'; | ||
import { BirthdayEntryService } from '../../models/birthday/service/birthday-entry.service'; | ||
|
||
export default class BirthdayShoutoutTask implements ITask { | ||
private channel: TextChannel | ||
private channel: TextChannel; | ||
|
||
constructor(channel: TextChannel, private readonly birthdayService: BirthdayEntryService) { | ||
this.channel = channel | ||
} | ||
|
||
async execute(): Promise<void> { | ||
const birthDayEntries = await this.birthdayService.getEntryForToday() | ||
constructor( | ||
channel: TextChannel, | ||
private readonly birthdayService: BirthdayEntryService, | ||
) { | ||
this.channel = channel; | ||
} | ||
|
||
if (!birthDayEntries || birthDayEntries.length < 1) { | ||
return | ||
} | ||
async execute(): Promise<void> { | ||
const birthDayEntries = await this.birthdayService.getEntryForToday(); | ||
|
||
birthDayEntries.forEach((entry) => { | ||
const creator = this.channel.members.find((member) => member.user.username === entry.username || member.user.displayName === entry.secName) | ||
if (!birthDayEntries || birthDayEntries.length < 1) { | ||
return; | ||
} | ||
|
||
const embed = new EmbedBuilder() | ||
.setTitle(`π¨ Birthday Alert!! π¨`) | ||
.setColor('Random') | ||
.setDescription(`${entry.username ?? entry.secName} is turning **${new Date().getFullYear() - entry.birthDate.getFullYear()}** years old today! πππ`) | ||
.setFooter({ | ||
text: creator?.user.username ?? 'bingus', | ||
iconURL: creator?.displayAvatarURL() ?? undefined, | ||
}) | ||
.setTimestamp(new Date()) | ||
birthDayEntries.forEach((entry) => { | ||
const creator = this.channel.members.find( | ||
(member) => | ||
member.user.username === entry.username || | ||
member.user.displayName === entry.secName, | ||
); | ||
|
||
this.channel.send({ embeds: [embed] }) | ||
const embed = new EmbedBuilder() | ||
.setTitle(`π¨ Birthday Alert!! π¨`) | ||
.setColor('Random') | ||
.setDescription( | ||
`${entry.username ?? entry.secName} is turning **${ | ||
new Date().getFullYear() - entry.birthDate.getFullYear() | ||
}** years old today! πππ`, | ||
) | ||
.setFooter({ | ||
text: creator?.user.username ?? 'bingus', | ||
iconURL: creator?.displayAvatarURL() ?? undefined, | ||
}) | ||
} | ||
} | ||
.setTimestamp(new Date()); | ||
|
||
this.channel.send({ embeds: [embed] }); | ||
}); | ||
} | ||
} |
Oops, something went wrong.