简体   繁体   English

Discord.js 加载字符串

[英]Discord.js loadstring

I want to make a command for a bot to evaluate a string (run it as code).我想为机器人创建一个命令来评估一个字符串(将其作为代码运行)。 Is there a way to run a string as code in discord.js?有没有办法在 discord.js 中将字符串作为代码运行 Not rly having a code sample here, I just want to know of a function to do so.这里没有代码示例,我只想知道一个 function 这样做。

discord.js is using Node which uses Javascript, so your solution to evalute a code from a string should be with the eval() method. discord.js 正在使用使用 Javascript 的 Node,因此从字符串评估代码的解决方案应该使用eval()方法。 Eval on developer.mozilla.org developer.mozilla.org 上的评估

However, as soon as you implement eval() , you'll soon find out that they have access to basically your whole computer.但是,一旦您实施eval() ,您很快就会发现他们基本上可以访问您的整个计算机。 I would not recommend you to use this.我不建议你使用这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM