Skip to content

Commit

Permalink
fix isAllowed on reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Techbot121 authored and Meta Construct committed Jun 30, 2024
1 parent 40d2db7 commit 68df9f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/services/gamebridge/discord/DiscordClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export default class DiscordClient extends Discord.Client {
this.login(token);
}

public static async isAllowed(server: GameServer, user: Discord.User): Promise<boolean> {
public async isAllowed(user: Discord.User): Promise<boolean> {
try {
const discord = server.discord;
const guild = discord.guilds.cache.get(discord.config.bot.primaryGuildId);
const discord = this.gameServer.discord;
const guild = await discord.guilds.fetch(discord.config.bot.primaryGuildId);
if (!guild) return false;

const member = await guild.members.fetch(user.id);
Expand Down
10 changes: 8 additions & 2 deletions app/services/gamebridge/payloads/AdminNotifyPayload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as requestSchema from "./structures/AdminNotifyRequest.json";
import { AdminNotifyRequest } from "./structures";
import { DiscordClient, GameServer } from "..";
import { GameServer } from "..";
import { f } from "@/utils";
import Discord from "discord.js";
import Payload from "./Payload";
Expand All @@ -26,7 +26,13 @@ export default class AdminNotifyPayload extends Payload {
const collector = notificationsChannel.createMessageComponentCollector({ filter });

collector.on("collect", async (ctx: Discord.ButtonInteraction) => {
if (!(await DiscordClient.isAllowed(server, ctx.user))) return;
if (!(await server.discord.isAllowed(ctx.user))) {
await ctx.reply({
content: "you're not allowed to use this button...",
ephemeral: true,
});
return;
}
await ctx.deferReply();
try {
const interactionId64 = new SteamID(
Expand Down

0 comments on commit 68df9f0

Please sign in to comment.