Home > Mobile >  Cannot display server/user info
Cannot display server/user info

Time:10-10

I am new to building a bot with discord.js

I am using the same code from the discordjs.guide site:

if (commandName === 'ping') {
    await interaction.reply('Pong!');
} else if (commandName === 'server') {
    await interaction.reply('Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}\nCreated on: ${interaction.guild.createdAt}');
} else if (commandName === 'user') {
    await interaction.reply('Your tag: ${interaction.user.tag}\nYour id: ${interaction.user.id}');
} 

To have a /server or /user command show relevant info, but the output looks like:

MUDBot BOT — Today at 1:38 AM

Your tag: ${interaction.user.tag}

Your id: ${interaction.user.id}

MUDBot BOT — 10/05/2022

Server name: ${interaction.guild.name}

Total members: ${interaction.guild.memberCount}

Created on: ${interaction.guild.createdAt}

So the formatting is fine but it's not actually filling out the information fields.

Thank you.

CodePudding user response:

you need to put your output between 2 backquotes.

here is an example:

    await interaction.reply(`Your tag: ${interaction.user.tag}\nYour id: ${interaction.user.id}`);
  • Related