added confetti on command /confetti

This commit is contained in:
nurjinn jafar 2020-08-24 10:43:41 +02:00
parent 69227dd456
commit 34cee20140

View file

@ -45,6 +45,7 @@ import { ViewUserPayload } from "./dispatcher/payloads/ViewUserPayload";
import { Action } from "./dispatcher/actions"; import { Action } from "./dispatcher/actions";
import { EffectiveMembership, getEffectiveMembership } from "./utils/membership"; import { EffectiveMembership, getEffectiveMembership } from "./utils/membership";
import {func} from "prop-types"; import {func} from "prop-types";
import SettingsStore from "./settings/SettingsStore";
// XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816 // XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816
interface HTMLInputEvent extends Event { interface HTMLInputEvent extends Event {
@ -1029,15 +1030,24 @@ export const Commands = [
}), }),
new Command({ new Command({
command: "confetti", command: "confetti",
description: _td("Throws confetti animation in the chat room"), description: _td("Sends the given message with confetti"),
args: '/confetti + <message>', args: '<message>',
runFn: function(roomId, args, command) { runFn: function(roomId, args) {
return success((async () => { return success((async () => {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
await cli.sendHtmlMessage(roomId, args); const userId = cli.getUserId();
const userName = userId.slice(1).split(":").slice(0, 1);
const isChatEffectsDisabled = SettingsStore.getValue('dontShowChatEffects');
if (!args || isChatEffectsDisabled) {
args = '*' + userName + _td(' sends confetti');
}
if (!isChatEffectsDisabled) {
dis.dispatch({action: 'confetti'});
}
cli.sendHtmlMessage(roomId, args);
})()); })());
}, },
category: CommandCategories.messages, category: CommandCategories.actions,
}), }),
// Command definitions for autocompletion ONLY: // Command definitions for autocompletion ONLY: