-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add command for getting voice message urls
1 parent
e207e65
commit fa0542b
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/services/discord/modules/commands/GetVoiceMessageUrl.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { EphemeralResponse } from "."; | ||
import { MenuCommand } from "@/extensions/discord"; | ||
import Discord from "discord.js"; | ||
|
||
export const MenuGetVoiceMessageUrlCommand: MenuCommand = { | ||
options: { | ||
name: "get voice message url", | ||
type: Discord.ApplicationCommandType.Message, | ||
}, | ||
execute: async (ctx: Discord.MessageContextMenuCommandInteraction) => { | ||
if (ctx.targetMessage.attachments.size === 0) { | ||
await ctx.reply(EphemeralResponse("no attachments found in this message...")); | ||
return; | ||
} | ||
const voiceUris = ctx.targetMessage.attachments.find(a => a.waveform !== null && a.url); | ||
if (!voiceUris) { | ||
await ctx.reply(EphemeralResponse("no voice messages found in this message...")); | ||
return; | ||
} | ||
await ctx.reply({ | ||
content: voiceUris.url, | ||
ephemeral: 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