mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Update to new Knub 30 beta. Code clean-up.
This commit is contained in:
parent
5d579446c5
commit
2f470dc37a
299 changed files with 1075 additions and 1004 deletions
|
@ -1,4 +1,4 @@
|
|||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { ConfigSchema, TimeAndDatePluginType } from "./types";
|
||||
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones";
|
||||
import { PluginOptions } from "knub";
|
||||
|
@ -32,7 +32,7 @@ const defaultOptions: PluginOptions<TimeAndDatePluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const TimeAndDatePlugin = zeppelinPlugin<TimeAndDatePluginType>()("time_and_date", {
|
||||
export const TimeAndDatePlugin = zeppelinGuildPlugin<TimeAndDatePluginType>()("time_and_date", {
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Time and date",
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { defaultDateFormats } from "../defaultDateFormats";
|
||||
import { TimeAndDatePluginType } from "../types";
|
||||
|
||||
export function getDateFormat(pluginData: PluginData<any>, formatName: keyof typeof defaultDateFormats) {
|
||||
export function getDateFormat(
|
||||
pluginData: GuildPluginData<TimeAndDatePluginType>,
|
||||
formatName: keyof typeof defaultDateFormats,
|
||||
) {
|
||||
return pluginData.config.get().date_formats?.[formatName] || defaultDateFormats[formatName];
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ZeppelinGuildConfig } from "../../../types";
|
||||
import { TimeAndDatePluginType } from "../types";
|
||||
|
||||
export function getGuildTz(pluginData: PluginData<TimeAndDatePluginType>) {
|
||||
export function getGuildTz(pluginData: GuildPluginData<TimeAndDatePluginType>) {
|
||||
return pluginData.config.get().timezone;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { TimeAndDatePluginType } from "../types";
|
||||
import { getGuildTz } from "./getGuildTz";
|
||||
|
||||
export async function getMemberTz(pluginData: PluginData<TimeAndDatePluginType>, memberId: string) {
|
||||
export async function getMemberTz(pluginData: GuildPluginData<TimeAndDatePluginType>, memberId: string) {
|
||||
const memberTz = await pluginData.state.memberTimezones.get(memberId);
|
||||
return memberTz?.timezone || getGuildTz(pluginData);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { TimeAndDatePluginType } from "../types";
|
||||
import moment from "moment-timezone";
|
||||
import { getGuildTz } from "./getGuildTz";
|
||||
|
||||
export function inGuildTz(pluginData: PluginData<TimeAndDatePluginType>, input?: moment.Moment | number) {
|
||||
export function inGuildTz(pluginData: GuildPluginData<TimeAndDatePluginType>, input?: moment.Moment | number) {
|
||||
let momentObj: moment.Moment;
|
||||
if (typeof input === "number") {
|
||||
momentObj = moment.utc(input, "x");
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { TimeAndDatePluginType } from "../types";
|
||||
import moment from "moment-timezone";
|
||||
import { getGuildTz } from "./getGuildTz";
|
||||
import { getMemberTz } from "./getMemberTz";
|
||||
|
||||
export async function inMemberTz(
|
||||
pluginData: PluginData<TimeAndDatePluginType>,
|
||||
pluginData: GuildPluginData<TimeAndDatePluginType>,
|
||||
memberId: string,
|
||||
input?: moment.Moment | number,
|
||||
) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { tNullable, tPartialDictionary } from "../../utils";
|
||||
import { BasePluginType, command } from "knub";
|
||||
import { BasePluginType, guildCommand } from "knub";
|
||||
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones";
|
||||
import { tValidTimezone } from "../../utils/tValidTimezone";
|
||||
import { defaultDateFormats } from "./defaultDateFormats";
|
||||
|
@ -19,4 +19,4 @@ export interface TimeAndDatePluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const timeAndDateCmd = command<TimeAndDatePluginType>();
|
||||
export const timeAndDateCmd = guildCommand<TimeAndDatePluginType>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue