Add owner debug command for channel information

This commit is contained in:
Dragory 2021-09-11 20:11:14 +03:00
parent 3e7313d40f
commit 3bc0015dbe
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 35 additions and 0 deletions

View file

@ -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<BotControlPluginType>()({
EligibleCmd,
PerformanceCmd,
AddServerFromInviteCmd,
ChannelToServerCmd,
],
async afterLoad(pluginData) {

View file

@ -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}`);
},
});