Esempio n. 1
0
 internal static async Task GenericInteractionEnd(IUserMessage message, EmbedBuilder embed)
 {
     if (InteractiveMessageService.RemoveInteractiveMessage(message.Id))
     {
         await message.ModifyAsync(MessageProperties =>
         {
             MessageProperties.Embed = embed.Build();
         });
     }
 }
Esempio n. 2
0
 internal static async Task GenericInteractionEnd(IUserMessage message, string title)
 {
     if (InteractiveMessageService.RemoveInteractiveMessage(message.Id))
     {
         EmbedBuilder success = new EmbedBuilder()
         {
             Title = title, Color = BotCore.EmbedColor
         };
         await message.ModifyAsync(MessageProperties =>
         {
             MessageProperties.Embed = success.Build();
         });
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Handles an interaction with this message
 /// </summary>
 /// <param name="context">MessageInteraction Context</param>
 public async Task HandleInteraction(MessageInteractionContext context)
 {
     if (ExpirationTime < TimingThread.Millis && ExpirationTime >= 0)
     {
         InteractiveMessageService.RemoveInteractiveMessage(MessageId);
         await OnMessageExpire(context);
     }
     else
     {
         if (await OnAnyEmoteAdded(context))
         {
             InteractiveMessageService.RemoveInteractiveMessage(MessageId);
         }
         else if (Interactions.TryGetValue(context.Emote.Name, out EmoteInteraction interaction))
         {
             await interaction.HandleAction(context);
         }
     }
 }
Esempio n. 4
0
        public InteractiveMessage(IUserMessage message, ICollection <EmoteInteraction> interactions = null, long expirationTime = -1)
        {
            MessageId = message.Id;
            ChannelId = message.Channel.Id;
            GuildId   = (ulong)(message.Channel as SocketTextChannel)?.Guild.Id;
            if (expirationTime == -1)
            {
                ExpirationTime = -1;
            }
            else
            {
                ExpirationTime = TimingThread.Millis + expirationTime;
            }
            if (interactions != null)
            {
                AddMessageInteractions(interactions);
            }

            InteractiveMessageService.AddInteractiveMessage(this);
        }
Esempio n. 5
0
 /// <summary>
 /// Handles the action
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public async Task HandleAction(MessageInteractionContext context)
 {
     try
     {
         if (InteractiveMessageService.HasInteractiveMessage(MessageId))
         {
             if (InvalidateMessage)
             {
                 InteractiveMessageService.RemoveInteractiveMessage(MessageId);
             }
             if (await Action(context))
             {
                 InteractiveMessageService.RemoveInteractiveMessage(MessageId);
             }
         }
     }
     catch (Exception e)
     {
         await GuildChannelHelper.SendExceptionNotification(e, $"Error handling EmoteInteraction, MessageId `{MessageId}`, Emote {Emote.Name}");
     }
 }