mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-08 03:27:20 +00:00
Fixes, refactoring and PR feedback
This commit is contained in:
parent
0be54912c4
commit
893a77d562
202 changed files with 1037 additions and 1069 deletions
|
@ -11,6 +11,7 @@ import { getMemberTz } from "./functions/getMemberTz";
|
|||
import { inGuildTz } from "./functions/inGuildTz";
|
||||
import { inMemberTz } from "./functions/inMemberTz";
|
||||
import { TimeAndDatePluginType, zTimeAndDateConfig } from "./types";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
|
||||
const defaultOptions: PluginOptions<TimeAndDatePluginType> = {
|
||||
config: {
|
||||
|
@ -57,4 +58,8 @@ export const TimeAndDatePlugin = guildPlugin<TimeAndDatePluginType>()({
|
|||
|
||||
state.memberTimezones = GuildMemberTimezones.getGuildInstance(guild.id);
|
||||
},
|
||||
|
||||
beforeStart(pluginData) {
|
||||
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,8 +11,6 @@ export const ResetTimezoneCmd = timeAndDateCmd({
|
|||
async run({ pluginData, message }) {
|
||||
await pluginData.state.memberTimezones.reset(message.author.id);
|
||||
const serverTimezone = getGuildTz(pluginData);
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(message, `Your timezone has been reset to server default, **${serverTimezone}**`);
|
||||
void pluginData.state.common.sendSuccessMessage(message, `Your timezone has been reset to server default, **${serverTimezone}**`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ export const SetTimezoneCmd = timeAndDateCmd({
|
|||
async run({ pluginData, message, args }) {
|
||||
const parsedTz = parseFuzzyTimezone(args.timezone);
|
||||
if (!parsedTz) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(
|
||||
void pluginData.state.common.sendErrorMessage(
|
||||
message,
|
||||
trimLines(`
|
||||
Invalid timezone: \`${escapeInlineCode(args.timezone)}\`
|
||||
|
@ -28,6 +28,6 @@ export const SetTimezoneCmd = timeAndDateCmd({
|
|||
}
|
||||
|
||||
await pluginData.state.memberTimezones.set(message.author.id, parsedTz);
|
||||
pluginData.getPlugin(CommonPlugin).sendSuccessMessage(message, `Your timezone is now set to **${parsedTz}**`);
|
||||
void pluginData.state.common.sendSuccessMessage(message, `Your timezone is now set to **${parsedTz}**`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { BasePluginType, guildPluginMessageCommand } from "knub";
|
||||
import { BasePluginType, guildPluginMessageCommand, pluginUtils } 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 { CommonPlugin } from "../Common/CommonPlugin";
|
||||
|
||||
const zDateFormatKeys = z.enum(keys(defaultDateFormats) as U.ListOf<keyof typeof defaultDateFormats>);
|
||||
|
||||
|
@ -18,6 +19,7 @@ export interface TimeAndDatePluginType extends BasePluginType {
|
|||
config: z.infer<typeof zTimeAndDateConfig>;
|
||||
state: {
|
||||
memberTimezones: GuildMemberTimezones;
|
||||
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue