Skip to content

Commit

Permalink
Merge pull request #123 from JakyeRU/remove-roles-column
Browse files Browse the repository at this point in the history
Remove roles column
  • Loading branch information
JakyeRU authored Sep 6, 2023
2 parents 7d4e4a6 + 843e920 commit 900c481
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 48 deletions.
3 changes: 0 additions & 3 deletions docs/pages/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ return [
*/

// WARNING: This feature makes one request to the Discord API for each guild you specify. (Because you need to fetch the roles for each guild)
// At the moment the database is not checked for roles when the user logs in. It will always fetch the roles from the Discord API.
// Currently, the roles are only updated in the database when the user logs in. The roles from the database can be used in a middleware.
// I'm working on a better way to do this, but for now, this will work.

'guild_roles' => [
// 'guild_id' => [
Expand Down
2 changes: 0 additions & 2 deletions src/Http/Controllers/DiscordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ public function handle(StoreUserRequest $request): RedirectResponse | JsonRespon
DB::rollBack();
return $this->throwError('missing_role');
}

(new DiscordService())->updateUserRoles($user, $guildMember, $guildId);
}
} catch (\Exception $e) {
DB::rollBack();
Expand Down
12 changes: 0 additions & 12 deletions src/Services/DiscordService.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,6 @@ public function hasRoleInGuild(GuildMember $guildMember, array $roles): bool
return !empty(array_intersect($roles, $guildMember->roles));
}

/**
* Updates the user's roles in the database.
*/
public function updateUserRoles(User $user, GuildMember $guildMember, int $guildId): void
{
// Updating the user's roles in the database.
$updatedRoles = $user->roles;
$updatedRoles[$guildId] = $guildMember->roles;
$user->roles = $updatedRoles;
$user->save();
}

/**
* Revoke the user's access token.
*
Expand Down
3 changes: 0 additions & 3 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@
*/

// WARNING: This feature makes one request to the Discord API for each guild you specify. (Because you need to fetch the roles for each guild)
// At the moment the database is not checked for roles when the user logs in. It will always fetch the roles from the Discord API.
// Currently, the roles are only updated in the database when the user logs in. The roles from the database can be used in a middleware.
// I'm working on a better way to do this, but for now, this will work.

'guild_roles' => [
// 'guild_id' => [
Expand Down

This file was deleted.

1 comment on commit 900c481

@vercel
Copy link

@vercel vercel bot commented on 900c481 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.