chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
@@ -8,10 +8,7 @@ export type MessageCliHelpers = {
|
||||
withMessageBase: (command: Command) => Command;
|
||||
withMessageTarget: (command: Command) => Command;
|
||||
withRequiredMessageTarget: (command: Command) => Command;
|
||||
runMessageAction: (
|
||||
action: string,
|
||||
opts: Record<string, unknown>,
|
||||
) => Promise<void>;
|
||||
runMessageAction: (action: string, opts: Record<string, unknown>) => Promise<void>;
|
||||
};
|
||||
|
||||
export function createMessageCliHelpers(
|
||||
@@ -37,10 +34,7 @@ export function createMessageCliHelpers(
|
||||
"Recipient/channel: E.164 for WhatsApp/Signal, Telegram chat id/@username, Discord/Slack channel/user, or iMessage handle/chat_id",
|
||||
);
|
||||
|
||||
const runMessageAction = async (
|
||||
action: string,
|
||||
opts: Record<string, unknown>,
|
||||
) => {
|
||||
const runMessageAction = async (action: string, opts: Record<string, unknown>) => {
|
||||
setVerbose(Boolean(opts.verbose));
|
||||
const deps = createDefaultDeps();
|
||||
try {
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
import type { Command } from "commander";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessageDiscordAdminCommands(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessageDiscordAdminCommands(message: Command, helpers: MessageCliHelpers) {
|
||||
const role = message.command("role").description("Role actions");
|
||||
helpers
|
||||
.withMessageBase(
|
||||
role
|
||||
.command("info")
|
||||
.description("List roles")
|
||||
.requiredOption("--guild-id <id>", "Guild id"),
|
||||
role.command("info").description("List roles").requiredOption("--guild-id <id>", "Guild id"),
|
||||
)
|
||||
.action(async (opts) => {
|
||||
await helpers.runMessageAction("role-info", opts);
|
||||
|
||||
@@ -2,10 +2,7 @@ import type { Command } from "commander";
|
||||
import { collectOption } from "../helpers.js";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessageEmojiCommands(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessageEmojiCommands(message: Command, helpers: MessageCliHelpers) {
|
||||
const emoji = message.command("emoji").description("Emoji actions");
|
||||
|
||||
helpers
|
||||
@@ -24,28 +21,18 @@ export function registerMessageEmojiCommands(
|
||||
)
|
||||
.requiredOption("--emoji-name <name>", "Emoji name")
|
||||
.requiredOption("--media <path-or-url>", "Emoji media (path or URL)")
|
||||
.option(
|
||||
"--role-ids <id>",
|
||||
"Role id (repeat)",
|
||||
collectOption,
|
||||
[] as string[],
|
||||
)
|
||||
.option("--role-ids <id>", "Role id (repeat)", collectOption, [] as string[])
|
||||
.action(async (opts) => {
|
||||
await helpers.runMessageAction("emoji-upload", opts);
|
||||
});
|
||||
}
|
||||
|
||||
export function registerMessageStickerCommands(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessageStickerCommands(message: Command, helpers: MessageCliHelpers) {
|
||||
const sticker = message.command("sticker").description("Sticker actions");
|
||||
|
||||
helpers
|
||||
.withMessageBase(
|
||||
helpers.withRequiredMessageTarget(
|
||||
sticker.command("send").description("Send stickers"),
|
||||
),
|
||||
helpers.withRequiredMessageTarget(sticker.command("send").description("Send stickers")),
|
||||
)
|
||||
.requiredOption("--sticker-id <id>", "Sticker id (repeat)", collectOption)
|
||||
.option("-m, --message <text>", "Optional message body")
|
||||
|
||||
@@ -2,10 +2,7 @@ import type { Command } from "commander";
|
||||
import { collectOption } from "../helpers.js";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessagePermissionsCommand(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessagePermissionsCommand(message: Command, helpers: MessageCliHelpers) {
|
||||
helpers
|
||||
.withMessageBase(
|
||||
helpers.withMessageTarget(
|
||||
@@ -18,30 +15,15 @@ export function registerMessagePermissionsCommand(
|
||||
});
|
||||
}
|
||||
|
||||
export function registerMessageSearchCommand(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessageSearchCommand(message: Command, helpers: MessageCliHelpers) {
|
||||
helpers
|
||||
.withMessageBase(
|
||||
message.command("search").description("Search Discord messages"),
|
||||
)
|
||||
.withMessageBase(message.command("search").description("Search Discord messages"))
|
||||
.requiredOption("--guild-id <id>", "Guild id")
|
||||
.requiredOption("--query <text>", "Search query")
|
||||
.option("--channel-id <id>", "Channel id")
|
||||
.option(
|
||||
"--channel-ids <id>",
|
||||
"Channel id (repeat)",
|
||||
collectOption,
|
||||
[] as string[],
|
||||
)
|
||||
.option("--channel-ids <id>", "Channel id (repeat)", collectOption, [] as string[])
|
||||
.option("--author-id <id>", "Author id")
|
||||
.option(
|
||||
"--author-ids <id>",
|
||||
"Author id (repeat)",
|
||||
collectOption,
|
||||
[] as string[],
|
||||
)
|
||||
.option("--author-ids <id>", "Author id (repeat)", collectOption, [] as string[])
|
||||
.option("--limit <n>", "Result limit")
|
||||
.action(async (opts) => {
|
||||
await helpers.runMessageAction("search", opts);
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
import type { Command } from "commander";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessagePinCommands(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessagePinCommands(message: Command, helpers: MessageCliHelpers) {
|
||||
const withPinsTarget = (command: Command) =>
|
||||
command.option(
|
||||
"--channel-id <id>",
|
||||
"Channel id (defaults to --to; required for WhatsApp)",
|
||||
);
|
||||
command.option("--channel-id <id>", "Channel id (defaults to --to; required for WhatsApp)");
|
||||
|
||||
const pins = [
|
||||
helpers
|
||||
.withMessageBase(
|
||||
withPinsTarget(
|
||||
helpers.withMessageTarget(
|
||||
message.command("pin").description("Pin a message"),
|
||||
),
|
||||
helpers.withMessageTarget(message.command("pin").description("Pin a message")),
|
||||
),
|
||||
)
|
||||
.requiredOption("--message-id <id>", "Message id")
|
||||
@@ -27,9 +19,7 @@ export function registerMessagePinCommands(
|
||||
helpers
|
||||
.withMessageBase(
|
||||
withPinsTarget(
|
||||
helpers.withMessageTarget(
|
||||
message.command("unpin").description("Unpin a message"),
|
||||
),
|
||||
helpers.withMessageTarget(message.command("unpin").description("Unpin a message")),
|
||||
),
|
||||
)
|
||||
.requiredOption("--message-id <id>", "Message id")
|
||||
@@ -38,9 +28,7 @@ export function registerMessagePinCommands(
|
||||
}),
|
||||
helpers
|
||||
.withMessageBase(
|
||||
helpers.withMessageTarget(
|
||||
message.command("pins").description("List pinned messages"),
|
||||
),
|
||||
helpers.withMessageTarget(message.command("pins").description("List pinned messages")),
|
||||
)
|
||||
.option("--channel-id <id>", "Channel id (defaults to --to)")
|
||||
.option("--limit <n>", "Result limit")
|
||||
|
||||
@@ -2,15 +2,10 @@ import type { Command } from "commander";
|
||||
import { collectOption } from "../helpers.js";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessagePollCommand(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessagePollCommand(message: Command, helpers: MessageCliHelpers) {
|
||||
helpers
|
||||
.withMessageBase(
|
||||
helpers.withRequiredMessageTarget(
|
||||
message.command("poll").description("Send a poll"),
|
||||
),
|
||||
helpers.withRequiredMessageTarget(message.command("poll").description("Send a poll")),
|
||||
)
|
||||
.requiredOption("--poll-question <text>", "Poll question")
|
||||
.option(
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
import type { Command } from "commander";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessageReactionsCommands(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessageReactionsCommands(message: Command, helpers: MessageCliHelpers) {
|
||||
helpers
|
||||
.withMessageBase(
|
||||
helpers.withMessageTarget(
|
||||
message.command("react").description("Add or remove a reaction"),
|
||||
),
|
||||
helpers.withMessageTarget(message.command("react").description("Add or remove a reaction")),
|
||||
)
|
||||
.requiredOption("--message-id <id>", "Message id")
|
||||
.option("--emoji <emoji>", "Emoji for reactions")
|
||||
|
||||
@@ -7,9 +7,7 @@ export function registerMessageReadEditDeleteCommands(
|
||||
) {
|
||||
helpers
|
||||
.withMessageBase(
|
||||
helpers.withMessageTarget(
|
||||
message.command("read").description("Read recent messages"),
|
||||
),
|
||||
helpers.withMessageTarget(message.command("read").description("Read recent messages")),
|
||||
)
|
||||
.option("--limit <n>", "Result limit")
|
||||
.option("--before <id>", "Read/search before id")
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import type { Command } from "commander";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessageSendCommand(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessageSendCommand(message: Command, helpers: MessageCliHelpers) {
|
||||
helpers
|
||||
.withMessageBase(
|
||||
helpers
|
||||
@@ -24,11 +21,7 @@ export function registerMessageSendCommand(
|
||||
)
|
||||
.option("--reply-to <id>", "Reply-to message id")
|
||||
.option("--thread-id <id>", "Thread id (Telegram forum thread)")
|
||||
.option(
|
||||
"--gif-playback",
|
||||
"Treat video media as GIF playback (WhatsApp only).",
|
||||
false,
|
||||
),
|
||||
.option("--gif-playback", "Treat video media as GIF playback (WhatsApp only).", false),
|
||||
)
|
||||
.action(async (opts) => {
|
||||
await helpers.runMessageAction("send", opts);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import type { Command } from "commander";
|
||||
import type { MessageCliHelpers } from "./helpers.js";
|
||||
|
||||
export function registerMessageThreadCommands(
|
||||
message: Command,
|
||||
helpers: MessageCliHelpers,
|
||||
) {
|
||||
export function registerMessageThreadCommands(message: Command, helpers: MessageCliHelpers) {
|
||||
const thread = message.command("thread").description("Thread actions");
|
||||
|
||||
helpers
|
||||
|
||||
Reference in New Issue
Block a user