[text]
与[username]
结合(您可以将任何用户名放在“realdonaldtrump
”中。之后的任何内容都是实际消息。
我尝试了很多东西,只有我工作的东西是特朗普是默认的推文而不能改变它所以它将是>tweet [message]
而不是>tweet [username] [message]
但我想有自定义用户名。关于如何从[username]
中移除[text]
的任何线索
这是代码
exports.exec = async (client, message, args, level, settings, texts) => {
const user = args[0];
// Fires Error message that the command wasn't ran correctly.
if (!user) {
return client.emit('commandUsage', message, this.help);
}
// Fires Error message that the command wasn't ran correctly.
const text = args.join(" ");
// Below is a self-deletion message prior to image sending when it's fetching the actual image.
message.channel.send({
embed: {
color: 0,
description: `${message.author} Generating image.`
}
}).then(msg => {
msg.delete(5000).catch(() => { });
}).catch(e => {
});
// Above is a self-deletion message prior to image sending when it's fetching the actual image.
try {
const { body } = await snekfetch.get(`https://nekobot.xyz/api/imagegen?type=${user.toLowerCase() === "realdonaldtrump" ? "trumptweet" : "tweet"}&username=${user.startsWith("@") ? user.slice(1) : user}&text=${encodeURIComponent(text)}`);
message.channel.send("", { file: body.message });
// Below is a automatic logger
} catch (err) {
const errorlogs = client.channels.get('480735959944527886')
const embed = new discord.RichEmbed()
.setAuthor("ERROR", "https://i.imgur.com/Omg7uJV.png")
.setDescription(`${message.author} An error has occured using this command, this has automatically be logged and sent to ${client.channels.get('480735959944527886')} to be reviewed.`)
.setColor(0)
.setTimestamp()
message.channel.send({ embed });
errorlogs.send(`Error with \`$tweet\` command!\n\nError:\n\n ${err}`)
}
// Above is a automatic logger
};
你正在连接你的args
来设置你的text
变量
const text = args.join(" ");
但由于args
值在你的例子中是["realdonaltrump", "yeeet"]
,它导致text
具有值"realdonaldtrump yeet"
。
就像你为user
variable所做的那样:
const text = args[1]
您可能需要验证参数的值。