Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion commands/guild.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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')
Expand Down
14 changes: 13 additions & 1 deletion functions/AUTOCOMPLETE/RESOLVE/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand All @@ -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)) {
Expand Down