Add tiers, continuation, fetch cooldown, persistent action log, voice read, batch MCP
This commit is contained in:
@@ -34,6 +34,7 @@ const KNOWN_ACTIONS = new Set<string>([
|
||||
PuppetAction.Ping,
|
||||
PuppetAction.EventsSubscribe,
|
||||
PuppetAction.StateGet,
|
||||
PuppetAction.VoiceGet,
|
||||
PuppetAction.MessageSend,
|
||||
PuppetAction.MessageRead,
|
||||
PuppetAction.MessageFetch,
|
||||
|
||||
@@ -9,7 +9,13 @@
|
||||
|
||||
import { openPrivateChannel, sendMessage } from "@vencord/types/utils";
|
||||
import { findByPropsLazy } from "@vencord/types/webpack";
|
||||
import { ChannelStore, GuildStore, MessageStore, UserStore } from "@vencord/types/webpack/common";
|
||||
import {
|
||||
ChannelStore,
|
||||
GuildStore,
|
||||
MessageStore,
|
||||
UserStore,
|
||||
VoiceStateStore
|
||||
} from "@vencord/types/webpack/common";
|
||||
import { isSnowflake, PUPPET_LIMITS, PuppetAction, PuppetErrorCode, type PuppetResult } from "shared/puppetProtocol";
|
||||
|
||||
/** Channel types that can receive text messages. */
|
||||
@@ -154,6 +160,42 @@ export async function handlePuppetAction(
|
||||
return ok(state);
|
||||
}
|
||||
|
||||
case PuppetAction.VoiceGet: {
|
||||
const { guildId, userId } = params;
|
||||
if (guildId !== undefined) {
|
||||
assert(isSnowflake(guildId), PuppetErrorCode.InvalidSnowflake, "guildId must be a snowflake");
|
||||
}
|
||||
if (userId !== undefined) {
|
||||
assert(isSnowflake(userId), PuppetErrorCode.InvalidSnowflake, "userId must be a snowflake");
|
||||
}
|
||||
|
||||
const targetId = (userId as string | undefined) ?? UserStore.getCurrentUser()?.id;
|
||||
assert(targetId, PuppetErrorCode.NotLoggedIn, "no user is logged in");
|
||||
|
||||
const voiceState = VoiceStateStore.getVoiceState((guildId as string | null) ?? null, targetId);
|
||||
if (!voiceState?.channelId) {
|
||||
return ok({ guildId: guildId ?? null, channelId: null, channelName: null, members: [] });
|
||||
}
|
||||
|
||||
const channel = ChannelStore.getChannel(voiceState.channelId);
|
||||
const states = VoiceStateStore.getVoiceStatesForChannel(voiceState.channelId);
|
||||
|
||||
return ok({
|
||||
guildId: channel?.guild_id ?? guildId ?? null,
|
||||
channelId: voiceState.channelId,
|
||||
channelName: channel?.name ?? null,
|
||||
members: Object.values(states).map(state => {
|
||||
const user = UserStore.getUser(state.userId);
|
||||
return {
|
||||
id: state.userId,
|
||||
username: user?.username ?? state.userId,
|
||||
mute: state.mute,
|
||||
deaf: state.deaf
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
case PuppetAction.MessageSend: {
|
||||
const { channelId } = params;
|
||||
assert(isSnowflake(channelId), PuppetErrorCode.InvalidSnowflake, "channelId must be a snowflake");
|
||||
|
||||
@@ -10,6 +10,7 @@ export const enum PuppetAction {
|
||||
Ping = "ping",
|
||||
EventsSubscribe = "events.subscribe",
|
||||
StateGet = "state.get",
|
||||
VoiceGet = "voice.get",
|
||||
MessageSend = "message.send",
|
||||
MessageRead = "message.read",
|
||||
MessageFetch = "message.fetch",
|
||||
@@ -20,6 +21,7 @@ export const PuppetActions: readonly PuppetAction[] = [
|
||||
PuppetAction.Ping,
|
||||
PuppetAction.EventsSubscribe,
|
||||
PuppetAction.StateGet,
|
||||
PuppetAction.VoiceGet,
|
||||
PuppetAction.MessageSend,
|
||||
PuppetAction.MessageRead,
|
||||
PuppetAction.MessageFetch,
|
||||
|
||||
Reference in New Issue
Block a user