コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InlineReactionCallback"/> class.
 /// </summary>
 /// <param name="interactive">
 /// The interactive service.
 /// </param>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="data">
 /// The callback data.
 /// </param>
 /// <param name="criterion">
 /// The criterion.
 /// </param>
 public InlineReactionCallback(
     InteractiveService interactive,
     SocketCommandContext context,
     ReactionCallbackData data,
     ICriterion <SocketReaction> criterion = null)
 {
     _interactive = interactive;
     Context      = context;
     _data        = data;
     Criterion    = criterion ?? new EmptyCriterion <SocketReaction>();
     Timeout      = data.Timeout ?? TimeSpan.FromSeconds(30);
 }
コード例 #2
0
        /// <summary>
        /// Sends a message with reaction callbacks.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="callbackData">
        /// The callback data.
        /// </param>
        /// <param name="fromSourceUser">
        /// Determines whether the user have to be the source user or not.
        /// </param>
        /// <returns>
        /// A task representing the asynchronous operation. The result contains the message.
        /// </returns>
        public async Task <IUserMessage> SendMessageWithReactionCallbacksAsync(SocketCommandContext context, ReactionCallbackData callbackData, bool fromSourceUser = true)
        {
            var criterion = new Criteria <SocketReaction>();

            if (fromSourceUser)
            {
                criterion.AddCriterion(new EnsureReactionFromSourceUserCriterion());
            }

            var callback = new InlineReactionCallback(this, context, callbackData, criterion);
            await callback.DisplayAsync().ConfigureAwait(false);

            return(callback.Message);
        }