public async Task GetInboundChannelAsync(SocketGuild g, Server s) { if (s.Config.InboundChannel == 0) { Embed e = EmbedData.Throw(Context, $"**CrossChat** is currently unbound to a channel."); await ReplyAsync(embed : e); return; } if (!g.TryGetTextChannel(s.Config.InboundChannel, out SocketTextChannel c)) { Embed e = EmbedData.Throw(Context, $"{g.Name} is lacking the saved channel.", "This channel no longer exists, and the inbound channel will now be reset.", false); await ReplyAsync(embed : e); // find a default value. s.Config.InboundChannel = 0; return; } EmbedBuilder emb = EmbedData.DefaultEmbed; emb.WithColor(EmbedData.GetColor("error")); emb.WithDescription($"**CrossChat** is currently bound to {c.Mention}."); await ReplyAsync(embed : emb.Build()); }
public async Task ContinueQueueAsync() { var displayEmbed = new EmbedBuilder(); displayEmbed.WithColor(EmbedData.GetColor("yield")); displayEmbed.WithTitle("Continuing queue."); displayEmbed.WithDescription("Please wait..."); var selfVoice = Context.Guild.GetCurrentUserAsync().Result.VoiceChannel ?? null; var contextVoice = (Context.User as IGuildUser).VoiceChannel ?? null; if (contextVoice == null && selfVoice == null) { await ReplyAsync("`I need a channel to connect to in order to play audio.`"); return; } else if (selfVoice == null) { await _audio.JoinVoiceChannel(Context.Guild, contextVoice); } if (_audio.Queue(Context.Guild).Count.Equals(0) || _audio.Stream(Context.Guild)) { return; } //await ConnectAsync(); var display = await ReplyAsync(null, false, displayEmbed.Build()); await _audio.CheckQueue(Context.Guild, Context.Channel, display); }
public static Embed RoleAssignTemplate() { List <WerewolfRole> roles = WerewolfManager.GenerateRoles(8, out WerewolfTickGenerator t); List <string> addedroles = new List <string>(); string shift = $"{(t.Shift > 0 ? "+" : "")}{t.Shift} Equinox"; EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("error")); StringBuilder sb = new StringBuilder(); sb.AppendLine("**Assigning Roles...**\n"); foreach (WerewolfRole role in roles) { if (addedroles.Contains(role.Name)) { continue; } string pv = role.PointValue > 0 ? $"+{role.PointValue}" : $"{role.PointValue}"; sb.AppendLine($"**x{roles.InstanceCount(role)}** | {role.Name.MarkdownBold()} ({pv})"); sb.AppendLine($"{role.Summary}"); addedroles.Add(role.Name); } e.WithDescription(sb.ToString()); e.WithFooter($"{shift} | {t.PlayerCount} Players"); return(e.Build()); }
public async Task WagerDiceRollRangeAsync(OldAccount a, int wager, int size, int midpoint, bool dir = false) { Dice d = new Dice(size); int min = dir ? 1 : 2; int max = dir ? (size - 1) : size; // exception catchers. if (!midpoint.IsInRange(min, max)) { EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("error")); if (!a.Config.Overflow) { await ReplyAsync(embed : EmbedData.Throw(Context, "Midpoint out of range.", $"The midpoint must be inside the range of {min} to {max}.", false)); return; } midpoint = midpoint.InRange(min, max); } CasinoResult outcome = CasinoService.BetRangedRoll(a, d, wager, midpoint, dir); await ReplyAsync(embed : outcome.Generate()); }
// bet on a dice roll with n amount of sides // choose the sides that you think it will land on. public async Task WagerDiceRollAsync(OldAccount a, int wager, int size, params int[] clear) { EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("error")); Dice d = new Dice(size); string err = ""; if (clear.Length == 0) { err = "You need to at least place one landing point."; await ReplyAsync(embed : EmbedData.Throw(Context, "Empty landing points.", err, false)); return; } if (clear.Length > (d.Sides - 1)) { err = $"You can only place up to {d.Sides - 1} landing points."; await ReplyAsync(embed : EmbedData.Throw(Context, "Max landing points hit.", err, false)); return; } List <int> called = new List <int>(); foreach (int safe in clear) { if (safe > d.Sides) { err = $"You can't place a landing point higher than {d.Sides}."; await ReplyAsync(embed : EmbedData.Throw(Context, "Landing point out of range.", err, false)); return; } if (safe.EqualsAny(called)) { err = "You cannot place a landing point on a side twice."; await ReplyAsync(embed : EmbedData.Throw(Context, "Duplicate landing point.", err, false)); return; } else { called.Add(safe); } } CasinoResult outcome = CasinoService.BetSelectiveRoll(a, d, wager, clear); await ReplyAsync(embed : outcome.Generate()); }
public async Task GamesResponseAsync() { WerewolfGame g = new WerewolfGame(); EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("error")); e.WithTitle("Ori's Arcade Zone"); e.WithDescription($"{g.Status} **{g.Name}**\n{g.Summary}");//"The arcade is currently closed. Please hang tight while the arcade is being repaired. Sorry about that."); e.WithFooter("The arcade is currently closed. :("); await ReplyAsync(embed : e.Build()); }
public static Embed DeathTemplate() { EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("error")); StringBuilder sb = new StringBuilder(); sb.AppendLine($"**PLAYER_NAME** has died. {GetRandomDeathCause()}"); sb.AppendLine($"PLAYER_NAME proved themselves to be many things, but they preferred that you call them a **{WerewolfManager.GetAnyRole().Name}**."); // <Description based on player's influence> e.WithDescription(sb.ToString()); return(e.Build()); }
public static Embed RoleGenerationTemplate() { EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("yield")); StringBuilder sb = new StringBuilder(); sb.AppendLine("Generating Roles...".MarkdownBold()); e.WithDescription(sb.ToString()); e.WithFooter(GetFact()); return(e.Build()); }
public async Task ViewCrossChatAsync(Server s) { SocketGuild g = s.Guild(Context.Client); EmbedBuilder e = EmbedData.DefaultEmbed; StringBuilder sb = new StringBuilder(); sb.Append(s.Config.CrossChat ? "**CrossChat** is active" : "**CrossChat** is currently disabled."); if (s.Config.CrossChat) { bool hasDefault = Context.TryGetPrimaryChatChannel(g, out SocketTextChannel def); if (s.Config.InboundChannel > 0) { if (!g.TryGetTextChannel(s.Config.InboundChannel, out SocketTextChannel inb)) { sb.AppendLine(", but is missing the inbound channel."); if (hasDefault) { sb.AppendLine($"All messages will be sent to {def.Mention}."); } else { sb.AppendLine("No messages can be received at this time, due to the lack of a default chat channel."); } } else { sb.AppendLine($", and is bound to {inb.Mention}."); } } else { sb.AppendLine(", but is currently unbound to a channel."); if (hasDefault) { sb.AppendLine($"All messages will be sent to {def.Mention}."); } else { sb.AppendLine("No messages can be received at this time, due to the lack of a default chat channel."); } } } else { e.WithColor(EmbedData.GetColor("error")); } e.WithDescription(sb.ToString()); await ReplyAsync(embed : e.Build()); }
private Embed GetGambleError(OldAccount a, ulong wager) { EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("error")); StringBuilder su = new StringBuilder(); su.AppendLine($"Hello, {a.GetName()}."); su.AppendLine($"As you may know, I was accidently shut down during a wager you placed, and for that, I am sorry."); su.Append($"I have returned {EmojiIndex.Balance}{wager.ToPlaceValue().MarkdownBold()} to your wallet."); e.WithDescription(su.ToString()); return(e.Build()); }
public static Embed SecondMotionTemplate() { EmbedBuilder e = new EmbedBuilder(); StringBuilder sb = new StringBuilder(); e.WithTitle("An accusation has been made!"); e.WithColor(EmbedData.GetColor("owo")); sb.AppendLine("**PLAYER_NAME_A** has seen enough of **PLAYER_NAME_B**'s tactics, and has accused them of being a **Werewolf**!"); sb.AppendLine("Is there anybody else that follows through?"); //sb.AppendLine("<10 seconds for anyone else to agree for trial>"); e.WithDescription(sb.ToString()); EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithText("10 seconds until the window closes."); e.WithFooter(f); return(e.Build()); }
public async Task SetPlayAsync() { if (!_audio.Stream(Context.Guild)) { return; } if (_audio.IsPlaying(Context.Guild)) { return; } _audio.SetOutput(Context.Guild, true); var oriGreen = EmbedData.GetColor("origreen"); var displayEmbed = new EmbedBuilder(); displayEmbed.WithColor(oriGreen); displayEmbed.WithTitle("The queue is now playing."); await ReplyAsync(null, false, displayEmbed.Build()); }
public async Task SetPauseAsync() { if (!_audio.Stream(Context.Guild)) { return; } if (!_audio.IsPlaying(Context.Guild)) { return; } var yieldColor = EmbedData.GetColor("yield"); _audio.SetOutput(Context.Guild, false); var displayEmbed = new EmbedBuilder(); displayEmbed.WithColor(yieldColor); displayEmbed.WithTitle("The queue has been paused."); await ReplyAsync(null, false, displayEmbed.Build()); }
public EmbedBuilder GenerateChatBox(OldAccount a, Server s, SocketGuild g, string content) { string command = "message"; List <string> demobl = new List <string> { "darn" }; List <string> blacklist = Context.Data.Blacklist.Merge(s.Config.Blacklist, demobl); EmbedBuilder e = new EmbedBuilder(); EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithText($"{s.Config.GetPrefix(Context)}{command} {Context.Guild.Id} <{nameof(content)}>"); e.WithColor(EmbedData.GetColor("origreen")); e.WithDescription(s.Config.SafeChat ? content.Guard(blacklist).Escape('*') : content); e.WithTitle($"{EmojiIndex.CrossChat.Pack(a)} {a.GetName()}"); e.WithFooter(f); return(e); }
public async Task TogglePlayAsync() { if (!_audio.Stream(Context.Guild)) { return; } _audio.SetOutput(Context.Guild, !_audio.IsPlaying(Context.Guild)); var displayEmbed = new EmbedBuilder(); var yieldColor = EmbedData.GetColor("yield"); displayEmbed.WithColor(yieldColor); displayEmbed.WithTitle("The queue has been paused."); if (_audio.IsPlaying(Context.Guild)) { var oriGreen = EmbedData.GetColor("origreen"); displayEmbed.WithColor(oriGreen); displayEmbed.WithTitle("The queue is now playing."); } await ReplyAsync(null, false, displayEmbed.Build()); }
public EmbedBuilder Generate(OldAccount a) { EmbedBuilder e = new EmbedBuilder(); Emoji icon = Type.Icon(); string user = $"{Author.Name}"; string subject = $"Subject: {Subject.MarkdownBold()}"; string title = $"{icon.Pack(a)} | {user} | {Command}\n{subject}"; string footer = $"Case: {Id}"; EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithText(footer); e.WithColor(EmbedData.GetColor("error")); e.WithTitle(title); e.WithDescription(Content); e.WithFooter(f); return(e); }
public async Task DisplayCurrentAudioAsync() { var queue = _audio.Queue(Context.Guild).ToList(); var displayEmbed = new EmbedBuilder(); var displayEmbedFooter = new EmbedFooterBuilder(); displayEmbed.WithColor(213, 16, 93); displayEmbed.WithTitle("Stopped:"); if (queue.Count == 0) { displayEmbed.WithDescription("Nothing is currently playing."); await ReplyAsync(null, false, displayEmbed.Build()); return; } var prevQueue = queue[0].Value; displayEmbed.WithDescription($"{prevQueue.Title} ({prevQueue.Duration})"); if (_audio.IsPlaying(Context.Guild)) { displayEmbed.WithColor(129, 243, 193); displayEmbed.WithTitle("Now playing:"); } else if (_audio.Stream(Context.Guild)) { displayEmbed.WithColor(EmbedData.GetColor("yield")); displayEmbed.WithTitle("Paused:"); } if (queue.Count == 1) { await ReplyAsync(null, false, displayEmbed.Build()); return; } var nextQueue = queue[1].Value; displayEmbed.WithFooter(displayEmbedFooter.WithText($"Up Next => {nextQueue.Title} ({nextQueue.Duration})")); var msg = await ReplyAsync(null, false, displayEmbed.Build()); }
public async Task SetSkipAsync() { if (_audio.Queue(Context.Guild).Count.Equals(0) || !_audio.Stream(Context.Guild)) { return; } var skipColor = EmbedData.GetColor("error"); if (!_audio.IsPlaying(Context.Guild)) { _audio.SetOutput(Context.Guild, true); _audio.RequestSkip(Context.Guild); } else { _audio.RequestSkip(Context.Guild); } var displayEmbed = new EmbedBuilder(); displayEmbed.WithColor(skipColor); displayEmbed.WithTitle("The current song has been skipped."); await ReplyAsync(null, false, displayEmbed.Build()); }
public async Task GetRandomCommandAsync() { IEnumerable <ModuleInfo> modules = Context.Data.Modules.Where(x => x.IsActive(_service.Modules)); List <IReadOnlyList <CommandInfo> > collection = new List <IReadOnlyList <CommandInfo> >(); foreach (ModuleInfo m in modules) { collection.Add(m.Commands); } List <CommandInfo> commands = new List <CommandInfo>(); foreach (IReadOnlyList <CommandInfo> coll in collection) { commands.Merge(coll.ToList()); } int n = RandomProvider.Instance.Next(1, collection.Count()) - 1; string info = $"{Context.Server.Config.Prefix ?? Context.Client.CurrentUser.Mention + " "}{commands[n].Name}"; EmbedBuilder e = EmbedData.DefaultEmbed; e.WithColor(EmbedData.GetColor("owo")); e.WithFooter($"{info} | Random Command"); await ReplyAsync(embed : e.Build()); }
public Embed Generate() { EmbedBuilder e = EmbedData.DefaultEmbed; EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithText(ToString()); // Colors Color onEmptyColor = EmbedData.GetColor("steamerror"); Color onLoseColor = EmbedData.GetColor("error"); Color onWinColor = EmbedData.GetColor("origreen"); // Titles string onWinTitle = "+ {0}"; string onLoseTitle = "- {0}"; string onOORTitle = "> {0}"; // Money display string money = $"{EmojiIndex.Balance}" + "{0}".MarkdownBold(); string defLoseDesc = "You lost at chance at {0}."; string defWinDesc = "You have earned " + "(x{0})".MarkdownBold() + " the initial bet!"; string defEmptyDesc = "You do know you need money, right?"; string defOORDesc = "You asked to wager a bit too much."; // exceptions based on balance. if (Player.Balance == 0) { e.WithColor(onEmptyColor); e.WithTitle(string.Format(money, "null")); e.WithDescription(defEmptyDesc); return(e.Build()); } if (Player.Balance - Wager < 0) { if (!Player.Config.Overflow) { e.WithColor(onEmptyColor); e.WithTitle(string.Format(onOORTitle, string.Format(money, Player.Balance.ToPlaceValue()))); e.WithDescription(defOORDesc); return(e.Build()); } Wager = Player.Balance; } Player.Take((ulong)Wager); e.WithFooter(f); if (Victory) { Player.Give((ulong)Reward); e.WithColor(onWinColor); e.WithTitle(string.Format(onWinTitle, string.Format(money, Reward.ToPlaceValue()))); e.WithDescription(string.Format(defWinDesc, Risk.ToString("##,0.0#"))); return(e.Build()); } else { e.WithColor(onLoseColor); e.WithTitle(string.Format(onLoseTitle, string.Format(money, Wager.ToPlaceValue()))); e.WithDescription(LosingSummary ?? string.Format(defLoseDesc, string.Format(money, Reward.ToPlaceValue()))); return(e.Build()); } }
// for gimme command. public async Task GetOrTakeWalletAsync(OldAccount a) { EmbedBuilder e = new EmbedBuilder(); Color give = EmbedData.GetColor("origreen"); Color golden = EmbedData.GetColor("yield"); Color take = EmbedData.GetColor("error"); Color pity = EmbedData.GetColor("steamerror"); int x = RandomProvider.Instance.Next(0, 1000 + 1); bool win = x >= 500; bool goldwin = x == 999; double reward = goldwin ? 999 : RandomProvider.Instance.Next(1, 10 + 1); string balance = $"{EmojiIndex.Balance}{reward.ToPlaceValue().MarkdownBold()}"; string debt = $"{EmojiIndex.Debt}{reward.ToPlaceValue().MarkdownBold()}"; string onGiveTitle = $"+ {balance}"; string onTakeTitle = $"- {balance}"; string onPityTitle = $"+ {debt}"; if (!a.TracksGimme) { a.GimmeStats = new GiveOrTakeAnalyzer(); } a.GimmeStats.Track(win, goldwin, (long)reward); StringBuilder f = new StringBuilder(); f.Append($"{EmojiIndex.TellerMachine} {x}.{reward} | "); if (win) { if (goldwin) { e.WithColor(golden); e.WithTitle(onGiveTitle); e.WithDescription(GoldenReply()); f.Append($"{a.GimmeStats.GoldenCount.ToPositionValue()} Golden"); } else { e.WithColor(give); e.WithTitle(onGiveTitle); e.WithDescription(GivenReply()); f.Append($"{(a.GimmeStats.WinStreak > 1 ? $"Wx{a.GimmeStats.WinStreak.ToPlaceValue()}" : $"{a.GimmeStats.WinCount.ToPlaceValue()} Win{(a.GimmeStats.WinCount > 1 ? "s" : "")}")}"); } a.Give((ulong)reward); } else { if (a.Balance - reward < 0) { e.WithColor(pity); e.WithTitle(onPityTitle); e.WithDescription(DebtReply()); a.Fine((ulong)reward); } else { e.WithColor(take); e.WithTitle(onTakeTitle); e.WithDescription(TakenReply(reward)); a.Take((ulong)reward); } f.Append($"{(a.GimmeStats.LossStreak > 1 ? $"Lx{a.GimmeStats.LossStreak.ToPlaceValue()}" : $"{a.GimmeStats.LossCount.ToPlaceValue()} Loss{(a.GimmeStats.LossCount > 1 ? "es" : "")}")}"); } f.Append($" | Give or Take"); if (a.Config.VerboseGimme) { e.WithFooter(f.ToString()); } await ReplyAsync(embed : e.Build()); }
public async Task AccountResponseAsync(int page = 1) { SocketUser u = Context.User; OldAccount a = Context.Account; Server s = Context.Server; int pages = 7; page = page.InRange(1, pages) - 1; EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithIconUrl(u.GetAvatarUrl()); f.WithText($"{a.GetName()} | Page {page + 1} of {pages}"); EmbedBuilder e = new EmbedBuilder(); e.WithColor(EmbedData.GetColor("origreen")); e.WithFooter(f); if (page.Equals(0)) // Introduction Page { StringBuilder sb = new StringBuilder(); string title = "Account Panel"; sb.AppendLine($"`{Context.Server.Config.Prefix}account 2` - Options"); sb.AppendLine($"`{Context.Server.Config.Prefix}account 3` - Notifications"); sb.AppendLine($"`{Context.Server.Config.Prefix}account 4` - Level Stats"); sb.AppendLine($"`{Context.Server.Config.Prefix}account 5` - Wallet Stats"); sb.AppendLine($"`{Context.Server.Config.Prefix}account 6` - Command Stats"); sb.AppendLine($"`{Context.Server.Config.Prefix}account 7` - Give Or Take Stats"); e.WithTitle(title); e.WithDescription(sb.ToString()); await ReplyAsync(embed : e.Build()); return; } if (page.Equals(1)) // Configuration { await GetConfigPanelAsync(a, s, e); return; } if (page.Equals(2)) // Notifiers { await GetNotifierPanelAsync(a, s, e); return; } if (page.Equals(3)) // Level Analytics { await GetLevelPanelAsync(a, s, e); return; } if (page.Equals(4)) // Wallet Analytics { await GetWalletPanelAsync(a, s, e); return; } if (page.Equals(6)) { await GetGimmePanelAsync(a, s, e); return; } }
public MessageStructure ToMessage(IconFormat f) { MessageBuilder mb = new MessageBuilder(); EmbedBuilder eb = Embedder.DefaultEmbed; StringBuilder title = new StringBuilder(); title.AppendLine(Source.Author.Name.MarkdownBold()); if (Source.Recipients.Funct()) { if (Source.Recipients.Count > 1) { title.AppendLine($"**Recipients**: {string.Join(",", Source.Recipients.Select(x => $"{x.Id}".DiscordLine()))}"); } } if (Source.IsThreaded) { title.AppendLine($"**Thread**: {Source.Thread.Root.Subject}\n**SubThread**: {Source.Subject}"); } else { title.AppendLine($"**Subject**: {Source.Subject}"); } if (Source.Locked) { title.Insert(0, EmojiIndex.Locked.Format(AccountOptions.Default.IconFormat) + " "); } if (Source.Marked) { eb.WithColor(EmbedData.GetColor("error")); } else if (!Source.Read) { eb.WithColor(EmbedData.GetColor("owo")); } eb.WithTitle(title.ToString()); if (Source.HasMessage) { eb.WithDescription(Source.Message); } eb.WithFooter(Source.Id); eb.WithTimestamp(Source.Date); if (Source.HasAttachment) { if (Source.Attachment.IsEmbeddable) { eb.WithImageUrl(Source.Attachment.Url); // in the case of the image being unable to load..? string msg = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url); eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}" : msg); } else if (Source.Attachment.IsWritten) { var client = new OriWebClient(); WebResponse <string> r = client.RequestAsync <string>(Source.Attachment.Url).ConfigureAwait(false).GetAwaiter().GetResult(); if (r.IsSuccess) { "i passed".Debug(); string msg = r.Data.Clean(); // 6 = ``` ``` , 2 = \n \n int limit = 256 - Source.Attachment.CodeLanguage.Length - 6 - 2; if (msg.Length > limit) { msg = msg.Substring(0, limit); } string link = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url); msg = msg.DiscordBlock(Source.Attachment.CodeLanguage); eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}{link}": msg + link); } } else { string msg = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url); eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}" : msg); } } mb.WithEmbed(eb); return(mb.Build()); }