【问题标题】:send all messages to a specific channel in discord js将所有消息发送到discord js中的特定频道
【发布时间】:2020-05-18 05:46:45
【问题描述】:

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

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

我如何以 info.t.other_thing_i_want_to_get 或类似的格式获取其他内容?

【问题讨论】:

    标签: discord discord.js


    【解决方案1】:

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

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

    const info = require('./path_to_json/info.json');
    

    你的 json 必须看起来像:

    {t: 'PRESCENCE_UPDATE', other_thing_i_want_to_get: 'blah blah blah'}
    

    使用此代码,您可以使用 info.other_thing_i_want_to_get 获取它

    【讨论】:

      猜你喜欢
      • 2021-10-28
      • 2020-10-01
      • 2023-03-27
      • 2020-07-06
      • 2019-03-01
      • 2021-03-24
      • 2021-07-06
      • 2019-03-18
      • 2021-08-18
      相关资源
      最近更新 更多