The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/slashcommands-topic/client/topic.ts

28 lines
1.0 KiB

import type { SlashCommandCallbackParams } from '@rocket.chat/core-typings';
import { slashCommands } from '../../utils/lib/slashCommand';
import { ChatRoom } from '../../models/client/models/ChatRoom';
import { callbacks } from '../../../lib/callbacks';
import { hasPermission } from '../../authorization/client';
import { dispatchToastMessage } from '../../../client/lib/toast';
import { sdk } from '../../utils/client/lib/SDKClient';
slashCommands.add({
command: 'topic',
callback: async function Topic({ params, message }: SlashCommandCallbackParams<'topic'>): Promise<void> {
if (hasPermission('edit-room', message.rid)) {
try {
await sdk.call('saveRoomSettings', message.rid, 'roomTopic', params);
await callbacks.run('roomTopicChanged', ChatRoom.findOne(message.rid));
} catch (error: unknown) {
dispatchToastMessage({ type: 'error', message: error });
throw error;
}
}
},
options: {
description: 'Slash_Topic_Description',
params: 'Slash_Topic_Params',
permission: 'edit-room',
},
});