/// <summary>Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success.</summary> /// <param name="bot">BotClient</param> /// <param name="args">Parameters.</param> /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception> /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception> /// <returns>True</returns> public static bool SetMyCommands(this BotClient bot, SetMyCommandsArgs args) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } return(bot.RPC <bool>(MethodNames.SetMyCommands, args)); }
/// <summary>Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success.</summary> /// <param name="bot">BotClient</param> /// <param name="args">Parameters.</param> /// <param name="cancellationToken">The cancellation token to cancel operation.</param> /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception> /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception> /// <returns>True</returns> public static async Task <bool> SetMyCommandsAsync(this BotClient bot, SetMyCommandsArgs args, [Optional] CancellationToken cancellationToken) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } return(await bot.RPCA <bool>(MethodNames.SetMyCommands, args, cancellationToken).ConfigureAwait(false)); }
/// <summary>Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success.</summary> /// <param name="bot">BotClient</param> /// <param name="commands">A <see cref="BotCommand"/> list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.</param> /// <param name="scope">A <see cref="BotCommandScope"/> object, describing scope of users for which the commands are relevant. Defaults to <see cref="BotCommandScopeDefault"/>.</param> /// <param name="languageCode">A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.</param> /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception> /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception> /// <returns>True</returns> public static bool SetMyCommands(this BotClient bot, IEnumerable <BotCommand> commands, [Optional] BotCommandScope scope, [Optional] string languageCode) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } if (commands == default) { throw new ArgumentNullException(nameof(commands)); } var args = new SetMyCommandsArgs(commands, scope, languageCode); return(bot.RPC <bool>(MethodNames.SetMyCommands, args)); }
/// <summary>Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success.</summary> /// <param name="bot">BotClient</param> /// <param name="commands">A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.</param> /// <param name="scope">A <see cref="BotCommandScope"/> object, describing scope of users for which the commands are relevant. Defaults to <see cref="BotCommandScopeDefault"/>.</param> /// <param name="languageCode">A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands</param> /// <param name="cancellationToken">The cancellation token to cancel operation.</param> /// <exception cref="BotRequestException">Thrown when a request to Telegram Bot API got an error response.</exception> /// <exception cref="ArgumentNullException">Thrown when a required parameter is null.</exception> /// <returns>True</returns> public static async Task <bool> SetMyCommandsAsync(this BotClient bot, IEnumerable <BotCommand> commands, [Optional] BotCommandScope scope, [Optional] string languageCode, [Optional] CancellationToken cancellationToken) { if (bot == null) { throw new ArgumentNullException(nameof(bot)); } if (commands == default) { throw new ArgumentNullException(nameof(commands)); } var args = new SetMyCommandsArgs(commands, scope, languageCode); return(await bot.RPCA <bool>(MethodNames.SetMyCommands, args, cancellationToken).ConfigureAwait(false)); }