3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-13 21:35:02 +00:00
zeppelin/backend/src/plugins/BotControl/commands/ChannelToServerCmd.ts
Dragory 45e3fe2ef0
chore: esm imports
This will make merging this into 'next' much easier.
2024-08-11 21:58:52 +03:00

30 lines
1,016 B
TypeScript

import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { isStaffPreFilter } from "../../../pluginUtils.js";
import { botControlCmd } from "../types.js";
export const ChannelToServerCmd = botControlCmd({
trigger: ["channel_to_server", "channel2server"],
permission: null,
config: {
preFilters: [isStaffPreFilter],
},
signature: {
channelId: ct.string(),
},
async run({ pluginData, message: msg, args }) {
const channel = pluginData.client.channels.cache.get(args.channelId);
if (!channel) {
void msg.channel.send("Channel not found in cache!");
return;
}
const channelName = channel.isVoiceBased() ? channel.name : `#${"name" in channel ? channel.name : channel.id}`;
const guild = "guild" in channel ? channel.guild : null;
const guildInfo = guild ? `${guild.name} (\`${guild.id}\`)` : "Not a server";
msg.channel.send(`**Channel:** ${channelName} (\`${channel.type}\`) (<#${channel.id}>)\n**Server:** ${guildInfo}`);
},
});