mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
channel typings
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
c33a216857
commit
8347095fa0
15 changed files with 91 additions and 103 deletions
|
@ -2,7 +2,15 @@
|
|||
* @file Utility functions that are plugin-instance-specific (i.e. use PluginData)
|
||||
*/
|
||||
|
||||
import { GuildMember, Message, MessageMentionOptions, MessageOptions, TextChannel } from "discord.js";
|
||||
import {
|
||||
GuildMember,
|
||||
GuildTextBasedChannel,
|
||||
Message,
|
||||
MessageMentionOptions,
|
||||
MessageOptions,
|
||||
TextBasedChannel,
|
||||
TextChannel,
|
||||
} from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { CommandContext, configUtils, ConfigValidationError, GuildPluginData, helpers, PluginOptions } from "knub";
|
||||
import { PluginOverrideCriteria } from "knub/dist/config/configTypes";
|
||||
|
@ -209,7 +217,7 @@ export async function sendSuccessMessage(
|
|||
|
||||
export async function sendErrorMessage(
|
||||
pluginData: AnyPluginData<any>,
|
||||
channel: TextChannel,
|
||||
channel: GuildTextBasedChannel,
|
||||
body: string,
|
||||
allowedMentions?: MessageMentionOptions,
|
||||
): Promise<Message | undefined> {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { ChannelType, Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { convertDelayStringToMS, isDiscordAPIError, tDelayString, tNullable } from "../../../utils";
|
||||
import { automodAction } from "../helpers";
|
||||
|
@ -23,15 +22,15 @@ export const SetSlowmodeAction = automodAction({
|
|||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
||||
|
||||
// Only text channels and text channels within categories support slowmodes
|
||||
if (!channel || !(channel.type === ChannelTypeStrings.TEXT || ChannelTypeStrings.CATEGORY)) {
|
||||
if (!channel || !(channel.type === ChannelType.GuildText || ChannelType.GuildCategory)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const channelsToSlowmode: TextChannel[] = [];
|
||||
if (channel.type === ChannelTypeStrings.CATEGORY) {
|
||||
if (channel.type === ChannelType.GuildCategory) {
|
||||
// Find all text channels within the category
|
||||
for (const ch of pluginData.guild.channels.cache.values()) {
|
||||
if (ch.parentId === channel.id && ch.type === ChannelTypeStrings.TEXT) {
|
||||
if (ch.parentId === channel.id && ch.type === ChannelType.GuildText) {
|
||||
channelsToSlowmode.push(ch as TextChannel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { GuildFeature, ThreadAutoArchiveDuration } from "discord-api-types/v9";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { ChannelType, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter";
|
||||
import { ChannelTypeStrings } from "../../../types";
|
||||
import { convertDelayStringToMS, MINUTES, noop, tDelayString, tNullable } from "../../../utils";
|
||||
import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { automodAction } from "../helpers";
|
||||
|
@ -32,7 +31,7 @@ export const StartThreadAction = automodAction({
|
|||
const threads = contexts.filter((c) => {
|
||||
if (!c.message || !c.user) return false;
|
||||
const channel = pluginData.guild.channels.cache.get(c.message.channel_id);
|
||||
if (channel?.type !== ChannelTypeStrings.TEXT || !channel.isTextBased()) return false; // for some reason the typing here for channel.type defaults to ThreadChannelTypes (?)
|
||||
if (channel?.type !== ChannelType.GuildText || !channel.isTextBased()) return false; // for some reason the typing here for channel.type defaults to ThreadChannelTypes (?)
|
||||
// check against max threads per channel
|
||||
if (actionConfig.limit_per_channel && actionConfig.limit_per_channel > 0) {
|
||||
const threadCount = channel.threads.cache.filter(
|
||||
|
@ -67,10 +66,7 @@ export const StartThreadAction = automodAction({
|
|||
.create({
|
||||
name: threadName,
|
||||
autoArchiveDuration: autoArchive,
|
||||
type:
|
||||
actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads)
|
||||
? ChannelTypeStrings.PRIVATE_THREAD
|
||||
: ChannelTypeStrings.PUBLIC_THREAD,
|
||||
type: actionConfig.private ? ChannelType.PrivateThread : ChannelType.PublicThread,
|
||||
startMessage:
|
||||
!actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads)
|
||||
? threadContext.message!.id
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Util } from "discord.js";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { ChannelType, escapeInlineCode } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { asSingleLine } from "../../../utils";
|
||||
|
@ -39,7 +38,7 @@ export const SlowmodeClearCmd = slowmodeCmd({
|
|||
}
|
||||
|
||||
try {
|
||||
if (args.channel.type === ChannelTypeStrings.TEXT) {
|
||||
if (args.channel.type === ChannelType.GuildText) {
|
||||
await clearBotSlowmodeFromUserId(pluginData, args.channel, args.user.id, args.force);
|
||||
} else {
|
||||
sendErrorMessage(
|
||||
|
@ -58,7 +57,7 @@ export const SlowmodeClearCmd = slowmodeCmd({
|
|||
msg.channel,
|
||||
asSingleLine(`
|
||||
Failed to clear slowmode from **${args.user.tag}** in <#${args.channel.id}>:
|
||||
\`${Util.escapeInlineCode(e.message)}\`
|
||||
\`${escapeInlineCode(e.message)}\`
|
||||
`),
|
||||
);
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Permissions, TextChannel, ThreadChannel, Util } from "discord.js";
|
||||
import { ChannelType, GuildTextBasedChannel, Permissions, TextChannel, ThreadChannel, Util } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { asSingleLine, DAYS, HOURS, MINUTES } from "../../../utils";
|
||||
|
@ -39,7 +38,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
],
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
const channel: TextChannel | ThreadChannel = args.channel || msg.channel;
|
||||
const channel: GuildTextBasedChannel = args.channel || msg.channel;
|
||||
|
||||
if (args.time === 0) {
|
||||
// Workaround until we can call SlowmodeDisableCmd from here
|
||||
|
@ -123,7 +122,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
if (mode === "native") {
|
||||
// If there is an existing bot-maintained slowmode, disable that first
|
||||
const existingBotSlowmode = await pluginData.state.slowmodes.getChannelSlowmode(channel.id);
|
||||
if (existingBotSlowmode && channel.type === ChannelTypeStrings.TEXT) {
|
||||
if (existingBotSlowmode && channel.isTextBased()) {
|
||||
await disableBotSlowmodeForChannel(pluginData, channel);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake, VoiceChannel } from "discord.js";
|
||||
import { ChannelType, Snowflake, VoiceChannel } from "discord.js";
|
||||
import {
|
||||
channelToTemplateSafeChannel,
|
||||
memberToTemplateSafeMember,
|
||||
|
@ -9,7 +9,6 @@ import { LogType } from "../../../data/LogType";
|
|||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { channelMentionRegex, isSnowflake, simpleClosestStringMatch } from "../../../utils";
|
||||
import { utilityCmd } from "../types";
|
||||
import { ChannelTypeStrings } from "../../../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export const VcmoveCmd = utilityCmd({
|
||||
|
@ -48,7 +47,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
} else {
|
||||
// Search string -> find closest matching voice channel name
|
||||
const voiceChannels = [...pluginData.guild.channels.cache.values()].filter(
|
||||
(c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE,
|
||||
(c): c is VoiceChannel => c.type === ChannelType.GuildVoice,
|
||||
);
|
||||
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, (ch) => ch.name);
|
||||
if (!closestMatch) {
|
||||
|
@ -127,7 +126,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
} else {
|
||||
// Search string -> find closest matching voice channel name
|
||||
const voiceChannels = [...pluginData.guild.channels.cache.values()].filter(
|
||||
(c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE,
|
||||
(c): c is VoiceChannel => c.type === ChannelType.GuildVoice,
|
||||
);
|
||||
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, (ch) => ch.name);
|
||||
if (!closestMatch) {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { MessageEmbedOptions, Snowflake, StageChannel, ThreadChannel, VoiceChannel } from "discord.js";
|
||||
import { ChannelType, MessageEmbedOptions, Snowflake, StageChannel, ThreadChannel, VoiceChannel } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { EmbedWith, formatNumber, MINUTES, preEmbedPadding, trimLines, verboseUserMention } from "../../../utils";
|
||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||
import { UtilityPluginType } from "../types";
|
||||
|
@ -36,24 +35,25 @@ export async function getChannelInfoEmbed(
|
|||
|
||||
const icon =
|
||||
{
|
||||
[ChannelTypeStrings.VOICE]: VOICE_CHANNEL_ICON,
|
||||
[ChannelTypeStrings.NEWS]: ANNOUNCEMENT_CHANNEL_ICON,
|
||||
[ChannelTypeStrings.STAGE]: STAGE_CHANNEL_ICON,
|
||||
[ChannelTypeStrings.PUBLIC_THREAD]: PUBLIC_THREAD_ICON,
|
||||
[ChannelTypeStrings.PRIVATE_THREAD]: PRIVATE_THREAD_UCON,
|
||||
[ChannelType.GuildVoice]: VOICE_CHANNEL_ICON,
|
||||
[ChannelType.GuildAnnouncement]: ANNOUNCEMENT_CHANNEL_ICON,
|
||||
[ChannelType.GuildStageVoice]: STAGE_CHANNEL_ICON,
|
||||
[ChannelType.PublicThread]: PUBLIC_THREAD_ICON,
|
||||
[ChannelType.PrivateThread]: PRIVATE_THREAD_UCON,
|
||||
}[channel.type] || TEXT_CHANNEL_ICON;
|
||||
|
||||
const channelType =
|
||||
{
|
||||
[ChannelTypeStrings.TEXT]: "Text channel",
|
||||
[ChannelTypeStrings.VOICE]: "Voice channel",
|
||||
[ChannelTypeStrings.CATEGORY]: "Category",
|
||||
[ChannelTypeStrings.NEWS]: "Announcement channel",
|
||||
[ChannelTypeStrings.STORE]: "Store channel",
|
||||
[ChannelTypeStrings.STAGE]: "Stage channel",
|
||||
[ChannelTypeStrings.PUBLIC_THREAD]: "Public Thread channel",
|
||||
[ChannelTypeStrings.PRIVATE_THREAD]: "Private Thread channel",
|
||||
[ChannelTypeStrings.NEWS_THREAD]: "News Thread channel",
|
||||
[ChannelType.GuildText]: "Text channel",
|
||||
[ChannelType.GuildVoice]: "Voice channel",
|
||||
[ChannelType.GuildCategory]: "Category channel",
|
||||
[ChannelType.GuildAnnouncement]: "Announcement channel",
|
||||
[ChannelType.GuildStageVoice]: "Stage channel",
|
||||
[ChannelType.PublicThread]: "Public Thread channel",
|
||||
[ChannelType.PrivateThread]: "Private Thread channel",
|
||||
[ChannelType.AnnouncementThread]: "News Thread channel",
|
||||
[ChannelType.GuildDirectory]: "Hub channel",
|
||||
[ChannelType.GuildForum]: "Forum channel",
|
||||
}[channel.type] || "Channel";
|
||||
|
||||
embed.author = {
|
||||
|
@ -63,9 +63,10 @@ export async function getChannelInfoEmbed(
|
|||
|
||||
let channelName = `#${channel.name}`;
|
||||
if (
|
||||
channel.type === ChannelTypeStrings.VOICE ||
|
||||
channel.type === ChannelTypeStrings.CATEGORY ||
|
||||
channel.type === ChannelTypeStrings.STAGE
|
||||
channel.type === ChannelType.GuildVoice ||
|
||||
channel.type === ChannelType.GuildCategory ||
|
||||
channel.type === ChannelType.GuildStageVoice ||
|
||||
channel.type === ChannelType.GuildDirectory
|
||||
) {
|
||||
channelName = channel.name;
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ export async function getChannelInfoEmbed(
|
|||
round: true,
|
||||
});
|
||||
|
||||
const showMention = channel.type !== ChannelTypeStrings.CATEGORY;
|
||||
const showMention = channel.type !== ChannelType.GuildCategory;
|
||||
|
||||
embed.fields.push({
|
||||
name: preEmbedPadding + "Channel information",
|
||||
|
@ -94,11 +95,11 @@ export async function getChannelInfoEmbed(
|
|||
`),
|
||||
});
|
||||
|
||||
if (channel.type === ChannelTypeStrings.VOICE || channel.type === ChannelTypeStrings.STAGE) {
|
||||
if (channel.type === ChannelType.GuildVoice || channel.type === ChannelType.GuildStageVoice) {
|
||||
const voiceMembers = Array.from((channel as VoiceChannel | StageChannel).members.values());
|
||||
const muted = voiceMembers.filter((vm) => vm.voice.mute || vm.voice.selfMute);
|
||||
const deafened = voiceMembers.filter((vm) => vm.voice.deaf || vm.voice.selfDeaf);
|
||||
const voiceOrStage = channel.type === ChannelTypeStrings.VOICE ? "Voice" : "Stage";
|
||||
const voiceOrStage = channel.type === ChannelType.GuildVoice ? "Voice" : "Stage";
|
||||
|
||||
embed.fields.push({
|
||||
name: preEmbedPadding + `${voiceOrStage} information`,
|
||||
|
@ -110,13 +111,13 @@ export async function getChannelInfoEmbed(
|
|||
});
|
||||
}
|
||||
|
||||
if (channel.type === ChannelTypeStrings.CATEGORY) {
|
||||
if (channel.type === ChannelType.GuildCategory) {
|
||||
const textChannels = pluginData.guild.channels.cache.filter(
|
||||
(ch) => ch.parentId === channel.id && ch.type !== ChannelTypeStrings.VOICE,
|
||||
(ch) => ch.parentId === channel.id && ch.type !== ChannelType.GuildVoice,
|
||||
);
|
||||
const voiceChannels = pluginData.guild.channels.cache.filter(
|
||||
(ch) =>
|
||||
ch.parentId === channel.id && (ch.type === ChannelTypeStrings.VOICE || ch.type === ChannelTypeStrings.STAGE),
|
||||
ch.parentId === channel.id && (ch.type === ChannelType.GuildVoice || ch.type === ChannelType.GuildStageVoice),
|
||||
);
|
||||
|
||||
embed.fields.push({
|
||||
|
@ -128,7 +129,7 @@ export async function getChannelInfoEmbed(
|
|||
});
|
||||
}
|
||||
|
||||
if (channel.type === ChannelTypeStrings.PRIVATE_THREAD || channel.type === ChannelTypeStrings.PUBLIC_THREAD) {
|
||||
if (channel.type === ChannelType.PrivateThread || channel.type === ChannelType.PublicThread) {
|
||||
const thread = channel as ThreadChannel;
|
||||
const parentChannelName = thread.parent?.name ?? `<#${thread.parentId}>`;
|
||||
const memberCount = thread.memberCount ?? thread.members.cache.size;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { MessageEmbedOptions } from "discord.js";
|
||||
import { ChannelType, EmbedData } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import {
|
||||
EmbedWith,
|
||||
formatNumber,
|
||||
|
@ -20,7 +19,7 @@ import { UtilityPluginType } from "../types";
|
|||
export async function getInviteInfoEmbed(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
inviteCode: string,
|
||||
): Promise<MessageEmbedOptions | null> {
|
||||
): Promise<EmbedData | null> {
|
||||
let invite = await resolveInvite(pluginData.client, inviteCode, true);
|
||||
if (!invite) {
|
||||
return null;
|
||||
|
@ -67,7 +66,7 @@ export async function getInviteInfoEmbed(
|
|||
});
|
||||
if (invite.channel) {
|
||||
const channelName =
|
||||
invite.channel.type === ChannelTypeStrings.VOICE ? `🔉 ${invite.channel.name}` : `#${invite.channel.name}`;
|
||||
invite.channel.type === ChannelType.GuildVoice ? `🔉 ${invite.channel.name}` : `#${invite.channel.name}`;
|
||||
|
||||
const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel.id);
|
||||
const channelCreatedAt = moment.utc(channelCreatedAtTimestamp, "x");
|
||||
|
@ -82,7 +81,7 @@ export async function getInviteInfoEmbed(
|
|||
Created: **${channelAge} ago**
|
||||
`);
|
||||
|
||||
if (invite.channel.type !== ChannelTypeStrings.VOICE) {
|
||||
if (invite.channel.type !== ChannelType.GuildVoice) {
|
||||
channelInfo += `\nMention: <#${invite.channel.id}>`;
|
||||
}
|
||||
|
||||
|
@ -114,13 +113,13 @@ export async function getInviteInfoEmbed(
|
|||
|
||||
invite = invite as GroupDMInvite;
|
||||
embed.author = {
|
||||
name: invite.channel.name ? `Group DM invite: ${invite.channel.name}` : `Group DM invite`,
|
||||
name: invite.channel!.name ? `Group DM invite: ${invite.channel!.name}` : `Group DM invite`,
|
||||
url: `https://discord.gg/${invite.code}`,
|
||||
}; // FIXME pending invite re-think
|
||||
|
||||
/*if (invite.channel.icon) {
|
||||
embed.author.icon_url = `https://cdn.discordapp.com/channel-icons/${invite.channel.id}/${invite.channel.icon}.png?size=256`;
|
||||
}*/ const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel.id);
|
||||
}*/ const channelCreatedAtTimestamp = snowflakeToTimestamp(invite.channel!.id);
|
||||
const channelCreatedAt = moment.utc(channelCreatedAtTimestamp, "x");
|
||||
const channelAge = humanizeDuration(Date.now() - channelCreatedAtTimestamp, {
|
||||
largest: 2,
|
||||
|
@ -130,8 +129,8 @@ export async function getInviteInfoEmbed(
|
|||
embed.fields.push({
|
||||
name: preEmbedPadding + "Group DM information",
|
||||
value: trimLines(`
|
||||
Name: ${invite.channel.name ? `**${invite.channel.name}**` : `_Unknown_`}
|
||||
ID: \`${invite.channel.id}\`
|
||||
Name: ${invite.channel!.name ? `**${invite.channel!.name}**` : `_Unknown_`}
|
||||
ID: \`${invite.channel!.id}\`
|
||||
Created: **${channelAge} ago**
|
||||
Members: **${formatNumber((invite as any).memberCount)}**
|
||||
`),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { MessageEmbedOptions, PremiumTier, Snowflake } from "discord.js";
|
||||
import { ChannelType, MessageEmbedOptions, PremiumTier, Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { ChannelTypeStrings } from "../../../types";
|
||||
|
||||
import {
|
||||
EmbedWith,
|
||||
formatNumber,
|
||||
|
@ -90,10 +90,10 @@ export async function getServerInfoEmbed(
|
|||
});
|
||||
|
||||
// IMAGE LINKS
|
||||
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL({ dynamic: true, format: "png", size: 2048 })})`;
|
||||
const bannerUrl = restGuild?.banner ? `[Link](${restGuild.bannerURL({ format: "png", size: 2048 })})` : "None";
|
||||
const iconUrl = `[Link](${(restGuild || guildPreview)!.iconURL({ size: 2048 })})`;
|
||||
const bannerUrl = restGuild?.banner ? `[Link](${restGuild.bannerURL({ size: 2048 })})` : "None";
|
||||
const splashUrl = (restGuild || guildPreview)!.splash
|
||||
? `[Link](${(restGuild || guildPreview)!.splashURL({ format: "png", size: 2048 })})`
|
||||
? `[Link](${(restGuild || guildPreview)!.splashURL({ size: 2048 })})`
|
||||
: "None";
|
||||
|
||||
embed.fields.push(
|
||||
|
@ -162,9 +162,19 @@ export async function getServerInfoEmbed(
|
|||
// CHANNEL COUNTS
|
||||
if (thisServer) {
|
||||
const totalChannels = thisServer.channels.cache.size;
|
||||
const categories = thisServer.channels.cache.filter((channel) => channel.type === ChannelTypeStrings.CATEGORY);
|
||||
const textChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelTypeStrings.TEXT);
|
||||
const voiceChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelTypeStrings.VOICE);
|
||||
const categories = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildCategory);
|
||||
const textChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildText);
|
||||
const voiceChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildVoice);
|
||||
const threadChannels = thisServer.channels.cache.filter(
|
||||
(channel) =>
|
||||
channel.type === ChannelType.PublicThread ||
|
||||
channel.type === ChannelType.PrivateThread ||
|
||||
channel.type === ChannelType.AnnouncementThread,
|
||||
);
|
||||
const announcementChannels = thisServer.channels.cache.filter(
|
||||
(channel) => channel.type === ChannelType.GuildAnnouncement,
|
||||
);
|
||||
const stageChannels = thisServer.channels.cache.filter((channel) => channel.type === ChannelType.GuildStageVoice);
|
||||
|
||||
embed.fields.push({
|
||||
name: preEmbedPadding + "Channels",
|
||||
|
@ -172,8 +182,10 @@ export async function getServerInfoEmbed(
|
|||
value: trimLines(`
|
||||
Total: **${totalChannels}** / 500
|
||||
Categories: **${categories.size}**
|
||||
Text: **${textChannels.size}**
|
||||
Text: **${textChannels.size}** (**${threadChannels.size} threads**)
|
||||
Announcement: **${announcementChannels.size}**
|
||||
Voice: **${voiceChannels.size}**
|
||||
Stage: **${stageChannels.size}**
|
||||
`),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -65,21 +65,6 @@ export interface CommandInfo {
|
|||
};
|
||||
}
|
||||
|
||||
export enum ChannelTypeStrings {
|
||||
TEXT = "GUILD_TEXT",
|
||||
DM = "DM",
|
||||
VOICE = "GUILD_VOICE",
|
||||
GROUP = "GROUP_DM",
|
||||
CATEGORY = "GUILD_CATEGORY",
|
||||
NEWS = "GUILD_NEWS",
|
||||
STORE = "GUILD_STORE",
|
||||
NEWS_THREAD = "GUILD_NEWS_THREAD",
|
||||
PUBLIC_THREAD = "GUILD_PUBLIC_THREAD",
|
||||
PRIVATE_THREAD = "GUILD_PRIVATE_THREAD",
|
||||
STAGE = "GUILD_STAGE_VOICE",
|
||||
UNKNOWN = "UNKNOWN",
|
||||
}
|
||||
|
||||
export enum MessageTypeStrings {
|
||||
"DEFAULT",
|
||||
"RECIPIENT_ADD",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
ChannelType,
|
||||
Client,
|
||||
Constants,
|
||||
DiscordAPIError,
|
||||
|
@ -42,7 +43,6 @@ import tmp from "tmp";
|
|||
import { URL } from "url";
|
||||
import { ISavedMessageAttachmentData, SavedMessage } from "./data/entities/SavedMessage";
|
||||
import { SimpleCache } from "./SimpleCache";
|
||||
import { ChannelTypeStrings } from "./types";
|
||||
import { sendDM } from "./utils/sendDM";
|
||||
import { waitForButtonConfirm } from "./utils/waitForInteraction";
|
||||
import { decodeAndValidateStrict, StrictValidationError } from "./validatorUtils";
|
||||
|
@ -1444,7 +1444,7 @@ export function verboseUserName(user: User | UnknownUser): string {
|
|||
|
||||
export function verboseChannelMention(channel: GuildChannel | ThreadChannel): string {
|
||||
const plainTextName =
|
||||
channel.type === ChannelTypeStrings.VOICE || channel.type === ChannelTypeStrings.STAGE
|
||||
channel.type === ChannelType.GuildVoice || channel.type === ChannelType.GuildStageVoice
|
||||
? channel.name
|
||||
: `#${channel.name}`;
|
||||
return `<#${channel.id}> (**${plainTextName}**, \`${channel.id}\`)`;
|
||||
|
@ -1578,7 +1578,7 @@ export function isGuildInvite(invite: Invite): invite is GuildInvite {
|
|||
}
|
||||
|
||||
export function isGroupDMInvite(invite: Invite): invite is GroupDMInvite {
|
||||
return invite.guild == null && invite.channel?.type === ChannelTypeStrings.GROUP;
|
||||
return invite.guild == null && invite.channel?.type === ChannelType.GroupDM;
|
||||
}
|
||||
|
||||
export function inviteHasCounts(invite: Invite): invite is Invite {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Channel, DMChannel } from "discord.js";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { Channel, ChannelType, DMChannel } from "discord.js";
|
||||
|
||||
export function isDmChannel(channel: Channel): channel is DMChannel {
|
||||
return channel.type === ChannelTypeStrings.DM || channel.type === ChannelTypeStrings.GROUP;
|
||||
return channel.isDMBased();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Channel, GuildChannel } from "discord.js";
|
||||
import { Channel, GuildBasedChannel, GuildChannel } from "discord.js";
|
||||
|
||||
export function isGuildChannel(channel: Channel): channel is GuildChannel {
|
||||
return channel.type.startsWith("GUILD_");
|
||||
export function isGuildChannel(channel: Channel): channel is GuildBasedChannel {
|
||||
return channel.type.toString().startsWith("GUILD_");
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
import { AnyThreadChannel, Channel, ChannelType } from "discord.js";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
|
||||
export function isThreadChannel(channel: Channel): channel is AnyThreadChannel {
|
||||
return (
|
||||
channel.type === ChannelType.PublicThread ||
|
||||
channel.type === ChannelType.PrivateThread ||
|
||||
channel.type === ChannelType.AnnouncementThread
|
||||
);
|
||||
return channel.isThread();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import { ChannelType } from "discord-api-types/v9";
|
||||
import { CategoryChannel, Channel } from "discord.js";
|
||||
import { ChannelTypes } from "discord.js/typings/enums";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { isDmChannel } from "./isDmChannel";
|
||||
import { isGuildChannel } from "./isGuildChannel";
|
||||
import { isThreadChannel } from "./isThreadChannel";
|
||||
|
|
Loading…
Add table
Reference in a new issue