Skip to content

Commit

Permalink
Backend: add inline reply to command
Browse files Browse the repository at this point in the history
  • Loading branch information
89Q12 committed Dec 6, 2024
1 parent 2fd12a4 commit 4ac3b61
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
17 changes: 14 additions & 3 deletions backend/src/bot/commands/mod-anouncement.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,29 @@ export class MumVoiceCommand {
@Handler()
async onMessage(
@InteractionEvent() interaction: CommandInteraction,
@IA(SlashCommandPipe, ValidationPipe) message: ModAnouncementDto,
@IA(SlashCommandPipe, ValidationPipe) dto: ModAnouncementDto,
): Promise<void> {
try {
await interaction.channel.send(message.message);
if (dto.replyToMessage != '' || dto.replyToMessage != undefined)
await interaction.channel.send({
content: dto.message,
reply: {
messageReference: dto.replyToMessage,
failIfNotExists: true,
},
});
else
await interaction.channel.send({
content: dto.message,
});
interaction.reply({
content: 'Done!',
ephemeral: true,
});
} catch (err) {
interaction.reply({
content: `Failed to send message in this channel with error: ${err} and message:
${message.message}`,
${dto.message}`,
ephemeral: true,
});
}
Expand Down
9 changes: 9 additions & 0 deletions backend/src/bot/dto/mod-anouncement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ export class ModAnouncementDto {
})
@IsString()
message: string;

@Param({
name: 'replyto',
description: 'Message ID to which the bot should reply(optional)',
type: ParamType.STRING,
required: false,
})
@IsString()
replyToMessage: string;
}

0 comments on commit 4ac3b61

Please sign in to comment.