public static async Task CreateReactionsBulk(this DiscordMessage msg, string[] reactions) { foreach (var reaction in reactions) { await msg.CreateReactionAsync(DiscordEmoji.FromUnicode(reaction)); } }
public async Task PostAnwärter(CommandContext ctx, [Description("Die UserId des Anwärters")] ulong userId, [Description("Anmerkung über den Anwärter")][RemainingText] string anmerkung) { if (ctx.Guild.Id.Equals(848588654020132874)) //Nur für Milf Discord { DateTime inaktivität = DateTime.Now; DiscordMessage msg; var text = $"<@&848640163797794828>\nAbstimmung für den Anwärter: <@{userId}>\nAnmerkung: {anmerkung}\nEntfernung bei Inaktivität: {inaktivität.AddDays(14):dd.MM.yyyy}"; msg = await ctx.Channel.SendMessageAsync(text).ConfigureAwait(false); DiscordEmoji emojiPlusOne = await ctx.Guild.GetEmojiAsync(config.StoredValues.EmojiPlusOne).ConfigureAwait(false); DiscordEmoji emojiYes = await ctx.Guild.GetEmojiAsync(config.StoredValues.EmojiYes).ConfigureAwait(false); DiscordEmoji emojiNo = await ctx.Guild.GetEmojiAsync(config.StoredValues.EmojiNo).ConfigureAwait(false); DiscordEmoji emojiLoading = await ctx.Guild.GetEmojiAsync(config.StoredValues.EmojiLoading).ConfigureAwait(false); DiscordEmoji emojiTop = DiscordEmoji.FromUnicode("💯"); await msg.CreateReactionAsync(emojiPlusOne).ConfigureAwait(false); await msg.CreateReactionAsync(emojiYes).ConfigureAwait(false); await msg.CreateReactionAsync(emojiNo).ConfigureAwait(false); await msg.CreateReactionAsync(emojiLoading).ConfigureAwait(false); await msg.CreateReactionAsync(emojiTop).ConfigureAwait(false); await ctx.Message.DeleteAsync().ConfigureAwait(false); } }
public async Task HandleMessageListener(MessageCreateEventArgs e) { await semaphore.WaitAsync(); if (currentChannel != null && e.Channel == currentChannel) { if (!eliminatedUsers.Contains(e.Author)) { var alphabetRegex = new Regex("[^A-Z]"); string messageText = alphabetRegex.Replace(e.Message.Content.ToUpper(), ""); string expectedAnswer = alphabetRegex.Replace(currentPuzzle.Phrase.ToUpper(), ""); if (messageText == expectedAnswer) { currentChannel = null; eliminatedUsers.Clear(); lastWinningMessage = e.Message; await BotMethods.SendMessage(this, new SendMessageEventArgs { Message = $"Congratulations to {e.Author.Mention} for getting the correct answer! Thanks for playing!", Channel = e.Channel, LogMessage = "WheelOfFortuneGameWin" }); } else { eliminatedUsers.Add(e.Author); await e.Message.CreateReactionAsync(DiscordEmoji.FromUnicode("❌")); } } } semaphore.Release(); }
public bool command(MessageCreateEventArgs e, Channel channel) { var message = e.Message.Content.ToLower(); if (e.Guild != null && e.Author == e.Guild.Owner) { if (message.Contains("!quiet")) { channel.ChannelSettings.TargetedResponseConfidenceThreshold = 2; var response = DiscordEmoji.FromUnicode("🤐"); e.Message.CreateReactionAsync(response); channelConfigurationService.SaveChannel(channel); return(true); } else if (message.Contains("!talk")) { channel.ChannelSettings.TargetedResponseConfidenceThreshold = configuration.TargetedResponseConfidenceThreshold; channelConfigurationService.SaveChannel(channel); var response = DiscordEmoji.FromUnicode("👅"); e.Message.CreateReactionAsync(response); e.Message.RespondAsync("hey 😉"); return(true); } else if (SetTargetedResponseConfidenceThreshold(message, channel) || SetReactionConfidenceThreshold(message, channel)) { var response = DiscordEmoji.FromUnicode("👍"); e.Message.CreateReactionAsync(response); } } return(false); }
public async Task React( CommandContext ctx, [Description("Message link")] string messageLink, [RemainingText, Description("List of reactions to add")] string emojis ) { try { var message = await ctx.GetMessageAsync(messageLink).ConfigureAwait(false); if (message == null) { await ctx.ReactWithAsync(Config.Reactions.Failure, "Couldn't find the message").ConfigureAwait(false); return; } string emoji = ""; for (var i = 0; i < emojis.Length; i++) { try { var c = emojis[i]; if (char.IsHighSurrogate(c)) { emoji += c; } else { DiscordEmoji de; if (c == '<') { var endIdx = emojis.IndexOf('>', i); if (endIdx < i) { endIdx = emojis.Length; } emoji = emojis.Substring(i, endIdx - i); i = endIdx - 1; var emojiId = ulong.Parse(emoji.Substring(emoji.LastIndexOf(':') + 1)); de = DiscordEmoji.FromGuildEmote(ctx.Client, emojiId); } else { de = DiscordEmoji.FromUnicode(emoji + c); } emoji = ""; await message.ReactWithAsync(de).ConfigureAwait(false); } } catch { } } } catch (Exception e) { Config.Log.Debug(e); } }
public async Task Credits(CommandContext ctx) { DiscordEmoji hcorion; try { hcorion = DiscordEmoji.FromName(ctx.Client, ":hcorion:"); } catch { hcorion = DiscordEmoji.FromUnicode("🍁"); } var embed = new DiscordEmbedBuilder { Title = "RPCS3 Compatibility Bot", Url = "https://github.com/RPCS3/discord-bot", Color = DiscordColor.Purple, }.AddField("Made by", "💮 13xforever\n" + "🇭🇷 Roberto Anić Banić aka nicba1010") .AddField("People who ~~broke~~ helped test the bot", "🐱 Juhn\n" + $"{hcorion} hcorion\n" + "🙃 TGE"); await ctx.RespondAsync(embed : embed.Build()); }
public static async Task OnMessageCreated(MessageCreateEventArgs args) { if (DefaultHandlerFilter.IsFluff(args.Message)) { return; } if (!args.Author.IsWhitelisted(args.Client, args.Message.Channel.Guild)) { return; } if (!NeedToSilence(args.Message)) { return; } var botMember = args.Guild?.CurrentMember ?? args.Client.GetMember(args.Client.CurrentUser); if (!args.Channel.PermissionsFor(botMember).HasPermission(Permissions.ReadMessageHistory)) { await args.Message.ReactWithAsync(args.Client, DiscordEmoji.FromUnicode("🙅"), @"No can do, boss ¯\\_(ツ)\_/¯").ConfigureAwait(false); return; } await args.Message.ReactWithAsync(args.Client, DiscordEmoji.FromUnicode("😟"), "Okay (._.)").ConfigureAwait(false); var lastBotMessages = await args.Channel.GetMessagesBeforeAsync(args.Message.Id, 20, DateTime.UtcNow.AddMinutes(-5)).ConfigureAwait(false); if (lastBotMessages.OrderByDescending(m => m.CreationTimestamp).FirstOrDefault(m => m.Author.IsCurrent) is DiscordMessage msg) { await msg.DeleteAsync("asked to shut up").ConfigureAwait(false); } }
public async Task FeedCommand(CommandContext context) { if (context.Channel.Name != "bot-commands") { Console.WriteLine("Wrong Channel"); return; } Console.WriteLine("Feeding"); string message = context.Message.Content; Console.WriteLine("Got message"); int offset = message.IndexOf(' ') + 1; message = message.Substring(offset); Console.WriteLine($"Got substring: {message}"); //Emote emoji = new Emote(message); //DiscordEmoji emoji = DiscordEmoji. Console.WriteLine(DiscordEmoji.FromUnicode(QazbotMain.discord, message).Id); Console.WriteLine(DiscordEmoji.FromUnicode(QazbotMain.discord, message).Name); Animation anim = new Animation(); Keyframe frame1 = new Keyframe(1.5f); Keyframe frame2 = new Keyframe(1.5f); Keyframe frame3 = new Keyframe(1.5f); Keyframe frame4 = new Keyframe(1.5f); Keyframe frame5 = new Keyframe(1.5f); }
public async Task Start(CommandContext ctx) { if (ctx.Channel.IsPrivate) { await ctx.TriggerTypingAsync(); var interactivity = ctx.Client.GetInteractivityModule(); var challengeSolutionBuilder = new StringBuilder(); for (int i = 0; i < 32; i++) { challengeSolutionBuilder.Append(_charset[StaticRandom.Next(0, _charset.Length)]); } var challengeSolution = challengeSolutionBuilder.ToString(); await ctx.RespondAsync($"Decode this, you have 1 second: {Rot13(challengeSolution)}"); var response = await interactivity.WaitForMessageAsync(message => message.Author.Id == ctx.User.Id && message.Channel.IsPrivate && challengeSolution.Equals(message.Content, StringComparison.Ordinal), TimeSpan.FromSeconds(1.0)); await ctx.TriggerTypingAsync(); if (response != null) { await response.Message.CreateReactionAsync(DiscordEmoji.FromUnicode("🎉")); await ctx.RespondAsync($"You did it! The flag is Pycon_{{T00_34sy_4_u!}}."); } else { await(await ctx.RespondAsync("Too late!")).CreateReactionAsync(DiscordEmoji.FromUnicode("⌛")); } } }
//implement further public async Task Ready(CommandContext ctx) { var interactivity = ctx.Client.GetInteractivity(); var discordEmoji = new DiscordEmoji[1]; discordEmoji[0] = DiscordEmoji.FromUnicode("👍🏽"); var options = discordEmoji.Select(x => x.ToString()); var pollEmbed = new DiscordEmbedBuilder { Title = "Are you ready to Begin?", //Description = string.Join("Press the check mark to signify you are ready: ", options) }; var pollMessage = await ctx.Channel.SendMessageAsync(embed : pollEmbed).ConfigureAwait(false); foreach (var option in discordEmoji) { await pollMessage.CreateReactionAsync(option).ConfigureAwait(false); } int readyCheck = 0; while (readyCheck != PLAYERS) { // _ = interactivity.WaitForReactionAsync().ConfigureAwait(false); readyCheck++; } //displays what emojis what was used await ctx.Channel.SendMessageAsync($"All {readyCheck} players are ready...It's time to begin!").ConfigureAwait(false); }
/// <summary> /// Internal method to search for emojis. /// </summary> /// <param name="emojiNameOrId"></param> /// <returns>A <see cref="DiscordEmoji"/> or <see langword="null"/> if the bot finds nothing.</returns> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="NullReferenceException"></exception> internal static DiscordEmoji FindEmoji(string emojiNameOrId) { DiscordClient discordClient = TarsBase._discordClient; discordClient.IsNotNull(); emojiNameOrId.IsNotNull(); StringComparison stringComparison = StringComparison.CurrentCultureIgnoreCase; ulong.TryParse(emojiNameOrId, out ulong emojiId); foreach (DiscordGuild guild in discordClient.Guilds.Values) { var emoji = guild.Emojis.Values.FirstOrDefault(e => string.Equals(e.Name, emojiNameOrId.Replace(":", ""), stringComparison) || string.Equals(e.ToString(), emojiNameOrId, stringComparison) || e.Id == emojiId); if (emoji != null) { return(emoji); } } try { return(DiscordEmoji.FromName(discordClient, $"{(emojiNameOrId.StartsWith(":") && emojiNameOrId.EndsWith(":") ? emojiNameOrId : $":{emojiNameOrId}:")}")); } catch { } return(!emojiNameOrId.IsNullOrEmptyOrWhiteSpace() && CharUnicodeInfo.GetUnicodeCategory(emojiNameOrId, 0) == UnicodeCategory.OtherSymbol ? DiscordEmoji.FromUnicode(discordClient, emojiNameOrId) : null); }
public static async Task BuildDeleteHandler(MessageDeleteEventArgs e) { if (e.Channel.Name == "builds") { using (var db = new BuildContext()) { var build = db.Builds.FirstOrDefault(b => b.MessageId == e.Message.Id); if (build == null) { return; } var author = await e.Guild.GetMemberAsync(build.AuthorId); await author.SendMessageAsync( $"{DiscordEmoji.FromUnicode("❌")} Your build has been deleted due to a large negative score " + $"(+{(build.UpVotes - 1)} | -{(build.DownVotes - 1)}).", false, await build.GetEmbed()); db.Remove(build); await db.SaveChangesAsync(); } } }
public async Task GetProcesses(CommandContext ctx) { if (!Bot.Config.ProcessesEnabled) { Logger.Log( $"Processes requested by {ctx.User.Username}#{ctx.User.Discriminator}, but it was toggled off.", ctx, LogLevel.Info); await ctx.Message.CreateReactionAsync(DiscordEmoji.FromUnicode("🔕")); return; } Logger.Log($"Processes requested by {ctx.User.Username}#{ctx.User.Discriminator}", ctx, LogLevel.Info); var procs = Process.GetProcesses().Where(x => x.SessionId == Process.GetCurrentProcess().SessionId) .OrderByDescending(x => x.PrivateMemorySize64) .ToList(); var table = new ConsoleTable("Name", "Memory", "Uptime"); foreach (var process in procs.Take(15)) { try { table.AddRow($"{process.ProcessName}", $"{process.PrivateMemorySize64 / 1000000}MB", $"{DateTime.Now - process.StartTime:h'h 'm'm 's's'}"); } catch (Exception) { table.AddRow($"{process.ProcessName}", $"{process.PrivateMemorySize64 / 1000000}MB", "Not available!"); } } var response = table.Configure(x => x.NumberAlignment = Alignment.Right).ToMinimalString(); await ctx.RespondAsync($"```{response}```"); }
public static async Task <bool> GetExpansionRequiredAsync(CommandContext context) { await context.TriggerTypingAsync(); var message = await context.RespondAsync($"{_required}Does this build require the expansion pack (Ashes of Malmouth)?"); await message.CreateReactionAsync(DiscordEmoji.FromUnicode("🇾")); await message.CreateReactionAsync(DiscordEmoji.FromUnicode("🇳")); var reaction = await Program.Interactivity.WaitForMessageReactionAsync( e => e == DiscordEmoji.FromUnicode("🇾") || e == DiscordEmoji.FromUnicode("🇳"), message, context.User); await message.DeleteAsync(); if (reaction == null || reaction.Emoji == DiscordEmoji.FromUnicode("🇳")) { return(false); } else { return(true); } }
public async Task TestPollAsync(CommandContext ctx, [RemainingText] string question) { var intr = ctx.Client.GetInteractivity(); var m = await ctx.RespondAsync(question); ctx.Client.DebugLogger.LogMessage(LogLevel.Debug, "interactivity-test", "sent message & got interactivity ext", DateTime.Now); List <DiscordEmoji> ems = new List <DiscordEmoji>(); ems.Add(DiscordEmoji.FromUnicode(ctx.Client, "👍")); ems.Add(DiscordEmoji.FromUnicode(ctx.Client, "👎")); ctx.Client.DebugLogger.LogMessage(LogLevel.Debug, "interactivity-test", "added reactions", DateTime.Now); var rcc = await intr.CreatePollAsync(m, ems, TimeSpan.FromSeconds(4)); ctx.Client.DebugLogger.LogMessage(LogLevel.Debug, "interactivity-test", "got results", DateTime.Now); string results = ""; foreach (var smth in rcc.Reactions) { results += $"{smth.Key.ToString()}: {smth.Value}\n"; } await m.DeleteAllReactionsAsync(); await m.ModifyAsync(results); ctx.Client.DebugLogger.LogMessage(LogLevel.Debug, "interactivity-test", "sent results", DateTime.Now); }
public static DiscordEmoji ToDiscordEmoji(string emojiUTF, Bot bot) { DiscordEmoji guildEmoji; try { guildEmoji = DiscordEmoji.FromName(bot.client, emojiUTF); } catch { try { guildEmoji = DiscordEmoji.FromName(bot.client, string.Format(":{0}:", emojiUTF.Split(':')[1])); } catch { try { if (Emoji.All.ToList().FindAll(o => o.Sequence.AsString == emojiUTF).Count <= 0) { throw; } guildEmoji = DiscordEmoji.FromUnicode(bot.client, emojiUTF); } catch { guildEmoji = null; } } } return(guildEmoji); }
public static async Task ReactionClear(ModCoreShard bot, MessageReactionsClearEventArgs e) { GuildSettings cfg = null; using (var db = bot.Database.CreateContext()) { cfg = e.Channel.Guild.GetGuildSettings(db); if (cfg == null) { return; } var emoji = cfg.Starboard.Emoji; DiscordEmoji em = null; if (emoji.EmojiId != 0) { em = DiscordEmoji.FromGuildEmote(e.Client, (ulong)emoji.EmojiId); } else { em = DiscordEmoji.FromUnicode(e.Client, emoji.EmojiName); } if (cfg.Starboard.Enable) { var c = e.Channel.Guild.Channels.First(x => x.Key == (ulong)cfg.Starboard.ChannelId).Value; if (db.StarDatas.Any(x => (ulong)x.MessageId == e.Message.Id)) { await(await c.GetMessageAsync((ulong)db.StarDatas.First(x => (ulong)x.MessageId == e.Message.Id).StarboardMessageId)).DeleteAsync(); db.StarDatas.RemoveRange(db.StarDatas.Where(x => (ulong)x.MessageId == e.Message.Id)); await db.SaveChangesAsync(); } } } }
public async Task Roll(CommandContext ctx, [Description("Dices to roll (i.e. 2d6 for two 6-sided dices)")] string dices, [Description("Optional text"), RemainingText] string comment = null) { var result = ""; if (dices is string dice && Regex.IsMatch(dice, @"\d+d\d+")) { await ctx.TriggerTypingAsync().ConfigureAwait(false); var diceParts = dice.Split('d', StringSplitOptions.RemoveEmptyEntries); if (int.TryParse(diceParts[0], out var num) && int.TryParse(diceParts[1], out var face) && 0 < num && num < 101 && 1 < face && face < 1001) { List <int> rolls; lock (rng) rolls = Enumerable.Range(0, num).Select(_ => rng.Next(face) + 1).ToList(); if (rolls.Count > 1) { result = "Total: " + rolls.Sum(); result += "\nRolls: " + string.Join(' ', rolls); } else { result = rolls.Sum().ToString(); } } } if (string.IsNullOrEmpty(result)) { await ctx.ReactWithAsync(DiscordEmoji.FromUnicode("💩"), "Invalid dice description passed").ConfigureAwait(false); } else { await ctx.RespondAsync(result).ConfigureAwait(false); } }
public async Task Freuddian(CommandContext ctx) { var message = await ctx.RespondAsync("Ring... Ring..."); const string emj = "☎"; var discordClient = _client; await message.CreateReactionAsync(DiscordEmoji.FromUnicode(discordClient, emj)); while (true) { var reacts = await discordClient.GetInteractivity() .WaitForReactionAsync(x => x.Emoji.Name == emj, TimeSpan.FromMinutes(5)); if (reacts.TimedOut) { return; } if (reacts.Result.User == discordClient.CurrentUser) { continue; } if (reacts.Result.Message != message) { continue; } await ctx.Member.SendMessageAsync("Kill zem, Kill zem all..."); } }
public static async Task CommandErrored(CommandErrorEventArgs e) { if (e.Exception.Message.Contains("command was not found")) { await e.Context.Message.CreateReactionAsync(DiscordEmoji.FromUnicode("❓")); return; } var eb = new DiscordEmbedBuilder() .WithColor(DiscordColor.Red) .WithAuthor("Command Execution failed!", iconUrl: "https://www.shareicon.net/data/128x128/2016/08/18/810028_close_512x512.png") .WithDescription(e.Exception.Message); if (e.Exception.Message.Contains("pre-execution checks failed")) { var checks = new List <string>(); foreach (var check in e.Command.ExecutionChecks) { if (!await check.ExecuteCheckAsync(e.Context, false)) { checks.Add(check.ToString().Substring(check.ToString().LastIndexOf(".", StringComparison.Ordinal) + 1).Replace("Attribute", string.Empty)); } } eb.AddField("Failed Pre-Execution checks:", string.Join(", ", checks)); } if (e.Exception.InnerException != null) { eb.AddField("Inner Exception:", e.Exception.InnerException.Message); } await e.Context.RespondAsync(embed : eb.Build()); }
private async Task Initialize(DiscordMessage message, int pageNum) { if (Pages > 1) { if (BulkSkipNumber > 1) { await message.CreateReactionAsync(DiscordEmoji.FromUnicode(BigLeft)); } await message.CreateReactionAsync(DiscordEmoji.FromUnicode(Left)); await message.CreateReactionAsync(DiscordEmoji.FromUnicode(Stop)); if (BulkSkipNumber > 1) { await message.CreateReactionAsync(DiscordEmoji.FromUnicode(Right)); } await message.CreateReactionAsync(DiscordEmoji.FromUnicode(BulkSkipNumber > 1 ? BigRight : Right)); } else { await message.CreateReactionAsync(DiscordEmoji.FromUnicode(Stop)); } await Pagination(message, pageNum); }
static MusicModule() { var iab = ImmutableArray.CreateBuilder <DiscordEmoji>(); iab.Add(DiscordEmoji.FromUnicode("1\u20e3")); iab.Add(DiscordEmoji.FromUnicode("2\u20e3")); iab.Add(DiscordEmoji.FromUnicode("3\u20e3")); iab.Add(DiscordEmoji.FromUnicode("4\u20e3")); iab.Add(DiscordEmoji.FromUnicode("5\u20e3")); iab.Add(DiscordEmoji.FromUnicode("\u274c")); Numbers = iab.ToImmutable(); var idb = ImmutableDictionary.CreateBuilder <int, DiscordEmoji>(); idb.Add(1, DiscordEmoji.FromUnicode("1\u20e3")); idb.Add(2, DiscordEmoji.FromUnicode("2\u20e3")); idb.Add(3, DiscordEmoji.FromUnicode("3\u20e3")); idb.Add(4, DiscordEmoji.FromUnicode("4\u20e3")); idb.Add(5, DiscordEmoji.FromUnicode("5\u20e3")); idb.Add(-1, DiscordEmoji.FromUnicode("\u274c")); NumberMappings = idb.ToImmutable(); var idb2 = ImmutableDictionary.CreateBuilder <DiscordEmoji, int>(); idb2.AddRange(NumberMappings.ToDictionary(x => x.Value, x => x.Key)); NumberMappingsReverse = idb2.ToImmutable(); }
public Task LoadListeners(BaseDiscordClient client) { var ids = _redis.SetMembers("MessageIds"); _listener = new Dictionary <string, Dictionary <DiscordEmoji, ulong> >(); foreach (var id in ids) { var reactions = _redis.HashGetAll($"Messages:{id}"); var emojiDictionary = new Dictionary <DiscordEmoji, ulong>(); foreach (var reaction in reactions) { DiscordEmoji emoji; var fieldName = reaction.Name.ToString(); if (fieldName.StartsWith("<")) { fieldName = fieldName.Substring(fieldName.LastIndexOf(':')); var emojiId = fieldName.Substring(1, fieldName.Length - 2); emoji = DiscordEmoji.FromGuildEmote(client, ulong.Parse(emojiId)); } else { emoji = DiscordEmoji.FromUnicode(fieldName); } emojiDictionary.Add(emoji, ulong.Parse(reaction.Value)); } _listener.Add(id, emojiDictionary); } return(Task.CompletedTask); }
private async Task <uint> GetAwardReactionCount(DiscordMessage message, DiscordMember messageAuthor) { uint awardReactionCount = 0; try { var cookieEmoji = DiscordEmoji.FromUnicode(EmojiMap.Cookie); var cookieReactionUsers = await message.GetReactionsAsync(cookieEmoji); if (cookieReactionUsers != null) { var skipAuthor = false; #if DEBUG skipAuthor = true; #endif awardReactionCount = (uint)cookieReactionUsers .Select(u => u.Id) .Distinct() .Count(x => skipAuthor || x != messageAuthor.Id); } } catch (Exception ex) { await _discordErrorLogger.LogDiscordError(ex.ToString()); } return(awardReactionCount); }
public PaginationEmojis() { Left = DiscordEmoji.FromUnicode("◀"); Right = DiscordEmoji.FromUnicode("▶"); SkipLeft = DiscordEmoji.FromUnicode("⏮"); SkipRight = DiscordEmoji.FromUnicode("⏭"); Stop = DiscordEmoji.FromUnicode("⏹"); }
public PaginationEmojis() { this.Left = DiscordEmoji.FromUnicode("◀"); this.Right = DiscordEmoji.FromUnicode("▶"); this.SkipLeft = DiscordEmoji.FromUnicode("⏮"); this.SkipRight = DiscordEmoji.FromUnicode("⏭"); this.Stop = DiscordEmoji.FromUnicode("⏹"); }
public PaginationEmojis(DiscordClient client) { Left = DiscordEmoji.FromUnicode(client, "◀"); Right = DiscordEmoji.FromUnicode(client, "▶"); SkipLeft = DiscordEmoji.FromUnicode(client, "⏮"); SkipRight = DiscordEmoji.FromUnicode(client, "⏭"); Stop = DiscordEmoji.FromUnicode(client, "⏹"); }
public PaginationButtons() { this.SkipLeft = new(ButtonStyle.Secondary, "leftskip", null, false, new(DiscordEmoji.FromUnicode("⏮"))); this.Left = new(ButtonStyle.Secondary, "left", null, false, new(DiscordEmoji.FromUnicode("◀"))); this.Stop = new(ButtonStyle.Secondary, "stop", null, false, new(DiscordEmoji.FromUnicode("⏹"))); this.Right = new(ButtonStyle.Secondary, "right", null, false, new(DiscordEmoji.FromUnicode("▶"))); this.SkipRight = new(ButtonStyle.Secondary, "rightskip", null, false, new(DiscordEmoji.FromUnicode("⏭"))); }
public async Task GetQueue() { if (_ctx.Member.VoiceState == null || _ctx.Member.VoiceState.Channel == null) { await _ctx.RespondAsync("You are not in a voice channel."); return; } if (Connection == null) { await _ctx.RespondAsync("Lavalink is not connected."); return; } if (Playlist == null) { await _ctx.RespondAsync("No playlist loaded."); return; } var interactivity = _ctx.Client.GetInteractivity(); var pageCount = Queue.Count / 5 + 1; if (Queue.Count % 5 == 0) { pageCount--; } var pages = Queue.Select(x => x.Title) .Select((t, i) => new { title = t, index = i }) .GroupBy(x => x.index / 5) .Select(page => new Page("", new DiscordEmbedBuilder { Title = "Playlist", Description = $"Now playing: {Queue.Peek().Title}\n\n{string.Join("\n", page.Select(track => $"`{track.index + 1:00}` {track.title}"))}", Footer = new EmbedFooter { Text = $"Page {page.Key + 1}/{pageCount}" } } )).ToArray(); var emojis = new PaginationEmojis { SkipLeft = null, SkipRight = null, Stop = null, Left = DiscordEmoji.FromUnicode("◀"), Right = DiscordEmoji.FromUnicode("▶") }; await interactivity.SendPaginatedMessageAsync(_ctx.Channel, _ctx.User, pages, emojis, PaginationBehaviour.Ignore, PaginationDeletion.KeepEmojis, TimeSpan.FromMinutes(2)); }
public async Task WebcamTask(CommandContext ctx, [Description("Index of the cam you want to capture.\nUse the webcam command to list them.")] int camIndex = -1) { // if no camera index has been passed, use the one from the config if (camIndex == -1) { camIndex = Config.Instance.DefaultCam; } Logger.Log($"Webcam requested by {ctx.User.Username} in #{ctx.Channel.Name} ({ctx.Guild.Name})", LogLevel.Info); // init capture var capture = new VideoCaptureDevice(Constants.Cameras[camIndex].MonikerString); try { capture.VideoResolution = TrySelectRes(capture, false); } catch (Exception ex) { if (ex.HResult != -2146233079) { throw; } } capture.Start(); // wait for configured time await Task.Delay(Config.Instance.CamTimer); // capture photo await ctx.Message.CreateReactionAsync(DiscordEmoji.FromUnicode("📸")); capture.NewFrame += (sender, args) => { args.Frame.Save("webcam.png"); capture.SignalToStop(); }; // stop capture while (capture.IsRunning) { capture.WaitForStop(); } capture.Stop(); // send/update message and delete file from disk var msg = new DiscordMessageBuilder() .WithReply(ctx.Message.Id) .WithFile(new FileStream("webcam.png", FileMode.Open)); StalkbotClient.UpdateLastMessage(await ctx.RespondAsync(msg)); File.Delete("webcam.png"); }