Merge pull request #250 from DarkView/fix_invalidRoleId

Fix "invalid role id" in addrole command
This commit is contained in:
Miikka 2021-08-19 20:10:11 +03:00 committed by GitHub
commit 3762584b62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1392,8 +1392,8 @@ export async function resolveRoleId(bot: Client, guildId: string, value: string)
// Role name
const roleList = (await bot.guilds.fetch(guildId as Snowflake)).roles.cache;
const role = roleList.filter(x => x.name.toLocaleLowerCase() === value.toLocaleLowerCase());
if (role[0]) {
return role[0].id;
if (role.size >= 1) {
return role.firstKey();
}
// Role ID