private async Task _client_MessagesBulkDeleted(System.Collections.Generic.IReadOnlyCollection <Cacheable <IMessage, ulong> > messages, ISocketMessageChannel channel) { ulong guildID = ((SocketTextChannel)channel).Guild.Id; StringBuilder fieldValue = new StringBuilder(); foreach (Cacheable <IMessage, ulong> cached in messages) { fieldValue.Append(cached.Id + ", "); } var origField = new EmbedFieldBuilder() .WithName(messages.Count + " Messages Deleted") .WithValue(fieldValue.ToString()); var footer = new EmbedFooterBuilder() .WithIconUrl(_client.CurrentUser.GetAvatarUrl()) .WithText("ArbitiesLog"); var embed = new EmbedBuilder() .AddField(origField) .WithFooter(footer) .WithColor(Color.Red) .Build(); GuildData guildData = await GuildManager.GetGuildData(guildID); await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed); }
private async Task _client_UserJoined(SocketGuildUser user) { ulong guildID = user.Guild.Id; LogMessage msg = new LogMessage(LogSeverity.Info, "EventLogger", $"User {user.Id} Joined Guild {guildID}!"); Log(msg); var creationTime = user.CreatedAt.UtcDateTime; TimeSpan timeExisted = DateTimeOffset.UtcNow - creationTime; var origField = new EmbedFieldBuilder() .WithName("New User Joined") .WithValue(user.Username); var timeField = new EmbedFieldBuilder() .WithName("Account Age") .WithValue(timeExisted.ToString()); var footer = new EmbedFooterBuilder() .WithIconUrl(_client.CurrentUser.GetAvatarUrl()) .WithText("ArbitiesLog"); var embed = new EmbedBuilder() .WithImageUrl(user.GetAvatarUrl(ImageFormat.Auto, 512)) .AddField(origField) .AddField(timeField) .WithFooter(footer) .WithColor(Color.Green) .Build(); GuildData guildData = await GuildManager.GetGuildData(guildID); await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed); }
static public async Task SetGuildData(GuildData data) { JsonSerializerOptions options = new JsonSerializerOptions { WriteIndented = true }; string jsonOut = JsonSerializer.Serialize(data, options); await File.WriteAllTextAsync("Config/" + data.GuildID + ".json", jsonOut); }
private async Task _client_GuildMemberUpdated(SocketUser arg1, SocketUser arg2) { ulong guildID = ((SocketGuildUser)arg1).Guild.Id; LogMessage msg = new LogMessage(LogSeverity.Info, "EventLogger", $"User {arg1.Id} in Guild {guildID} Updated!"); Log(msg); SocketGuildUser userStart = (SocketGuildUser)arg1; SocketGuildUser userEnd = (SocketGuildUser)arg2; string actionTaken = "Should Not Be Seen"; StringBuilder fieldValue = new StringBuilder(); if (userStart.Roles.Count != userEnd.Roles.Count) { if (userStart.Roles.Count < userEnd.Roles.Count) { //Role Added IEnumerable differentRoles = userEnd.Roles.Except(userStart.Roles); actionTaken = "Role(s) Added"; foreach (SocketRole role in differentRoles) { fieldValue.Append(role.Name + "\n"); } } else { //Role Removed IEnumerable differentRoles = userStart.Roles.Except(userEnd.Roles); actionTaken = "Role(s) Removed"; foreach (SocketRole role in differentRoles) { fieldValue.Append(role.Name + "\n"); } } } else if (userStart.Nickname != userEnd.Nickname) { actionTaken = "Nickname Changed"; fieldValue.Append(userStart.Nickname + " --> " + userEnd.Nickname); } var origField = new EmbedFieldBuilder() .WithName(actionTaken) .WithValue(fieldValue.ToString()); var footer = new EmbedFooterBuilder() .WithIconUrl(_client.CurrentUser.GetAvatarUrl()) .WithText("ArbitiesLog"); var embed = new EmbedBuilder() .WithImageUrl(userStart.GetAvatarUrl(ImageFormat.Auto, 512)) .AddField(origField) .WithFooter(footer) .WithColor(Color.Gold) .Build(); GuildData guildData = await GuildManager.GetGuildData(guildID); await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed); }
public async Task SetLogAsync(SocketChannel channel) { ulong chanID = channel.Id; if (GuildManager.CheckGuildData(Context.Guild.Id)) { GuildData data = await GuildManager.GetGuildData(Context.Guild.Id); data.LogChannel = chanID; await GuildManager.SetGuildData(data); } else { GuildData data = new GuildData { GuildID = Context.Guild.Id, LogChannel = chanID }; await GuildManager.SetGuildData(data); } }
private async Task _client_UserLeft(SocketGuildUser user) { ulong guildID = user.Guild.Id; LogMessage msg = new LogMessage(LogSeverity.Info, "EventLogger", $"User {user.Id} Left Guild {guildID}!"); Log(msg); var origField = new EmbedFieldBuilder() .WithName("User Left") .WithValue(user.Username); var footer = new EmbedFooterBuilder() .WithIconUrl(_client.CurrentUser.GetAvatarUrl()) .WithText("ArbitiesLog"); var embed = new EmbedBuilder() .WithImageUrl(user.GetAvatarUrl(ImageFormat.Auto, 512)) .AddField(origField) .WithFooter(footer) .WithColor(Color.Red) .Build(); GuildData guildData = await GuildManager.GetGuildData(guildID); await((SocketTextChannel)_client.GetChannel(guildData.LogChannel)).SendMessageAsync(embed: embed); }