refactor: convert /backend to ESM

This commit is contained in:
Dragory 2024-04-09 20:57:18 +03:00
parent 31d74c05aa
commit 5772e27cda
No known key found for this signature in database
766 changed files with 3473 additions and 3500 deletions

View file

@ -1,14 +1,14 @@
import { PluginOptions, guildPlugin } from "knub";
import { onGuildEvent } from "../../data/GuildEvents";
import { GuildVCAlerts } from "../../data/GuildVCAlerts";
import { FollowCmd } from "./commands/FollowCmd";
import { DeleteFollowCmd, ListFollowCmd } from "./commands/ListFollowCmd";
import { WhereCmd } from "./commands/WhereCmd";
import { GuildBanRemoveAlertsEvt } from "./events/BanRemoveAlertsEvt";
import { VoiceStateUpdateAlertEvt } from "./events/SendAlertsEvts";
import { LocateUserPluginType, zLocateUserConfig } from "./types";
import { clearExpiredAlert } from "./utils/clearExpiredAlert";
import { fillActiveAlertsList } from "./utils/fillAlertsList";
import { onGuildEvent } from "../../data/GuildEvents.js";
import { GuildVCAlerts } from "../../data/GuildVCAlerts.js";
import { FollowCmd } from "./commands/FollowCmd.js";
import { DeleteFollowCmd, ListFollowCmd } from "./commands/ListFollowCmd.js";
import { WhereCmd } from "./commands/WhereCmd.js";
import { GuildBanRemoveAlertsEvt } from "./events/BanRemoveAlertsEvt.js";
import { VoiceStateUpdateAlertEvt } from "./events/SendAlertsEvts.js";
import { LocateUserPluginType, zLocateUserConfig } from "./types.js";
import { clearExpiredAlert } from "./utils/clearExpiredAlert.js";
import { fillActiveAlertsList } from "./utils/fillAlertsList.js";
const defaultOptions: PluginOptions<LocateUserPluginType> = {
config: {

View file

@ -1,10 +1,10 @@
import humanizeDuration from "humanize-duration";
import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { registerExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { MINUTES, SECONDS } from "../../../utils";
import { locateUserCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { registerExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { MINUTES, SECONDS } from "../../../utils.js";
import { locateUserCmd } from "../types.js";
export const FollowCmd = locateUserCmd({
trigger: ["follow", "f"],

View file

@ -1,8 +1,8 @@
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { clearExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { createChunkedMessage, sorter } from "../../../utils";
import { locateUserCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { clearExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { createChunkedMessage, sorter } from "../../../utils.js";
import { locateUserCmd } from "../types.js";
export const ListFollowCmd = locateUserCmd({
trigger: ["follows", "fs"],

View file

@ -1,6 +1,6 @@
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { locateUserCmd } from "../types";
import { sendWhere } from "../utils/sendWhere";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { locateUserCmd } from "../types.js";
import { sendWhere } from "../utils/sendWhere.js";
export const WhereCmd = locateUserCmd({
trigger: ["where", "w"],

View file

@ -1,5 +1,5 @@
import { clearExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop";
import { locateUserEvt } from "../types";
import { clearExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop.js";
import { locateUserEvt } from "../types.js";
export const GuildBanRemoveAlertsEvt = locateUserEvt({
event: "guildBanAdd",

View file

@ -1,6 +1,6 @@
import { Snowflake } from "discord.js";
import { locateUserEvt } from "../types";
import { sendAlerts } from "../utils/sendAlerts";
import { locateUserEvt } from "../types.js";
import { sendAlerts } from "../utils/sendAlerts.js";
export const VoiceStateUpdateAlertEvt = locateUserEvt({
event: "voiceStateUpdate",

View file

@ -1,6 +1,6 @@
import { ZeppelinPluginInfo } from "../../types";
import { trimPluginDescription } from "../../utils";
import { zLocateUserConfig } from "./types";
import { ZeppelinPluginInfo } from "../../types.js";
import { trimPluginDescription } from "../../utils.js";
import { zLocateUserConfig } from "./types.js";
export const locateUserPluginInfo: ZeppelinPluginInfo = {
prettyName: "Locate user",

View file

@ -1,6 +1,6 @@
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
import z from "zod";
import { GuildVCAlerts } from "../../data/GuildVCAlerts";
import { GuildVCAlerts } from "../../data/GuildVCAlerts.js";
export const zLocateUserConfig = z.strictObject({
can_where: z.boolean(),

View file

@ -1,7 +1,7 @@
import { GuildPluginData } from "knub";
import { VCAlert } from "../../../data/entities/VCAlert";
import { LocateUserPluginType } from "../types";
import { removeUserIdFromActiveAlerts } from "./removeUserIdFromActiveAlerts";
import { VCAlert } from "../../../data/entities/VCAlert.js";
import { LocateUserPluginType } from "../types.js";
import { removeUserIdFromActiveAlerts } from "./removeUserIdFromActiveAlerts.js";
export async function clearExpiredAlert(pluginData: GuildPluginData<LocateUserPluginType>, alert: VCAlert) {
await pluginData.state.alerts.delete(alert.id);

View file

@ -1,5 +1,5 @@
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { LocateUserPluginType } from "../types.js";
export async function fillActiveAlertsList(pluginData: GuildPluginData<LocateUserPluginType>) {
const allAlerts = await pluginData.state.alerts.getAllGuildAlerts();

View file

@ -1,7 +1,7 @@
import { GuildMember, GuildTextBasedChannel, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { sendErrorMessage } from "../../../pluginUtils";
import { LocateUserPluginType } from "../types";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { LocateUserPluginType } from "../types.js";
export async function moveMember(
pluginData: GuildPluginData<LocateUserPluginType>,

View file

@ -1,5 +1,5 @@
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { LocateUserPluginType } from "../types.js";
export async function removeUserIdFromActiveAlerts(pluginData: GuildPluginData<LocateUserPluginType>, userId: string) {
const index = pluginData.state.usersWithAlerts.indexOf(userId);

View file

@ -1,9 +1,9 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { resolveMember } from "../../../utils";
import { LocateUserPluginType } from "../types";
import { moveMember } from "./moveMember";
import { sendWhere } from "./sendWhere";
import { resolveMember } from "../../../utils.js";
import { LocateUserPluginType } from "../types.js";
import { moveMember } from "./moveMember.js";
import { sendWhere } from "./sendWhere.js";
export async function sendAlerts(pluginData: GuildPluginData<LocateUserPluginType>, userId: string) {
const triggeredAlerts = await pluginData.state.alerts.getAlertsByUserId(userId);

View file

@ -1,9 +1,9 @@
import { GuildMember, GuildTextBasedChannel, Invite, VoiceChannel } from "discord.js";
import { GuildPluginData } from "knub";
import { getInviteLink } from "knub/helpers";
import { sendErrorMessage } from "../../../pluginUtils";
import { LocateUserPluginType } from "../types";
import { createOrReuseInvite } from "./createOrReuseInvite";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { LocateUserPluginType } from "../types.js";
import { createOrReuseInvite } from "./createOrReuseInvite.js";
export async function sendWhere(
pluginData: GuildPluginData<LocateUserPluginType>,