internal ContextCommandInfo(Builders.ContextCommandBuilder builder, ModuleInfo module, InteractionService commandService)
     : base(builder, module, commandService)
 {
     CommandType       = builder.CommandType;
     DefaultPermission = builder.DefaultPermission;
     Parameters        = builder.Parameters.Select(x => x.Build(this)).ToImmutableArray();
 }
示例#2
0
        /// <summary>
        ///     Adds context command builder to <see cref="ContextCommands"/>.
        /// </summary>
        /// <param name="name">Name of the command.</param>
        /// <param name="callback">Command callback to be executed.</param>
        /// <param name="configure"><see cref="ContextCommandBuilder"/> factory.</param>
        /// <returns>
        ///     The builder instance.
        /// </returns>
        public ModuleBuilder AddContextCommand(string name, ExecuteCallback callback, Action <ContextCommandBuilder> configure)
        {
            var command = new ContextCommandBuilder(this, name, callback);

            configure(command);
            _contextCommands.Add(command);
            return(this);
        }
示例#3
0
        /// <summary>
        ///     Adds context command builder to <see cref="ContextCommands"/>.
        /// </summary>
        /// <param name="configure"><see cref="ContextCommandBuilder"/> factory.</param>
        /// <returns>
        ///     The builder instance.
        /// </returns>
        public ModuleBuilder AddContextCommand(Action <ContextCommandBuilder> configure)
        {
            var command = new ContextCommandBuilder(this);

            configure(command);
            _contextCommands.Add(command);
            return(this);
        }
 internal static ContextCommandInfo Create(Builders.ContextCommandBuilder builder, ModuleInfo module, InteractionService commandService)
 {
     return(builder.CommandType switch
     {
         ApplicationCommandType.User => new UserCommandInfo(builder, module, commandService),
         ApplicationCommandType.Message => new MessageCommandInfo(builder, module, commandService),
         _ => throw new InvalidOperationException("This command type is not a supported Context Command"),
     });
 internal MessageCommandInfo(Builders.ContextCommandBuilder builder, ModuleInfo module, InteractionService commandService)
     : base(builder, module, commandService)
 {
 }