Exemple #1
0
        /// <summary>
        /// If the YamsterMessage with messageId already exists, this calls messageAction
        /// immediately.  Otherwise, messageAction is queued and will be called later when
        /// the message appears.  If the same listener calls ListenForMessageById() more
        /// than once, only the most recent request is kept.
        /// </summary>
        internal void ListenForMessageById(long messageId,
                                           object listener,
                                           YamsterModelEventCollector eventCollector,
                                           ListenedMessageAction messageAction)
        {
            YamsterMessage message = this.GetMessageById(messageId, nullIfMissing: true);

            if (message != null)
            {
                messageAction(message, eventCollector);
                return;
            }

            ListenedMessage listenedMessage;

            if (!listenedMessagesById.TryGetValue(messageId, out listenedMessage))
            {
                listenedMessage = new ListenedMessage()
                {
                    MessageId = messageId
                };
                listenedMessagesById.Add(messageId, listenedMessage);
            }

            listenedMessage.ActionsByListener[listener] = messageAction;
        }
 public async Task SendReactions()
 {
     if (EmoteToRoleBindings.Count > 0)
     {
         List <IEmote> emotes = EmoteToRoleBindings.Keys.ToList();
         await ListenedMessage.AddReactionsAsync(emotes.ToArray());
     }
 }
 public async Task UpdateMessage()
 {
     await ListenedMessage.ModifyAsync(x => x.Content = Message);
 }