public static ModlogEntry CreateNew(ModlogType type, String reason) { return(new ModlogEntry { Type = type, Reason = reason, Time = DateTime.UtcNow }); }
public static async Task <Embed> CreateModlog(SocketGuild guild, SocketUser caller, SocketUser user, ModlogType type, string Reason = null) { var guildObj = FileSystem.GetGuild(guild); var guilduser = guildObj.GuildUsers.Where(x => x.ID == user.Id).First(); if (!guildObj.AllowModlog) { throw new OperationCanceledException("Modlog isn't enabled on this server\nUse //setmodlogchannel to enable modlog"); } var embed = new EmbedBuilder(); Embed Result = null; switch (type) { case ModlogType.Ban: Result = embed .WithColor(Color.Red) .WithCurrentTimestamp() .WithTitle($"[#{guildObj.ModlogCount + 1}] {caller.ToString()} banned {user.ToString()} from the server") .WithDescription($"**Reason:** {Reason ?? "No reason given"}") .Build(); break; case ModlogType.Kick: Result = embed .WithColor(Color.Orange) .WithCurrentTimestamp() .WithTitle($"[#{guildObj.ModlogCount + 1}] {caller.ToString()} kicked {user.ToString()} from the server") .WithDescription($"**Reason:** {Reason ?? "No reason given"}") .Build(); break; case ModlogType.Muted: Result = embed .WithColor(Color.Purple) .WithCurrentTimestamp() .WithTitle($"[#{guildObj.ModlogCount + 1}] {caller.ToString()} muted {user.ToString()}") .WithDescription($"**Reason:** {Reason ?? "No reason given"}") .Build(); break; case ModlogType.Warn: guilduser = guilduser.IncreaseWarnCount(); guildObj.SetGuildUser(guilduser); Result = embed .WithColor(Color.Gold) .WithCurrentTimestamp() .WithTitle($"[#{guildObj.ModlogCount + 1}] {caller.ToString()} warned {user.ToString()}") .WithDescription($"{user.Username} has a total of {guilduser.WarnCount} now\n**Reason:** {Reason ?? "No reason given"}") .Build(); break; case ModlogType.Unmuted: Result = embed .WithColor(Color.Purple) .WithCurrentTimestamp() .WithTitle($"[#{guildObj.ModlogCount + 1}] {caller.ToString()} unmuted {user.ToString()}") .WithDescription($"**Reason:** {Reason ?? "No reason given"}") .Build(); break; case ModlogType.Pardon: guilduser = guilduser.DecreaseWarnCount(); guildObj.SetGuildUser(guilduser); Result = embed .WithColor(Color.Green) .WithCurrentTimestamp() .WithTitle($"[#{guildObj.ModlogCount + 1}] {caller.ToString()} pardoned {user.ToString()} and a warn has been removed") .WithDescription($"{user.Username} has a total of {guilduser.WarnCount} now\n**Reason:** {Reason ?? "No reason given"}") .Build(); break; } guildObj = guildObj.IncreaseModlogCount(); await FileSystem.SetGuild(guildObj); return(Result); }
public void AddModlogEntry(ModlogType type, String reason) { ModlogCount++; Modlog.Add(ModlogEntry.CreateNew(type, reason)); }