mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 17:44:15 +02:00
feat(arabot): add type checking to checkStaff command
This commit is contained in:
parent
750b10062f
commit
a498cde933
@ -75,10 +75,9 @@ export class RestrictLogsCommand extends Command {
|
||||
userId = user.id;
|
||||
}
|
||||
|
||||
let staffChannel = false;
|
||||
if (channel.type === ChannelType.GuildText) {
|
||||
const staffChannel = checkStaff(channel);
|
||||
if (staffChannel) {
|
||||
channel = channel as TextChannel;
|
||||
staffChannel = checkStaff(channel);
|
||||
|
||||
if (userId === null) {
|
||||
let topic: string[];
|
||||
|
@ -20,14 +20,13 @@
|
||||
import { RegisterBehavior, Args } from '@sapphire/framework';
|
||||
import { Subcommand } from '@sapphire/plugin-subcommands';
|
||||
import {
|
||||
ChannelType,
|
||||
EmbedBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonInteraction,
|
||||
ButtonStyle,
|
||||
} from 'discord.js';
|
||||
import type { Message, GuildMember, TextChannel } from 'discord.js';
|
||||
import type { Message, GuildMember } from 'discord.js';
|
||||
import { isMessageInstance } from '@sapphire/discord.js-utilities';
|
||||
import { addExistingUser } from '#utils/database/dbExistingUser';
|
||||
import {
|
||||
@ -43,7 +42,10 @@ import IDs from '#utils/ids';
|
||||
// TODO add a check when they join the server to give the user the sus role again
|
||||
|
||||
export class SusCommand extends Subcommand {
|
||||
public constructor(context: Subcommand.LoaderContext, options: Subcommand.Options) {
|
||||
public constructor(
|
||||
context: Subcommand.LoaderContext,
|
||||
options: Subcommand.Options,
|
||||
) {
|
||||
super(context, {
|
||||
...options,
|
||||
name: 'sus',
|
||||
@ -201,14 +203,7 @@ export class SusCommand extends Subcommand {
|
||||
return;
|
||||
}
|
||||
|
||||
let staffChannel = false;
|
||||
let { channel } = interaction;
|
||||
if (channel !== null) {
|
||||
if (channel.type === ChannelType.GuildText) {
|
||||
channel = channel as TextChannel;
|
||||
staffChannel = checkStaff(channel);
|
||||
}
|
||||
}
|
||||
const staffChannel = checkStaff(interaction.channel);
|
||||
|
||||
// Gets the sus notes from the database
|
||||
const notes = await findNotes(user.id, true);
|
||||
|
@ -17,8 +17,9 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import type { TextChannel } from 'discord.js';
|
||||
import type { TextBasedChannel } from 'discord.js';
|
||||
import IDs from '#utils/ids';
|
||||
import { ChannelType } from 'discord.js';
|
||||
|
||||
/**
|
||||
* Checks if the channel is in the staff category.
|
||||
@ -26,7 +27,15 @@ import IDs from '#utils/ids';
|
||||
* @returns {boolean} true if is in staff channel
|
||||
*/
|
||||
|
||||
export function checkStaff(channel: TextChannel) {
|
||||
export function checkStaff(channel: TextBasedChannel | null) {
|
||||
if (channel === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (channel.type !== ChannelType.GuildText) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (channel.parent === null) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user