Skip to content

Commit

Permalink
feat: add check for leading @. closes #426
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Dec 23, 2020
1 parent e5a926a commit aa498d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/commands/Roles/JoinRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const Command = require('../../models/Command.js');
* @returns {Role|null} Role
*/
const getRoleForString = (string, message) => {
const trimmedString = string.trim();
const trimmedString = string.trim()
.replace(/^@(.*)/, '$1')
.replace(/<@&(.*)>/, '$1');
const roleFromId = message.guild.roles.cache.get(trimmedString);
let roleFromName;
if (typeof roleFromId === 'undefined') {
Expand Down
4 changes: 3 additions & 1 deletion src/commands/Roles/LeaveRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const Command = require('../../models/Command.js');
* @returns {Role|null} Role
*/
const getRoleForString = (string, message) => {
const trimmedString = string.trim();
const trimmedString = string.trim()
.replace(/^@(.*)/, '$1')
.replace(/<@&(.*)>/, '$1');
const roleFromId = message.guild.roles.cache.get(trimmedString);
let roleFromName;
if (typeof roleFromId === 'undefined') {
Expand Down
5 changes: 4 additions & 1 deletion src/settings/DatabaseQueries/PrivateRoomQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class PrivateRoomQueries {
WHERE guild_id=${guild.id}`;
const [rows] = await this.query(query);
if (rows.length) {
const validList = rows[0].id_list
const rawList = typeof rows[0].id_list === 'string'
? JSON.parse(rows[0].id_list)
: rows[0].id_list;
const validList = rawList
.filter((role) => {
if (!role) {
return undefined;
Expand Down

0 comments on commit aa498d6

Please sign in to comment.