I’m trying to make the bot reply to me saying the username but it won’t.
Alright, JavaScript is not quite my game but I think I see the problem.
Can you send me the code in a reply?
(I need a close up)
var Discord = require(‘discord.js’)
var rblxbot = require(‘noblox.js’)
var config = require(’…/config.json’)
module.exports = {
name: 'Promote', //Case Sensitive
description: ' ......',
async execute(message,msg,split) {
if(!message.member.roles.cache.has('874300093417799700'))return message.reply('You do not have permission to rank users. You must be **Board Of Executives+**.')
const robloxname = split[1]
if(!robloxname)return message.reply("Username is missing. Please provide a correct ROBLOX username.")
await rblxbot.getIdFromUsername(robloxname)
.then(async (robloxid) => {
rblxbot.promote(config.GroupId, robloxid)
.then((success)=>{
message.reply('Successfully promoted ${robloxname}')
})
.catch((err) => {
message.reply(err.message)
})
})
.catch((err) => {
message.reply('Invalid user. Try again.')
console.robloxid(err)
})
}
}
Try printing “robloxname”
String Interpolation
Before ES6, we could embed an expression with a string using the +
operator.
const name = "cookie";
const myString = "My name is " + name;
This will output, My name is cookie
.
With template literals, we can accomplish the same thing through string interpolation.
String interpolation is a process where you can pass a valid JavaScript expression such as a variable into a template literal. The expression inside ${}
is evaluated, and the result of the evaluation is embedded into the string as demonstrated in the example below:
const name = "cookie";
const myString = `My name is ${name}`;
Output:
My name is cookie
Has that fixed it, if it doesn’t I’m not sure.
Yes, thank you! (20 charssssssssssssssssss)
This topic was automatically closed after 7 days. New replies are no longer allowed.