Telegram-bot-sdk: [Error] Alias [listcommands] conflicts with another command's alias list

Created on 5 Sep 2018  路  4Comments  路  Source: irazasyed/telegram-bot-sdk

Hello. I have a problem.

Telegram\Bot\Exceptions\TelegramSDKException : [Error] Alias [listcommands] conflicts with another command's alias list: "Telegram\Bot\Commands\HelpCommand", try with another name or remove this alias from the list.

I just installed the package and did nothing else. Please help to correct this mistake. Thank you.

my project - https://github.com/YaroslavStrigun/telegram-bot ;
https://t.me/yaroslav_ridex_bot - bot

Most helpful comment

In the /config folder there is a telegram.php config file. If not, run this command from the command line in your project root map:

php artisan vendor:publish --provider="Telegram\Bot\Laravel\TelegramServiceProvider".

In the project of @YaroslavStrigun there is already a telegram.php. He has changed the global commands list and in that list there is a pointer to the HelpCommand.php in a different folder location while there is also one in the vendor map. So Laravel sees 2 x HelpCommand.php classes or commands. You need to overwrite the vendor HelpCommand by pointing to the location where your custom HelpCommand is for your bot. Comment out the global HelpCommand like so:

'commands'
    => [
        App\Http\Commands\StartCommand::class,
        //App\Http\Commands\HelpCommand::class,
        App\Http\Commands\TodayCommand::class,
        App\Http\Commands\LeftCommand::class,
        App\Http\Commands\WhoCommand::class,
        App\Http\Commands\TomorrowCommand::class,
        App\Http\Commands\WeekCommand::class,
        App\Http\Commands\NextWeekCommand::class,
        App\Http\Commands\WeeksCommand::class
    ],

Then go back to the top and change:

'bots'                         => [
        'mybot' => [
            'username'            => 'TelegramBot',
            'token'               => env('TELEGRAM_BOT_TOKEN', '605210044:AAHWbtxoUBgYOAinbi9niH1TAv1SQyQcQP4'),
            'certificate_path'    => env('TELEGRAM_CERTIFICATE_PATH', 'YOUR-CERTIFICATE-PATH'),
            'webhook_url'         => env('TELEGRAM_WEBHOOK_URL', 'YOUR-BOT-WEBHOOK-URL'),
            'commands'            => [
                //Acme\Project\Commands\MyTelegramBot\BotCommand::class
               App\Http\Commands\HelpCommand::class,
            ],
        ],

and define your HelpCommand over there. This should solve the problem.

By the way, it is better not to cache your config while developing code. You need to remember to clear the cache everytime you change a config value and you might forget to do so. :)

All 4 comments

馃憢 Thanks for opening your first issue here! If you're reporting a 馃悶 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

I'm facing this problem too
I installed version 3 on fresh laravel 5.6
error message when run php artisan config:cache
Telegram\Bot\Exceptions\TelegramSDKException : [Error] Alias [listcommands] conflicts with another command's alias list: "Telegram\Bot\Commands\HelpCommand" , try with another name or remove this alias from the list.

In the /config folder there is a telegram.php config file. If not, run this command from the command line in your project root map:

php artisan vendor:publish --provider="Telegram\Bot\Laravel\TelegramServiceProvider".

In the project of @YaroslavStrigun there is already a telegram.php. He has changed the global commands list and in that list there is a pointer to the HelpCommand.php in a different folder location while there is also one in the vendor map. So Laravel sees 2 x HelpCommand.php classes or commands. You need to overwrite the vendor HelpCommand by pointing to the location where your custom HelpCommand is for your bot. Comment out the global HelpCommand like so:

'commands'
    => [
        App\Http\Commands\StartCommand::class,
        //App\Http\Commands\HelpCommand::class,
        App\Http\Commands\TodayCommand::class,
        App\Http\Commands\LeftCommand::class,
        App\Http\Commands\WhoCommand::class,
        App\Http\Commands\TomorrowCommand::class,
        App\Http\Commands\WeekCommand::class,
        App\Http\Commands\NextWeekCommand::class,
        App\Http\Commands\WeeksCommand::class
    ],

Then go back to the top and change:

'bots'                         => [
        'mybot' => [
            'username'            => 'TelegramBot',
            'token'               => env('TELEGRAM_BOT_TOKEN', '605210044:AAHWbtxoUBgYOAinbi9niH1TAv1SQyQcQP4'),
            'certificate_path'    => env('TELEGRAM_CERTIFICATE_PATH', 'YOUR-CERTIFICATE-PATH'),
            'webhook_url'         => env('TELEGRAM_WEBHOOK_URL', 'YOUR-BOT-WEBHOOK-URL'),
            'commands'            => [
                //Acme\Project\Commands\MyTelegramBot\BotCommand::class
               App\Http\Commands\HelpCommand::class,
            ],
        ],

and define your HelpCommand over there. This should solve the problem.

By the way, it is better not to cache your config while developing code. You need to remember to clear the cache everytime you change a config value and you might forget to do so. :)

he's swearing "protected $aliases = ['listcommands'];" after execution " php artisan optimize". even when adding the commands class "Telegram\Bot\Commands\HelpCommand::class"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

realtebo picture realtebo  路  4Comments

BehroozBvk picture BehroozBvk  路  5Comments

corneyl picture corneyl  路  3Comments

chaskayu picture chaskayu  路  4Comments

Visionary89 picture Visionary89  路  5Comments