Skip to content

Commit

Permalink
fix(network): limit editing network to channel's server
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Aug 29, 2023
1 parent f5296c0 commit 60c51b4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Commands/Main/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ export default {
const db = getDb();
const networkChannelId = interaction.options.getString('network', true);
const networkData = await db.connectedList.findFirst({ where: { channelId: networkChannelId }, include: { hub: true } });
const userIsHubMod =
networkData?.hub?.ownerId === interaction.user.id ||
networkData?.hub?.moderators.some((m) => m.userId === interaction.user.id);

if (!userIsHubMod) {
// check if channel is in the server the command was used in
const channelInServer = await interaction.guild?.channels.fetch(networkChannelId).catch(() => null);
if (channelInServer) {
return interaction.reply({
content: 'You are not a moderator of this network.',
content: `${interaction.client.emotes.normal.no} Please use this command in the server the joined/connected channel belongs to.`,
ephemeral: true,
});
}
Expand Down

0 comments on commit 60c51b4

Please sign in to comment.