Discord. js отправка сообщения с @person и #channel - PullRequest
0 голосов
/ 05 августа 2020

С помощью своего бота Discord я пытаюсь создать приветственное сообщение. У меня получилось следующее:

  • Отправка сообщения, когда кто-то присоединяется
  • Получение имени человека, который присоединяется

Теперь у меня есть проблема с помощью @ или # в этом сообщении. Я использую следующий код для сообщения:

const welcomeMessage = `Welcome @${member.user.username} to the server! Please look through the #:page_with_curl:rules and assign yourself a role at #:mortar_board:role-assignment`;

Но я также пробовал:

Welcome @${member.user.username} to the server! Please look through the #?rules and assign yourself a role at #?role-assignment

Оба они делают не то, что я хочу. Я получаю следующий результат из этого кода: Message of bot without the blue outline of @ and #

What you can see there is that the @MEE6 and the 2 channel # is not blue, and not clickable. But when I copy the full text, past it and send it in the chat it does show blue.

The result I would like to have is the result of when I copy, paste and send it. That is the following: Сообщение мое с синим контуром @ и #

Вот еще немного кода:

const welcomeChannel = client.channels.cache.get('738678076174630922');
const welcomeMessage = `Welcome @${member.user.username} to the server! Please look through the #?rules and assign yourself a role at #?role-assignment`;

welcomeChannel.send(welcomeMessage)

Что мне делать, чтобы исправить это?

1 Ответ

0 голосов
/ 05 августа 2020
const welcomeMessage = `Welcome ${member}! Please look through the <#id-of-rules-channel-here> and assign yourself a role at <#id-of-role-assignment-channel-here>`

Вы можете автоматически встраивать классы Discord, такие как каналы и участники, если они уже сохранены в переменной (например, для member), или вы можете использовать их идентификаторы в тексте непосредственно в форме <#id> для каналов или <@id> для пользователей.

...