diff --git a/backend/src/plugins/BotControl/BotControlPlugin.ts b/backend/src/plugins/BotControl/BotControlPlugin.ts index 314e7420..3e13c624 100644 --- a/backend/src/plugins/BotControl/BotControlPlugin.ts +++ b/backend/src/plugins/BotControl/BotControlPlugin.ts @@ -20,6 +20,7 @@ import { ServersCmd } from "./commands/ServersCmd"; import { BotControlPluginType, ConfigSchema } from "./types"; import { PerformanceCmd } from "./commands/PerformanceCmd"; import { AddServerFromInviteCmd } from "./commands/AddServerFromInviteCmd"; +import { ChannelToServerCmd } from "./commands/ChannelToServerCmd"; const defaultOptions = { config: { @@ -52,6 +53,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin()({ EligibleCmd, PerformanceCmd, AddServerFromInviteCmd, + ChannelToServerCmd, ], async afterLoad(pluginData) { diff --git a/backend/src/plugins/BotControl/commands/ChannelToServerCmd.ts b/backend/src/plugins/BotControl/commands/ChannelToServerCmd.ts new file mode 100644 index 00000000..5e9dcbb8 --- /dev/null +++ b/backend/src/plugins/BotControl/commands/ChannelToServerCmd.ts @@ -0,0 +1,33 @@ +import { Guild, GuildChannel, TextChannel } from "discord.js"; +import { commandTypeHelpers as ct } from "../../../commandTypes"; +import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; +import { GuildInvite, isGuildInvite, resolveInvite, verboseUserMention } from "../../../utils"; +import { botControlCmd } from "../types"; +import { isEligible } from "../functions/isEligible"; + +export const ChannelToServerCmd = botControlCmd({ + trigger: ["channel_to_server", "channel2server"], + permission: null, + config: { + preFilters: [isOwnerPreFilter], + }, + + signature: { + channelId: ct.string(), + }, + + async run({ pluginData, message: msg, args }) { + const channel = pluginData.client.channels.cache.get(args.channelId); + if (!channel) { + sendErrorMessage(pluginData, msg.channel as TextChannel, "Channel not found in cache!"); + return; + } + + const channelName = channel.isVoice() ? channel.name : `#${(channel as TextChannel).name}`; + + const guild: Guild | null = (channel as GuildChannel).guild ?? null; + const guildInfo = guild ? `${guild.name} (\`${guild.id}\`)` : "Not a server"; + + msg.channel.send(`**Channel:** ${channelName} (\`${channel.type}\`) (<#${channel.id}>)\n**Server:** ${guildInfo}`); + }, +});