fix(Moyai): not playing sound when reacting
This commit is contained in:
parent
ba5c4fe706
commit
400398829e
2 changed files with 9 additions and 3 deletions
|
|
@ -13,6 +13,6 @@
|
|||
],
|
||||
"main": "src/index.ts",
|
||||
"vendetta": {
|
||||
"icon": "ic_speaker"
|
||||
"icon": "VoiceNormalIcon"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,15 +64,20 @@ function onMessage(event) {
|
|||
}
|
||||
}
|
||||
|
||||
const recentReactions = new Set<string>();
|
||||
|
||||
function onReaction(event) {
|
||||
try {
|
||||
if (
|
||||
(storage.allowReactions ?? true) &&
|
||||
event.channelId == SelectedChannelStore.getChannelId() &&
|
||||
!event.optimistic
|
||||
event.channelId == SelectedChannelStore.getChannelId()
|
||||
) {
|
||||
const name = event.emoji?.name;
|
||||
if (name === "🗿" || (name && /moy?ai/i.test(name))) {
|
||||
const key = `${event.messageId}:${name}`;
|
||||
if (recentReactions.has(key)) return;
|
||||
recentReactions.add(key);
|
||||
setTimeout(() => recentReactions.delete(key), 500);
|
||||
playSound();
|
||||
}
|
||||
}
|
||||
|
|
@ -97,6 +102,7 @@ export default {
|
|||
onUnload: () => {
|
||||
FluxDispatcher.unsubscribe("MESSAGE_CREATE", onMessage);
|
||||
FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD", onReaction);
|
||||
recentReactions.clear();
|
||||
},
|
||||
settings: MoyaiSettings,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue