diff --git a/src/commands/unmute.ts b/src/commands/unmute.ts new file mode 100644 index 0000000..5ceb9cc --- /dev/null +++ b/src/commands/unmute.ts @@ -0,0 +1,23 @@ +import Command from "#utils/Command.js" +import { ApplicationCommandOptionTypes } from "oceanic.js"; +import interactWithBlueskyNow from "#utils/interact-with-bluesky-now.js"; + +const unmuteNowCommand = new Command({ + name: "unmute", + description: "Unmute an account on Bluesky.", + options: [ + { + type: ApplicationCommandOptionTypes.STRING, + name: "handle", + description: "What's the name of the account?", + required: true + } + ], + async action(interaction) { + + return await interactWithBlueskyNow(interaction, "unmute", "unmute"); + + } +}); + +export default unmuteNowCommand; \ No newline at end of file diff --git a/src/utils/interact-with-bluesky-now.ts b/src/utils/interact-with-bluesky-now.ts index dc9405c..f1febc4 100644 --- a/src/utils/interact-with-bluesky-now.ts +++ b/src/utils/interact-with-bluesky-now.ts @@ -11,7 +11,7 @@ import { authenticator } from "otplib"; import IncorrectDecryptionKeyError from "./errors/IncorrectDecryptionKeyError.js"; import MFAIncorrectCodeError from "./errors/MFAIncorrectCodeError.js"; -async function interactWithBlueskyNow(interaction: CommandInteraction | ComponentInteraction | ModalSubmitInteraction, customIDPrefix: string, action: "mute" | "deleteFollow" | "follow" | "deleteRepost" | "like" | "deleteLike" | "repost") { +async function interactWithBlueskyNow(interaction: CommandInteraction | ComponentInteraction | ModalSubmitInteraction, customIDPrefix: string, action: "unmute" | "mute" | "deleteFollow" | "follow" | "deleteRepost" | "like" | "deleteLike" | "repost") { const guildID = getGuildIDFromInteraction(interaction); @@ -28,7 +28,8 @@ async function interactWithBlueskyNow(interaction: CommandInteraction | Componen deleteRepost: "🗑️", follow: "➕", deleteFollow: "➖", - mute: "🔕" + mute: "🔕", + unmute: "🔔" }; await interaction.editOriginal({ content: responses[action], diff --git a/src/utils/interact-with-bluesky.ts b/src/utils/interact-with-bluesky.ts index c80cc4e..42dddd6 100644 --- a/src/utils/interact-with-bluesky.ts +++ b/src/utils/interact-with-bluesky.ts @@ -3,11 +3,12 @@ import blueskyClient from "./bluesky-client.js"; import { Agent } from "@atproto/api"; import { isThreadViewPost } from "@atproto/api/dist/client/types/app/bsky/feed/defs.js"; -async function interactWithBluesky(source: {interaction?: ModalSubmitInteraction | ComponentInteraction, rkey?: string, targetHandle?: string, actorDID?: string, guildID: string, decryptionKey?: string}, action: "mute" | "deleteFollow" | "follow" | "deletePost" | "deleteLike" | "like" | "deleteRepost" | "repost") { +async function interactWithBluesky(source: {interaction?: ModalSubmitInteraction | ComponentInteraction, rkey?: string, targetHandle?: string, actorDID?: string, guildID: string, decryptionKey?: string}, action: "unmute" | "mute" | "deleteFollow" | "follow" | "deletePost" | "deleteLike" | "like" | "deleteRepost" | "repost") { let {interaction, rkey, targetHandle, actorDID} = source; - const isTargetAccount = action === "deleteFollow" || action === "follow" || action === "mute"; + const accountActionTypes = ["deleteFollow", "follow", "mute", "unmute"]; + const isTargetAccount = accountActionTypes.includes(action); if (interaction && !targetHandle) { // Get the rkey of the post.