Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将所有消息发送到discord js中的特定通道_Discord_Discord.js - Fatal编程技术网

将所有消息发送到discord js中的特定通道

将所有消息发送到discord js中的特定通道,discord,discord.js,Discord,Discord.js,我开始编写我的discord机器人,并尝试添加一个功能,将特定原始事件记录到特定通道。我在Reddit和这个网站上查看了无数次,试图找到一种不被反对但运气不佳的方法。我希望我能在这个网站上回答。总而言之,我需要将消息发送到特定的频道。另一件事是从JSON文件中提取信息,如下所示: info.json: {t: 'PRESCENCE_UPDATE, {other_thing_i_want_to_get: 'blah blah blah'}} 我如何获取格式为info.t.other\u thi

我开始编写我的discord机器人,并尝试添加一个功能,将特定原始事件记录到特定通道。我在Reddit和这个网站上查看了无数次,试图找到一种不被反对但运气不佳的方法。我希望我能在这个网站上回答。总而言之,我需要将消息发送到特定的频道。另一件事是从JSON文件中提取信息,如下所示:

info.json:  {t: 'PRESCENCE_UPDATE,
{other_thing_i_want_to_get: 'blah blah blah'}}

我如何获取格式为info.t.other\u thing\u我希望\u获取的其他东西,或者类似的东西?

我建议创建一个json文件并导入它

使用npm模块,您可以创建WriteFileStreams来更改文件中存储的值

const info = require('./path_to_json/info.json');
您的json必须如下所示:

{t: 'PRESCENCE_UPDATE', other_thing_i_want_to_get: 'blah blah blah'}
使用此代码,您可以使用info.other\u thing\u我希望\u获得