zappyzep/backend/src/plugins/ModActions/functions/getDefaultContactMethods.ts

28 lines
759 B
TypeScript
Raw Normal View History

import { GuildPluginData } from "knub";
2020-07-23 00:37:33 +03:00
import { ModActionsPluginType } from "../types";
import { UserNotificationMethod } from "../../../utils";
export function getDefaultContactMethods(
pluginData: GuildPluginData<ModActionsPluginType>,
2020-07-23 00:37:33 +03:00
type: "warn" | "kick" | "ban",
): UserNotificationMethod[] {
const methods: UserNotificationMethod[] = [];
const config = pluginData.config.get();
if (config[`dm_on_${type}`]) {
methods.push({ type: "dm" });
}
if (config[`message_on_${type}`] && config.message_channel) {
const channel = pluginData.guild.channels.cache.get(config.message_channel);
2020-07-23 00:37:33 +03:00
if (channel instanceof TextChannel) {
methods.push({
type: "channel",
channel,
});
}
}
return methods;
}