Esempio n. 1
0
        public async Task <GuildEmote> GetEmote(string str, SocketGuild Guild = null)
        {
            Guild ??= Context.Guild;
            var replstr = str.Replace("a:", "").Replace("<", "").Replace(">", "").Replace(":", "");

            Console.WriteLine(replstr);
            if (Guild.Emotes.Any(x => string.Equals(replstr, x.Name, StringComparison.CurrentCultureIgnoreCase)))
            {
                return(Guild.Emotes.First(
                           x => string.Equals(replstr, x.Name, StringComparison.CurrentCultureIgnoreCase)));
            }
            Console.WriteLine(replstr);
            try
            {
                var resultString = ulong.Parse(Regex.Match(replstr, @"\d+").Value);

                if (resultString == 0 || await Context.Guild.GetEmoteAsync(resultString) == null)
                {
                    return(null);
                }
                return(await Guild.GetEmoteAsync(resultString));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 2
0
        // General Role Select Refresh
        public static async Task RefreshChannelConfiguration()
        {
            var inputs = new List <string>();

            // Get last 100 messages currently in the channel
            var msgs = await Channel_Config.GetMessagesAsync(100).FlattenAsync();

            // Delete useless messages, add content of remaining ones for processing
            foreach (var msg in msgs)
            {
                var content = msg.Content;
                if (content.Contains(@"Template: Name | #channel | @role | :emoji:. Use !Refresh to update changes."))
                {
                    continue;
                }
                else if (ChannelSelectController.InputMessageFormatValid(content))
                {
                    inputs.Add(content);
                }
                else
                {
                    await msg.DeleteAsync();
                }
            }

            // Refresh the configurations
            var processMsg = ChannelSelectController.RefreshChannelList(inputs);

            await LogMessage(processMsg);

            // Generate Embed Message
            var embeddedMessage = await GenerateEmbeddedMessage();

            // Get all messages in the select channel and delete everything except the last message which should be Pneumas
            var configmsgs = await Channel_Select.GetMessagesAsync(100).FlattenAsync();

            RestUserMessage lastMsg = null;

            foreach (var msg in configmsgs)
            {
                if (msg == configmsgs.Last() && msg.Author.Id == Client.CurrentUser.Id)
                {
                    lastMsg = (RestUserMessage)msg;
                }
                else
                {
                    await msg.DeleteAsync();
                }
            }

            // Edit if the last message exists and is Pneuma's, else delete and create a new one
            if (lastMsg == null)
            {
                lastMsg = await Channel_Select.SendMessageAsync(null, false, embeddedMessage);
            }
            else
            {
                await lastMsg.ModifyAsync(x => x.Embed = embeddedMessage);
            }
            MainMessage = lastMsg;


            // Verify all emojis exist on message
            foreach (var selection in ChannelSelectController.ChannelList)
            {
                var emoji = await Guild.GetEmoteAsync(selection.EmojiId);

                // Verify if Pneuma has done the emote
                var emojiUses = await MainMessage.GetReactionUsersAsync(emoji, 100).FlattenAsync();

                if (!emojiUses.Any(u => u.Id == Client.CurrentUser.Id))
                {
                    await MainMessage.AddReactionAsync(emoji);
                }
            }
        }
 public virtual Task <GuildEmote> GetEmoteAsync(ulong id, RequestOptions?options = null)
 {
     return(_socketGuild.GetEmoteAsync(id, options));
 }
Esempio n. 4
0
 public Task <GuildEmote> GetEmoteAsync(ulong id, RequestOptions options = null)
 {
     return(Guild.GetEmoteAsync(id, options));
 }