Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e3d1615

Browse files
authored
Make /msg <message> param optional for more flexibility (#7028)
1 parent ead2a51 commit e3d1615

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: src/SlashCommands.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1014,22 +1014,24 @@ export const Commands = [
10141014
new Command({
10151015
command: "msg",
10161016
description: _td("Sends a message to the given user"),
1017-
args: "<user-id> <message>",
1017+
args: "<user-id> [<message>]",
10181018
runFn: function(roomId, args) {
10191019
if (args) {
10201020
// matches the first whitespace delimited group and then the rest of the string
10211021
const matches = args.match(/^(\S+?)(?: +(.*))?$/s);
10221022
if (matches) {
10231023
const [userId, msg] = matches.slice(1);
1024-
if (msg && userId && userId.startsWith("@") && userId.includes(":")) {
1024+
if (userId && userId.startsWith("@") && userId.includes(":")) {
10251025
return success((async () => {
10261026
const cli = MatrixClientPeg.get();
10271027
const roomId = await ensureDMExists(cli, userId);
10281028
dis.dispatch({
10291029
action: 'view_room',
10301030
room_id: roomId,
10311031
});
1032-
cli.sendTextMessage(roomId, msg);
1032+
if (msg) {
1033+
cli.sendTextMessage(roomId, msg);
1034+
}
10331035
})());
10341036
}
10351037
}

0 commit comments

Comments
 (0)