diff --git a/commands/guild.js b/commands/guild.js index 428dc71..3a99ab8 100644 --- a/commands/guild.js +++ b/commands/guild.js @@ -1,4 +1,5 @@ const ParticipatingServer = require('../database/models/ParticipatingServer'); +const { ChannelType } = require('discord.js'); // check if server has feature enabled. async function checkFeature(serverID) { @@ -31,7 +32,11 @@ module.exports.data = new CmdBuilder() .addChannelOption((option) => option .setName('channel') .setDescription('Provide a channel you want Agent Black to report to.') - .addChannelType(0) + .addChannelType( + ChannelType.GuildText, + ChannelType.PrivateThread, + ChannelType.PublicThread + ) .setRequired(true)) .addRoleOption((option) => option .setName('role') diff --git a/functions/AUTOCOMPLETE/RESOLVE/channel.js b/functions/AUTOCOMPLETE/RESOLVE/channel.js index 37353d4..b258379 100644 --- a/functions/AUTOCOMPLETE/RESOLVE/channel.js +++ b/functions/AUTOCOMPLETE/RESOLVE/channel.js @@ -2,6 +2,11 @@ This function provides a autocomplete for channels in another server. This is needed, as discords built in search only searches the server where the command is executed in */ +const VALID_TYPES = [ + ChannelType.GuildText, + ChannelType.PrivateThread, + ChannelType.PublicThread +]; module.exports.run = async (searchInput, guildId) => { // if (searchInput.length <= 2) return []; @@ -10,7 +15,14 @@ module.exports.run = async (searchInput, guildId) => { if (!guild) return [{ name: 'Define server first.', value: '0' }]; const channels = guild.channels.cache - .filter((channel) => channel.type === 'GUILD_TEXT'); + .filter((channel) => VALID_TYPES.includes(channel.type)) + .map((channel) => { + if (channel.type !== ChannelType.GuildText) { + // Notify maintainers this is a thread + channel.name += channel.Name + ` (Thread in ${channel.parent.name || "???"})` + } + return channel; + }); // id search if (searchInput !== '' && !isNaN(searchInput)) {