Skip to content

Commit 23e524b

Browse files
authored
Some Fixes
1 parent 0e581eb commit 23e524b

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

backend/docker/dockerstartup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const path = require('path');
44
const isDocker = require('is-docker')
55

66
const env = process.env
7-
console.log(env)
87

98
const configPath = path.resolve(__dirname, '../../config.json')
109

@@ -37,7 +36,8 @@ async function dockerstartup() {
3736

3837
fs.writeFileSync(configPath, JSON.stringify(config, null, 4));
3938

40-
require("./../../deploy-commands.js")
39+
const { execSync } = require('child_process');
40+
execSync('node -e "require(\'./deploy-commands.js\')"', { stdio: 'inherit' });
4141
} else {
4242
console.log("Not running inside a dockers")
4343
}

backend/fetchNewMessages.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
44
const hackmudToDiscordColors = {
@@ -145,9 +145,9 @@ function fiveMinutesAgoToRubyTS() {
145145
let lastTimestamp = fiveMinutesAgoToRubyTS();
146146

147147
async 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
}

deploy-commands.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// This script was taken from the discord.js documentation
2+
13
const { REST, Routes } = require('discord.js');
24
const { clientId, guildId, token } = require('./config.json');
35
const fs = require('node:fs');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hackmud-chat-client",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A discord bot that bridges the hackmud chat with discord!",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)