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 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 GetPinAsync() { if (!Context.Channel.HasPins(out IReadOnlyCollection <RestMessage> pins)) { await ReplyAsync(embed : EmbedData.Throw(Context, "This channel has no pinned messages.")); return; } RestMessage pin = pins.ToList()[RandomProvider.Instance.Next(1, pins.Count) - 1]; await ModuleManager.TryExecute(Context.Channel, Context.Channel.SendRestMessageAsync(pin)); }
public async Task DoubleOrNothingAsync(OldAccount a, ulong wager, int times) { if (times <= 0) { string err = "You need to set the tick counter for the machine to land on."; await ReplyAsync(embed : EmbedData.Throw(Context, "Invalid tick counter.", err, false)); return; } CasinoResult outcome = CasinoService.DoubleOrNothing(a, wager, times); await ReplyAsync(embed : outcome.Generate()); }
public async Task GetReportAsync(OldGlobal g, ulong id) { OldAccount a = Context.Account; if (g.TryGetReport(id, out Report r)) { await ReplyAsync(embed : r.Generate(a).Build()); return; } Embed e = EmbedData.Throw(Context, "Invalid report.", $"R({id}) could not be found in the report collection.", false); await ReplyAsync(embed : e); }
public async Task SetInboundChannelAsync(SocketGuildUser u, Server s, SocketGuild g, SocketTextChannel c) { if (!u.EnsureRank(s, g)) { await ReplyAsync(embed : EmbedData.Throw(Context, "Unensured.", "You must be ensured to configure **CrossChat's** inbound channel.", false)); return; } EmbedBuilder e = EmbedData.DefaultEmbed; e.WithTitle("Inbound channel set."); e.WithDescription($"Inbound messages will now be sent to {c.Mention}."); s.Config.SetInboundChannel(c); await ReplyAsync(embed : e.Build()); Context.Data.Update(s); }
public async Task GetReportsAsync(OldGlobal g, int page = 1) { EmbedBuilder e = EmbedData.DefaultEmbed; EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithText($"{EmojiIndex.Report} Reports"); e.WithFooter(f); const int MAX_DESC = 1024; string desc = ""; List <string> list = new List <string>(); List <string> descriptions = new List <string>(); List <Report> reports = g.Reports; List <Report> accepted = g.AcceptedReports; foreach (Report accept in accepted) { list.Add("**+** " + accept.ToString(Context.Account)); } foreach (Report r in reports) { list.Add(r.ToString(Context.Account)); } if (!list.Funct()) { await ReplyAsync(embed : EmbedData.Throw(Context, "Empty collection.", "There are currently no reports.", false)); return; } Embed q = EmbedData.GenerateEmbedList(list, page, e); await ReplyAsync(embed : q); }