bug fixes

This commit is contained in:
Isaac 2022-10-04 21:23:01 +01:00
parent 74c0fd0fd1
commit bf4d17bd42
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
4 changed files with 12 additions and 5 deletions

View File

@ -4,6 +4,7 @@ const { domain } = require('./lib/http');
const { short } = require('leeks.js');
const { join } = require('path');
const { files } = require('node-dir');
const { PermissionsBitField } = require('discord.js');
process.env.PUBLIC_HOST = process.env.HTTP_EXTERNAL; // the SvelteKit app expects `PUBLIC_HOST`
@ -87,7 +88,7 @@ module.exports = async client => {
});
}
const guildMember = await guild.members.fetch(userId);
const isAdmin = guildMember?.permissions.has('MANAGE_GUILD') || client.supers.includes(userId);
const isAdmin = guildMember?.permissions.has(PermissionsBitField.Flags.ManageGuild) || client.supers.includes(userId);
if (!isAdmin) {
return res.code(403).send({
error: 'Forbidden',

View File

@ -1,3 +1,5 @@
const { PermissionsBitField } = require('discord.js');
/**
*
* @param {import("client")} client
@ -20,7 +22,7 @@ module.exports.isStaff = async (guild, userId) => {
const client = guild.client;
if (guild.client.supers.includes(userId)) return true;
const guildMember = await guild.members.fetch(userId);
if (guildMember?.permissions.has('MANAGE_GUILD')) return true;
if (guildMember?.permissions.has(PermissionsBitField.Flags.ManageGuild)) return true;
const { categories } = await client.prisma.guild.findUnique({
select: { categories: true },
where: { id: guild.id },

View File

@ -1,3 +1,5 @@
const { PermissionsBitField } = require('discord.js');
module.exports.get = fastify => ({
handler: async (req, res) => {
/** @type {import('client')} */
@ -11,14 +13,14 @@ module.exports.get = fastify => ({
if (settings.logChannel) {
const permissions = guild.members.me.permissionsIn(settings.logChannel);
if (!permissions.has('SendMessages')) {
if (!permissions.has(PermissionsBitField.Flags.SendMessages)) {
problems.push({
id: 'logChannelMissingPermission',
permission: 'SendMessages',
});
}
if (!permissions.has('EmbedLinks')) {
if (!permissions.has(PermissionsBitField.Flags.EmbedLinks)) {
problems.push({
id: 'logChannelMissingPermission',
permission: 'EmbedLinks',

View File

@ -1,3 +1,5 @@
const { PermissionsBitField } = require('discord.js');
module.exports.get = fastify => ({
handler: async (req, res) => {
const { client } = res.context.config;
@ -5,7 +7,7 @@ module.exports.get = fastify => ({
.filter(async guild => {
const member = await guild.members.fetch(req.user.payload.id);
if (!member) return false;
return member.permissions.has('MANAGE_GUILD');
return member.permissions.has(PermissionsBitField.Flags.ManageGuild);
})
.map(guild => ({
id: guild.id,