Q
Q
qwikman12021-03-19 23:07:35
Node.js
qwikman1, 2021-03-19 23:07:35

How to issue a role on the server when writing a bot in PM?

When writing a bot in PM, it is necessary to issue a role on the server, I searched the Internet, but did not find anything

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-03-19
@Alexandre888

check if the message was sent to a text channel or a PM to a bot: assign a role:
message.channel.type === "dm";

let role = client.guilds.cache.get("id_сервера")
    .roles.cache.find /* или .get() */ (// условие //)
  
  client.guilds.cache.get("id_сервера")
    .members.cache.get(message.author.id)
    .roles.add(role)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question