1- const { loadConfigVar, loadChnlMap } = require ( './../backend/ loadvar.js' ) ;
1+ const { loadConfigVar, loadChnlMap } = require ( './loadvar.js' ) ;
22
33// Full Hackmud-to-Discord color mapping // = U+001B
44const hackmudToDiscordColors = {
@@ -145,9 +145,9 @@ function fiveMinutesAgoToRubyTS() {
145145let lastTimestamp = fiveMinutesAgoToRubyTS ( ) ;
146146
147147async function fetchNewMessages ( client ) {
148- const channelMappings = await loadChnlMap
148+ const channelMappings = await loadChnlMap ( ) ;
149149 const pullusers = await loadConfigVar ( "pullusers" ) ;
150- const mudtoken = await loadConfigVar ( "mudtoken" )
150+ const mudtoken = await loadConfigVar ( "mudtoken" ) ;
151151 const apiUrl = 'https://www.hackmud.com/mobile/chats.json' ;
152152 const payload = {
153153 chat_token : mudtoken ,
@@ -161,7 +161,7 @@ async function fetchNewMessages(client) {
161161 body : JSON . stringify ( payload ) ,
162162 } ) ;
163163 const result = await response . json ( ) ;
164- if ( result . ok ) {
164+ if ( result . ok == true ) {
165165 Object . entries ( result . chats ) . forEach ( ( [ user , messages ] ) => {
166166 if ( messages . length === 0 ) {
167167 //console.log(`No new messages for user: ${user}`);
@@ -170,11 +170,10 @@ async function fetchNewMessages(client) {
170170 const discordChannelId = channelMappings [ user ]
171171 if ( discordChannelId ) {
172172 const formattedMessage = Formatter ( message )
173-
174173 const channel = client . channels . cache . get ( discordChannelId ) ;
175174 if ( channel ) {
176- const result = await channel . send ( formattedMessage ) ;
177- if ( result . code === 50013 ) {
175+ const mresult = await channel . send ( formattedMessage ) ;
176+ if ( mresult . code === 50013 ) {
178177 console . log ( `No permission to send message in ${ channel . name } , message not sent` ) ;
179178 return
180179 }
0 commit comments