Skip to content

Commit 2977206

Browse files
Techbot121Meta Construct
authored andcommitted
I just realised this was in the wrong place all along, oops!
1 parent 585d588 commit 2977206

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

app/services/discord/modules/webhook-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default async (bot: DiscordBot): Promise<void> => {
9999

100100
let webhook: Discord.Webhook;
101101
const bridge = bot.bridge;
102-
const chatWebhook = bot.bridge.servers.find(s => s.discordChatWH)?.discordChatWH;
102+
const chatWebhook = bot.bridge.discordChatWH;
103103

104104
bot.discord.on("ready", async () => {
105105
const channel = bot.getTextChannel(bot.config.channels.publicCommits);

app/services/gamebridge/GameBridge.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export default class GameBridge extends Service {
2121
webApp: WebApp;
2222
ws: WebSocketServer;
2323
servers: GameServer[] = [];
24+
discordChatWH: Discord.WebhookClient;
25+
discordErrorWH: Discord.WebhookClient;
26+
discordPacErrorWH: Discord.WebhookClient;
2427

2528
constructor(container: Container) {
2629
super(container);
@@ -33,6 +36,15 @@ export default class GameBridge extends Service {
3336
httpServer: this.webApp.http,
3437
autoAcceptConnections: false,
3538
});
39+
this.discordChatWH = new Discord.WebhookClient({
40+
url: config.chatWebhookUrl,
41+
});
42+
this.discordErrorWH = new Discord.WebhookClient({
43+
url: config.errorWebhookUrl,
44+
});
45+
this.discordPacErrorWH = new Discord.WebhookClient({
46+
url: config.pacErrorWebhookUrl,
47+
});
3648

3749
this.ws.on("request", req => {
3850
this.handleConnection(req);
@@ -131,12 +143,12 @@ export default class GameBridge extends Service {
131143
type: 3,
132144
},
133145
],
134-
}
146+
}
135147
: {
136148
status: "idle",
137149
afk: true,
138150
activities: [],
139-
};
151+
};
140152

141153
discord.user?.setPresence(presence);
142154

app/services/gamebridge/GameServer.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ export default class GameServer {
4545
discord: DiscordClient;
4646
discordIcon: string | undefined = undefined;
4747
discordBanner: string | undefined = undefined;
48-
discordChatWH?: WebhookClient; // chat relay webhook
49-
discordErrorWH?: WebhookClient; // error relay webhook
50-
discordPacErrorWH?: WebhookClient; // pac3 specific error webhook todo: remove???
5148
gamemode: {
5249
folderName: string;
5350
name: string;
@@ -78,15 +75,6 @@ export default class GameServer {
7875
this.discord = new DiscordClient(this, {
7976
intents: ["Guilds", "GuildMessages", "MessageContent"],
8077
});
81-
this.discordChatWH = new WebhookClient({
82-
url: config.bridge.config.chatWebhookUrl,
83-
});
84-
this.discordErrorWH = new WebhookClient({
85-
url: config.bridge.config.errorWebhookUrl,
86-
});
87-
this.discordPacErrorWH = new WebhookClient({
88-
url: config.bridge.config.pacErrorWebhookUrl,
89-
});
9078

9179
this.discord.run(this.config.discordToken);
9280

app/services/gamebridge/payloads/ChatPayload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ export default class ChatPayload extends Payload {
155155
super.handle(payload, server);
156156
const { player } = payload.data;
157157
let { content } = payload.data;
158-
const { bridge, discord, discordChatWH: discordWH } = server;
158+
const { bridge, discord } = server;
159159

160160
if (!discord.ready) return;
161161

162162
const guild = discord.guilds.cache.get(discord.config.bot.primaryGuildId);
163163
if (!guild) return;
164164

165-
const webhook = discordWH;
165+
const webhook = bridge.discordChatWH;
166166

167167
const avatar = await (
168168
await bridge.container.getService("Steam")

app/services/gamebridge/payloads/ErrorPayload.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export default class ErrorPayload extends Payload {
1717

1818
static async handle(payload: ErrorRequest, server: GameServer): Promise<void> {
1919
super.handle(payload, server);
20-
const { discordErrorWH: discordEWH, discordPacErrorWH: discordPEWH } = server;
20+
const { bridge } = server;
2121

2222
const { hook_error } = payload.data;
2323

2424
if (hook_error.name.includes("@repl_") || this.lastError === hook_error) return;
2525

26-
const webhook = discordEWH;
27-
const pacWebhook = discordPEWH;
26+
const webhook = bridge.discordErrorWH;
27+
const pacWebhook = bridge.discordPacErrorWH;
2828

2929
const lines = hook_error.errormsg.split(/\r?\n/);
3030
const err = lines[0];

0 commit comments

Comments
 (0)