【发布时间】:2021-11-13 07:28:04
【问题描述】:
我正在尝试使用机器人在 discord 中访问终端。该命令的代码是:
const { Client, Message, MessageEmbed } = require("discord.js");
const child = require("child_process");
module.exports = {
name: "terminal",
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
if (message.author.id !== "") return;
const command = args.join(" ");
const errorCommand = new MessageEmbed();
errorCommand
.setColor("RED")
.setDescription("Please specify a command to execute");
if (!command) return message.reply({ embeds: [errorCommand] });
child.exec(command, (err, res) => {
if (err) return console.log(err);
message.channel.send(` \`\`\`${res.slice(0, 2000)}\`\`\` `, {
code: "js",
});
});
},
};
当我运行命令时,代码块中不显示语法突出显示。我附上了我的意思的图片。
【问题讨论】:
标签: javascript discord discord.js bots