Find out if someone has a role

前端 未结 6 1866
萌比男神i
萌比男神i 2020-12-06 11:47

I made a simple quote bot for a server, but the admin only wants mod+ people to be able to add quotes to avoid spam. I went to the documentation and did everything, but I ca

6条回答
  •  暖寄归人
    2020-12-06 12:08

    The discord.js api has been updated and there is a better way since .exists() has been deprecated.

    if (message.member.roles.some(role => role.name === 'Whatever')) {}

    This is better than .find() because .find() returns the role object (or undefined) which is then converted into a boolean. The .some() method returns a boolean by default.

提交回复
热议问题