3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 04:45:02 +00:00

Turn on strict TS compilation. Fix up and tweak types accordingly.

This commit is contained in:
Dragory 2020-11-09 20:03:57 +02:00
parent 690955a399
commit 629002b8d9
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
172 changed files with 720 additions and 534 deletions

View file

@ -31,7 +31,7 @@ export const EditEmbedCmd = postCmd({
const content = args.content || args.maincontent;
let color = null;
let color: number | null = null;
if (args.color) {
const colorRgb = parseColor(args.color);
if (colorRgb) {
@ -42,8 +42,7 @@ export const EditEmbedCmd = postCmd({
}
}
const embed: Embed = savedMessage.data.embeds[0] as Embed;
embed.type = "rich";
const embed: Embed = savedMessage.data.embeds![0] as Embed;
if (args.title) embed.title = args.title;
if (content) embed.description = formatContent(content);
if (color) embed.color = color;

View file

@ -35,7 +35,7 @@ export const PostEmbedCmd = postCmd({
return;
}
let color = null;
let color: number | null = null;
if (args.color) {
const colorRgb = parseColor(args.color);
if (colorRgb) {

View file

@ -39,7 +39,7 @@ export const ScheduledPostsListCmd = postCmd({
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
const prettyPostAt = timeAndDate
.inGuildTz(moment.utc(p.post_at, DBDateFormat))
.inGuildTz(moment.utc(p.post_at!, DBDateFormat))
.format(timeAndDate.getDateFormat("pretty_datetime"));
const parts = [`\`#${i++}\` \`[${prettyPostAt}]\` ${previewText}${isTruncated ? "..." : ""}`];
if (p.attachments.length) parts.push("*(with attachment)*");

View file

@ -19,13 +19,13 @@ export async function actualPostCmd(
msg: Message,
targetChannel: Channel,
content: StrictMessageContent,
opts?: {
opts: {
"enable-mentions"?: boolean;
schedule?: string;
repeat?: number;
"repeat-until"?: string;
"repeat-times"?: number;
},
} = {},
) {
if (!(targetChannel instanceof TextChannel)) {
msg.channel.createMessage(errorMessage("Channel is not a text channel"));
@ -63,9 +63,9 @@ export async function actualPostCmd(
}
// For repeated posts, make sure repeat-until or repeat-times is specified
let repeatUntil: moment.Moment = null;
let repeatTimes: number = null;
let repeatDetailsStr: string = null;
let repeatUntil: moment.Moment | null = null;
let repeatTimes: number | null = null;
let repeatDetailsStr: string | null = null;
if (opts["repeat-until"]) {
repeatUntil = await parseScheduleTime(pluginData, msg.author.id, opts["repeat-until"]);

View file

@ -8,7 +8,7 @@ export async function parseScheduleTime(
pluginData: GuildPluginData<any>,
memberId: string,
str: string,
): Promise<Moment> {
): Promise<Moment | null> {
const tz = await pluginData.getPlugin(TimeAndDatePlugin).getMemberTz(memberId);
const dt1 = moment.tz(str, "YYYY-MM-DD HH:mm:ss", tz);