private static Embed GenerateDefaultEmbed(DisciplinaryEventEnum eventType, TimeSpan timeSpan, string reason, string targetName, bool existing, string author) { try { string commandName = ReturnEventTypeString(eventType); string duration = "Permanent."; if (timeSpan.TotalDays >= 1) { duration = $"{Math.Round(timeSpan.TotalDays, 2)} day{SAppend(timeSpan.TotalDays)}."; } else if (timeSpan.TotalHours >= 1) { duration = $"{Math.Round(timeSpan.TotalHours, 2)} hour{SAppend(timeSpan.TotalHours)}."; } else if (timeSpan.TotalMinutes >= 1) { duration = $"{Math.Round(timeSpan.TotalMinutes, 2)} min{SAppend(timeSpan.TotalMinutes)}."; } else if (timeSpan.TotalSeconds >= 1) { duration = $"{Math.Round(timeSpan.TotalSeconds, 2)} sec{SAppend(timeSpan.TotalSeconds)}."; } Emote emote = duration == "Permanent" ? DiscordContextSeymour.GetEmoteReee() : DiscordContextSeymour.GetEmoteAyySeymour(); string existingDisciplinary = String.Empty; if (existing) { existingDisciplinary = " updated to"; } var embed = new EmbedBuilder(); embed.WithTitle($"{author} {commandName} {targetName} {emote.ToString()}"); embed.WithDescription($"Reason: {reason}\nDuration{existingDisciplinary}: {duration}"); embed.WithColor(new Color(255, 0, 0)); return(embed.Build()); } catch (Exception ex) { ExceptionManager.HandleException($"{typeof(Utilities).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex); throw; } }
public static Embed BuildBlacklistEmbed(TimeSpan timeSpan, string username, bool existing, string author = "SeymourBot") { try { string commandName = "blacklisted"; string duration = "1 month"; if (timeSpan.TotalDays >= 1) { duration = $"{Math.Round(timeSpan.TotalDays, 2)} day{SAppend(timeSpan.TotalDays)}."; } else if (timeSpan.TotalHours >= 1) { duration = $"{Math.Round(timeSpan.TotalHours, 2)} hour{SAppend(timeSpan.TotalHours)}."; } else if (timeSpan.TotalMinutes >= 1) { duration = $"{Math.Round(timeSpan.TotalMinutes, 2)} min{SAppend(timeSpan.TotalMinutes)}."; } Emote emote = duration == "Permanent" ? DiscordContextSeymour.GetEmoteReee() : DiscordContextSeymour.GetEmoteAyySeymour(); string existingDisciplinary = String.Empty; if (existing) { existingDisciplinary = " updated to"; } var embed = new EmbedBuilder(); embed.WithTitle($"{author} {commandName} {username} {emote.ToString()}"); embed.WithDescription($"Duration{existingDisciplinary}: {duration}"); embed.WithColor(new Color(255, 0, 0)); return(embed.Build()); } catch (Exception ex) { ExceptionManager.HandleException($"{typeof(Utilities).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex); throw; } }
private async Task ExileUserAsync(ulong userID) { try { SocketGuildUser user = Context.Guild.GetUser(userID); if (await DiscordContextSeymour.IsUserDevOrAdminAsync(user as SocketGuildUser)) { return; } ulong peasantRoleID = ConfigManager.GetUlongProperty(PropertyItem.Role_Peasant); var roleToApply = Context.Guild.GetRole(peasantRoleID); var rolesToRemove = user.Roles.Where(x => x.IsEveryone == false); var embed = new EmbedBuilder(); embed.WithTitle($"{user.Username} has been stripped of their lands and titles, and banished to the gate {DiscordContextSeymour.GetEmoteReee()}"); embed.WithColor(new Color(255, 0, 0)); await Context.Channel.SendMessageAsync("", false, embed.Build()); await user.RemoveRolesAsync(rolesToRemove); await user.AddRoleAsync(roleToApply); await DiscordContextOverseer.LogModerationAction(userID, "Exiled", Context.Message.Author.Id, "", ""); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.ExileException, ex); } }
private async Task RaidprotectEnableAsync() { try { var chnl = Context.Channel as ITextChannel; var permOverride = new OverwritePermissions(sendMessages: PermValue.Deny); await Context.Channel.SendMessageAsync($"This channel is now silenced. {DiscordContextSeymour.GetEmoteReee()}"); await chnl.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, permOverride); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.RaidprotectException, ex); } }