Skip to content

Commit

Permalink
move webhook handler to discord modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Techbot121 authored and Meta Construct committed May 17, 2024
1 parent 1a0b2fa commit 742648f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/services/Tenor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const FORMATS = [
"nanogif_transparent",
] as const;

type ContentFormat = typeof FORMATS[number];
type ContentFormat = (typeof FORMATS)[number];

type MediaObject = {
url: string;
Expand Down
2 changes: 2 additions & 0 deletions app/services/discord/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ProgressBarLoader from "./premium-progress-bar";
import ShitpostLoader from "./shitposting";
import StarboardLoader from "./starboard";
import TempVoiceChannelsLoader from "./temp-voice-channels";
import WebhookHandlerLoader from "./webhook-handler";

export default [
CommandsLoader,
Expand All @@ -20,4 +21,5 @@ export default [
ShitpostLoader,
StarboardLoader,
TempVoiceChannelsLoader,
WebhookHandlerLoader,
];
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DiscordBot } from "..";
import { GameBridge } from "../../gamebridge";
import { WebApp } from "..";
import { Webhooks, createNodeMiddleware } from "@octokit/webhooks";
import { clamp } from "@/utils";
import Discord from "discord.js";
Expand Down Expand Up @@ -83,17 +83,16 @@ const isRemoteMergeCommit = (message: string) =>
const isMergeCommit = (message: string) =>
message.startsWith("Merge branch") || isRemoteMergeCommit(message);

export default (webApp: WebApp): void => {
webApp.app.use(createNodeMiddleware(GitHub, { path: "/webhooks/github" }));
let webhook: Discord.Webhook;
let bridge: GameBridge | undefined;
export default (bot: DiscordBot): void => {
const webapp = bot.container.getService("WebApp");
if (!webapp) return;

const bot = webApp.container.getService("DiscordBot");
if (!bot) return;
webapp.app.use(createNodeMiddleware(GitHub, { path: "/webhooks/github" }));

bot.discord.on("ready", async () => {
bridge = bot.bridge;
let webhook: Discord.Webhook;
const bridge = bot.bridge;

bot.discord.on("ready", async () => {
const channel = bot.getTextChannel(bot.config.channels.publicCommits);
if (channel) {
const hooks = await channel.fetchWebhooks();
Expand Down
2 changes: 0 additions & 2 deletions app/services/webapp/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ci from "./ci";
import discordOAuth from "./discord-oauth";
import gmodErrorHandler from "./gmod-error-handler";
import steamOAuth from "./steam-oauth";
import webhookHandler from "./webhook-handler";

export default [
addEmojiAPI,
Expand All @@ -17,5 +16,4 @@ export default [
discordOAuth,
gmodErrorHandler,
steamOAuth,
webhookHandler,
];

0 comments on commit 742648f

Please sign in to comment.