Skip to content

Instantly share code, notes, and snippets.

@debdutdeb
Created August 23, 2022 21:02
Show Gist options
  • Save debdutdeb/4fcb5fa6e4082f361aa9022572f9c107 to your computer and use it in GitHub Desktop.
Save debdutdeb/4fcb5fa6e4082f361aa9022572f9c107 to your computer and use it in GitHub Desktop.
import {
IRead,
IModify,
IHttp,
IPersistence,
} from "@rocket.chat/apps-engine/definition/accessors";
import {
ISlashCommand,
SlashCommandContext,
} from "@rocket.chat/apps-engine/definition/slashcommands";
export class ArchiveCommand implements ISlashCommand {
public command: string = "archivea";
public i18nParamsExample: string = "";
public i18nDescription: string = "";
public providesPreview: boolean = false;
public async executor(
context: SlashCommandContext,
read: IRead,
modify: IModify,
http: IHttp,
persis: IPersistence
): Promise<void> {
const success = await modify
.getUpdater()
.getRoomUpdater()
.archiveRoom(context.getRoom());
}
}
import {
IAppAccessors,
IConfigurationExtend,
IEnvironmentRead,
ILogger,
} from "@rocket.chat/apps-engine/definition/accessors";
import { App } from "@rocket.chat/apps-engine/definition/App";
import { IAppInfo } from "@rocket.chat/apps-engine/definition/metadata";
import { ArchiveCommand } from "./commands/ArchiveCommand";
export class ArchiveRoomApp extends App {
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
super(info, logger, accessors);
}
protected async extendConfiguration(
configuration: IConfigurationExtend,
environmentRead: IEnvironmentRead
): Promise<void> {
await configuration.slashCommands.provideSlashCommand(
new ArchiveCommand()
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment