mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
Add export option to mutes command
This commit is contained in:
parent
af360eaa73
commit
d82f88bc24
1 changed files with 19 additions and 1 deletions
|
@ -16,6 +16,7 @@ import {
|
||||||
ucfirst,
|
ucfirst,
|
||||||
UnknownUser,
|
UnknownUser,
|
||||||
UserNotificationMethod,
|
UserNotificationMethod,
|
||||||
|
trimLines,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
import humanizeDuration from "humanize-duration";
|
import humanizeDuration from "humanize-duration";
|
||||||
import { LogType } from "../data/LogType";
|
import { LogType } from "../data/LogType";
|
||||||
|
@ -28,6 +29,7 @@ import { CaseArgs, CasesPlugin } from "./Cases";
|
||||||
import { Case } from "../data/entities/Case";
|
import { Case } from "../data/entities/Case";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { ERRORS, RecoverablePluginError } from "../RecoverablePluginError";
|
import { ERRORS, RecoverablePluginError } from "../RecoverablePluginError";
|
||||||
|
import { GuildArchives } from "src/data/GuildArchives";
|
||||||
|
|
||||||
const ConfigSchema = t.type({
|
const ConfigSchema = t.type({
|
||||||
mute_role: tNullable(t.string),
|
mute_role: tNullable(t.string),
|
||||||
|
@ -83,6 +85,7 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
protected cases: GuildCases;
|
protected cases: GuildCases;
|
||||||
protected serverLogs: GuildLogs;
|
protected serverLogs: GuildLogs;
|
||||||
private muteClearIntervalId: NodeJS.Timer;
|
private muteClearIntervalId: NodeJS.Timer;
|
||||||
|
archives: GuildArchives;
|
||||||
|
|
||||||
public static getStaticDefaultOptions(): IPluginOptions<TConfigSchema> {
|
public static getStaticDefaultOptions(): IPluginOptions<TConfigSchema> {
|
||||||
return {
|
return {
|
||||||
|
@ -123,6 +126,7 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
this.mutes = GuildMutes.getGuildInstance(this.guildId);
|
this.mutes = GuildMutes.getGuildInstance(this.guildId);
|
||||||
this.cases = GuildCases.getGuildInstance(this.guildId);
|
this.cases = GuildCases.getGuildInstance(this.guildId);
|
||||||
this.serverLogs = new GuildLogs(this.guildId);
|
this.serverLogs = new GuildLogs(this.guildId);
|
||||||
|
this.archives = GuildArchives.getGuildInstance(this.guildId);
|
||||||
|
|
||||||
// Check for expired mutes every 5s
|
// Check for expired mutes every 5s
|
||||||
const firstCheckTime = Math.max(Date.now(), FIRST_CHECK_TIME) + FIRST_CHECK_INCREMENT;
|
const firstCheckTime = Math.max(Date.now(), FIRST_CHECK_TIME) + FIRST_CHECK_INCREMENT;
|
||||||
|
@ -380,10 +384,15 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
name: "left",
|
name: "left",
|
||||||
isSwitch: true,
|
isSwitch: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "export",
|
||||||
|
shortcut: "e",
|
||||||
|
isSwitch: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@d.permission("can_view_list")
|
@d.permission("can_view_list")
|
||||||
protected async muteListCmd(msg: Message, args: { age?: number; left?: boolean }) {
|
protected async muteListCmd(msg: Message, args: { age?: number; left?: boolean; export?: boolean }) {
|
||||||
const lines = [];
|
const lines = [];
|
||||||
|
|
||||||
// Create a loading message as this can potentially take some time
|
// Create a loading message as this can potentially take some time
|
||||||
|
@ -507,6 +516,15 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
message = hasFilters ? "No mutes found with the specified filters!" : "No active mutes!";
|
message = hasFilters ? "No mutes found with the specified filters!" : "No active mutes!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.export) {
|
||||||
|
const archiveId = await this.archives.create(trimLines(message), moment().add(1, "hour"));
|
||||||
|
const url = await this.archives.getUrl(this.knub.getGlobalConfig().url, archiveId);
|
||||||
|
|
||||||
|
await msg.channel.createMessage(`Exported mutes results: ${url}`);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await loadingMessage.delete().catch(noop);
|
await loadingMessage.delete().catch(noop);
|
||||||
const chunks = chunkMessageLines(message);
|
const chunks = chunkMessageLines(message);
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue