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,16 +1,16 @@
import { PluginOptions, guildPlugin } from "knub";
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones";
import { makePublicFn } from "../../pluginUtils";
import { ResetTimezoneCmd } from "./commands/ResetTimezoneCmd";
import { SetTimezoneCmd } from "./commands/SetTimezoneCmd";
import { ViewTimezoneCmd } from "./commands/ViewTimezoneCmd";
import { defaultDateFormats } from "./defaultDateFormats";
import { getDateFormat } from "./functions/getDateFormat";
import { getGuildTz } from "./functions/getGuildTz";
import { getMemberTz } from "./functions/getMemberTz";
import { inGuildTz } from "./functions/inGuildTz";
import { inMemberTz } from "./functions/inMemberTz";
import { TimeAndDatePluginType, zTimeAndDateConfig } from "./types";
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones.js";
import { makePublicFn } from "../../pluginUtils.js";
import { ResetTimezoneCmd } from "./commands/ResetTimezoneCmd.js";
import { SetTimezoneCmd } from "./commands/SetTimezoneCmd.js";
import { ViewTimezoneCmd } from "./commands/ViewTimezoneCmd.js";
import { defaultDateFormats } from "./defaultDateFormats.js";
import { getDateFormat } from "./functions/getDateFormat.js";
import { getGuildTz } from "./functions/getGuildTz.js";
import { getMemberTz } from "./functions/getMemberTz.js";
import { inGuildTz } from "./functions/inGuildTz.js";
import { inMemberTz } from "./functions/inMemberTz.js";
import { TimeAndDatePluginType, zTimeAndDateConfig } from "./types.js";
const defaultOptions: PluginOptions<TimeAndDatePluginType> = {
config: {

View file

@ -1,6 +1,6 @@
import { sendSuccessMessage } from "../../../pluginUtils";
import { getGuildTz } from "../functions/getGuildTz";
import { timeAndDateCmd } from "../types";
import { sendSuccessMessage } from "../../../pluginUtils.js";
import { getGuildTz } from "../functions/getGuildTz.js";
import { timeAndDateCmd } from "../types.js";
export const ResetTimezoneCmd = timeAndDateCmd({
trigger: "timezone reset",

View file

@ -1,9 +1,9 @@
import { escapeInlineCode } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { trimLines } from "../../../utils";
import { parseFuzzyTimezone } from "../../../utils/parseFuzzyTimezone";
import { timeAndDateCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { trimLines } from "../../../utils.js";
import { parseFuzzyTimezone } from "../../../utils/parseFuzzyTimezone.js";
import { timeAndDateCmd } from "../types.js";
export const SetTimezoneCmd = timeAndDateCmd({
trigger: "timezone",

View file

@ -1,5 +1,5 @@
import { getGuildTz } from "../functions/getGuildTz";
import { timeAndDateCmd } from "../types";
import { getGuildTz } from "../functions/getGuildTz.js";
import { timeAndDateCmd } from "../types.js";
export const ViewTimezoneCmd = timeAndDateCmd({
trigger: "timezone",

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { defaultDateFormats } from "../defaultDateFormats";
import { TimeAndDatePluginType } from "../types";
import { defaultDateFormats } from "../defaultDateFormats.js";
import { TimeAndDatePluginType } from "../types.js";
export function getDateFormat(
pluginData: GuildPluginData<TimeAndDatePluginType>,

View file

@ -1,5 +1,5 @@
import { GuildPluginData } from "knub";
import { TimeAndDatePluginType } from "../types";
import { TimeAndDatePluginType } from "../types.js";
export function getGuildTz(pluginData: GuildPluginData<TimeAndDatePluginType>) {
return pluginData.config.get().timezone;

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { TimeAndDatePluginType } from "../types";
import { getGuildTz } from "./getGuildTz";
import { TimeAndDatePluginType } from "../types.js";
import { getGuildTz } from "./getGuildTz.js";
export async function getMemberTz(pluginData: GuildPluginData<TimeAndDatePluginType>, memberId: string) {
const memberTz = await pluginData.state.memberTimezones.get(memberId);

View file

@ -1,7 +1,7 @@
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { TimeAndDatePluginType } from "../types";
import { getGuildTz } from "./getGuildTz";
import { TimeAndDatePluginType } from "../types.js";
import { getGuildTz } from "./getGuildTz.js";
export function inGuildTz(pluginData: GuildPluginData<TimeAndDatePluginType>, input?: moment.Moment | number) {
let momentObj: moment.Moment;

View file

@ -1,7 +1,7 @@
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { TimeAndDatePluginType } from "../types";
import { getMemberTz } from "./getMemberTz";
import { TimeAndDatePluginType } from "../types.js";
import { getMemberTz } from "./getMemberTz.js";
export async function inMemberTz(
pluginData: GuildPluginData<TimeAndDatePluginType>,

View file

@ -1,6 +1,6 @@
import { ZeppelinPluginInfo } from "../../types";
import { trimPluginDescription } from "../../utils";
import { zTimeAndDateConfig } from "./types";
import { ZeppelinPluginInfo } from "../../types.js";
import { trimPluginDescription } from "../../utils.js";
import { zTimeAndDateConfig } from "./types.js";
export const timeAndDatePluginInfo: ZeppelinPluginInfo = {
showInDocs: true,

View file

@ -1,10 +1,10 @@
import { BasePluginType, guildPluginMessageCommand } from "knub";
import { U } from "ts-toolbelt";
import z from "zod";
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones";
import { keys } from "../../utils";
import { zValidTimezone } from "../../utils/zValidTimezone";
import { defaultDateFormats } from "./defaultDateFormats";
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones.js";
import { keys } from "../../utils.js";
import { zValidTimezone } from "../../utils/zValidTimezone.js";
import { defaultDateFormats } from "./defaultDateFormats.js";
const zDateFormatKeys = z.enum(keys(defaultDateFormats) as U.ListOf<keyof typeof defaultDateFormats>);