0

I'm working on a whois slash command for a Discord Bot and I want to display the tag for the user selected within a command block but if I use " or ' for the value of the field on the embed, the variable doesn't work therefore I have to use `. The issue with this is, I can't see a way to show the text outputted by the variable as a code block.

My code:

            .addFields(
                { name: '__User Information__', value: `**Name:** ${user.tag}\n <:Spacer:1064084066997129277> • Mention: ${user}`, inline:false},
            )

1 Answer 1

1

You can escape a backtick like so: \`,

So, if you want to add codeblocks inside your embed you can do:

`Example codeblock: \`\`\`This is a codeblock! ${variable}\`\`\``

Here's an example from my bot, which displays the user id and message id inside a codeblock:

`\`\`\`ini\nUser = ${message.member.id}\nID = ${message.id}\`\`\``

The code above roughly translates to:

```ini
User = ${message.member.id}
ID = ${message.id}
```

You can read more about template literals here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.