Skip to content

Commit

Permalink
add command for getting voice message urls
Browse files Browse the repository at this point in the history
Techbot121 authored and Meta Construct committed Mar 11, 2024
1 parent e207e65 commit fa0542b
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/services/discord/modules/commands/GetVoiceMessageUrl.ts
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,
});
},
};
2 changes: 2 additions & 0 deletions app/services/discord/modules/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DiscordBot } from "../..";
import { MenuDeeplCommand, SlashDeeplCommand } from "./DeepL";
import { MenuGetStickerUrlCommand } from "./GetStickerUrl";
import { MenuGetVoiceMessageUrlCommand } from "./GetVoiceMessageUrl";
import { MenuManageMediaLinksCommand, SlashManageMediaLinks } from "./developer/ManageMediaLinks";
import {
MenuSpeechbubbleLeftCommand,
@@ -55,6 +56,7 @@ export const menuCommands = [
// normal menuCommands
MenuDeeplCommand,
MenuGetStickerUrlCommand,
MenuGetVoiceMessageUrlCommand,
MenuSpeechbubbleLeftCommand,
MenuSpeechbubbleRightCommand,
MenuWhyRoleCommand,

0 comments on commit fa0542b

Please sign in to comment.