Beispiel #1
0
 internal static async Task GenericInteractionEnd(IUserMessage message, EmbedBuilder embed)
 {
     if (InteractiveMessageService.RemoveInteractiveMessage(message.Id))
     {
         await message.ModifyAsync(MessageProperties =>
         {
             MessageProperties.Embed = embed.Build();
         });
     }
 }
Beispiel #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();
         });
     }
 }
Beispiel #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);
         }
     }
 }
Beispiel #4
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}");
     }
 }