feat(plugins): add vc effect event to moyai plugin (#199)

This commit is contained in:
megumin 2022-11-10 13:04:06 +00:00 committed by GitHub
parent 15f12073cf
commit 010523eeac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,6 +42,15 @@ interface IReactionAdd {
emoji: ReactionEmoji; emoji: ReactionEmoji;
} }
interface IVoiceChannelEffectSendEvent {
type: string;
emoji?: ReactionEmoji; // Just in case...
channelId: string;
userId: string;
animationType: number;
animationId: number;
}
const MOYAI = "🗿"; const MOYAI = "🗿";
const MOYAI_URL = const MOYAI_URL =
"https://raw.githubusercontent.com/MeguminSama/VencordPlugins/main/plugins/moyai/moyai.mp3"; "https://raw.githubusercontent.com/MeguminSama/VencordPlugins/main/plugins/moyai/moyai.mp3";
@ -77,14 +86,24 @@ export default definePlugin({
boom(); boom();
}, },
onVoiceChannelEffect(e: IVoiceChannelEffectSendEvent) {
if (!e.emoji?.name) return;
const name = e.emoji.name.toLowerCase();
if (name !== MOYAI && !name.includes("moyai") && !name.includes("moai")) return;
boom();
},
start() { start() {
FluxDispatcher.subscribe("MESSAGE_CREATE", this.onMessage); FluxDispatcher.subscribe("MESSAGE_CREATE", this.onMessage);
FluxDispatcher.subscribe("MESSAGE_REACTION_ADD", this.onReaction); FluxDispatcher.subscribe("MESSAGE_REACTION_ADD", this.onReaction);
FluxDispatcher.subscribe("VOICE_CHANNEL_EFFECT_SEND", this.onVoiceChannelEffect);
}, },
stop() { stop() {
FluxDispatcher.unsubscribe("MESSAGE_CREATE", this.onMessage); FluxDispatcher.unsubscribe("MESSAGE_CREATE", this.onMessage);
FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD", this.onReaction); FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD", this.onReaction);
FluxDispatcher.unsubscribe("VOICE_CHANNEL_EFFECT_SEND", this.onVoiceChannelEffect);
}, },
options: { options: {