Skip to content

Commit

Permalink
fix: better filtering before creating joinable object
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Aug 11, 2018
1 parent f95f3d9 commit b2cfb44
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/settings/DatabaseQueries/PrivateRoomQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PrivateRoomQueries {
return undefined;
}).filter(role => role).map((role) => {
const parsed = JSON.parse(role);
if (typeof parsed === 'object') {
if (typeof parsed === 'object' && guild.roles.has(parsed.id)) {
const joinable = new JoinableRole(guild.roles.get(parsed.id));
if (typeof parsed.requiredRole !== 'undefined') {
joinable.requiredRole = guild.roles.has(parsed.requiredRole)
Expand All @@ -60,7 +60,7 @@ class PrivateRoomQueries {
}
joinable.isLeaveable = typeof parsed.leaveable !== 'undefined' ? parsed.leavable : true;
return joinable;
} if (typeof parsed === 'string') {
} if (typeof parsed === 'string' && guild.roles.has(parsed)) {
const joinable = new JoinableRole(guild.roles.get(parsed));
joinable.requiredRole = undefined;
joinable.isLeaveable = true;
Expand Down

0 comments on commit b2cfb44

Please sign in to comment.