Skip to content

Bot not giving roles - event never triggers #1

Description

@Xudros

I had an issue with this where OAuth was fully setup and working and then I tried to also use this to have ranks be given it seemed to be setup fine but when I would try to trigger the events like completing an order on a test account that was linked to a test discord account it wouldnt give the ranks, I checked by running the discord API through my server and the bot had permissions to give the role yet it never would attempt to. So, after some testing and some fixes I got it working, I had to change each listener so that it went to the correct directory for example the order terminated listener used "use App\Events\OrderTerminated;" but what it needed to be was "use App\Events\Order\OrderTerminated;" as well in the order terminated listener there was a typo with the all packages option

        if($event->all_packages) {
            if($event->action == 'give') {
                $discord->giveRole($userDiscordId, $event->roles);
            } else {
                $discord->removeRole($userDiscordId, $event->roles);
            }

this needed to be

        if($event->all_packages) {
            if($event->action == 'give') {
                $discord->giveRoles($userDiscordId, $event->roles);
            } else {
                $discord->removeRoles($userDiscordId, $event->roles);
            }

as giveRole and removeRole needed to be giveRoles and removeRoles but the order terminated listener seemed to be the only one with this typo as the others were correct and thats how I found this error, finally I changed the service provider code in "/var/www/wemx/Modules/DiscordConnect/Providers/DiscordConnectServiceProvider.php as each event caller was also slightly incorrect for example I changed this line "Event::listen(Events\OrderCreated::class, Listeners\OrderCreatedListener::class);" to "Event::listen(\App\Events\Order\OrderCreated::class, \Modules\DiscordConnect\Listeners\OrderCreatedListener::class);"

and now they all work correctly. some issues I faced after was I kept doing "php artisan optimize:clear" which would delete the cache folder for certain things and then I couldnt access my dashboard for the test account but remaking the folder with "mkdir -p storage/framework/cache/data storage/framework/views storage/framework/sessions" fixed it if I did anything wrong here or anything that needs to be changed as it will break my stuff please let me know as this is the only fix ive been able to find

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions