3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Add Logs plugin and GuildServerLogs class to communicate with it

This commit is contained in:
Dragory 2018-07-09 02:48:36 +03:00
parent 8234f67b0f
commit c087654979
5 changed files with 188 additions and 3 deletions

View file

@ -0,0 +1,26 @@
import * as EventEmitter from "events";
import { LogType } from "./LogType";
// Use the same instance for the same guild, even if a new instance is created
const guildInstances: Map<string, GuildServerLogs> = new Map();
export class GuildServerLogs extends EventEmitter {
protected guildId: string;
constructor(guildId) {
if (guildInstances.has(guildId)) {
// Return existing instance for this guild if one exists
return guildInstances.get(guildId);
}
super();
this.guildId = guildId;
// Store the instance for this guild so it can be returned later if a new instance for this guild is requested
guildInstances.set(guildId, this);
}
log(type: LogType, data: any) {
this.emit("log", { type, data });
}
}

34
src/data/LogType.ts Normal file
View file

@ -0,0 +1,34 @@
export enum LogType {
MEMBER_WARN = 1,
MEMBER_MUTE,
MEMBER_UNMUTE,
MEMBER_KICK,
MEMBER_BAN,
MEMBER_JOIN,
MEMBER_LEAVE,
MEMBER_ROLE_ADD,
MEMBER_ROLE_REMOVE,
MEMBER_NICK_CHANGE,
MEMBER_USERNAME_CHANGE,
MEMBER_ROLES_RESTORE,
CHANNEL_CREATE,
CHANNEL_DELETE,
CHANNEL_EDIT,
ROLE_CREATE,
ROLE_DELETE,
MESSAGE_EDIT,
MESSAGE_DELETE,
MESSAGE_DELETE_BULK,
VOICE_CHANNEL_JOIN,
VOICE_CHANNEL_LEAVE,
VOICE_CHANNEL_MOVE,
COMMAND,
SPAM_DELETE,
CENSOR
}