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

@ -10,6 +10,7 @@ import { DeleteFollowCmd, ListFollowCmd } from "./commands/ListFollowCmd";
import { ChannelJoinAlertsEvt, ChannelLeaveAlertsEvt, ChannelSwitchAlertsEvt } from "./events/SendAlertsEvts";
import { GuildBanRemoveAlertsEvt } from "./events/BanRemoveAlertsEvt";
import { trimPluginDescription } from "../../utils";
import Timeout = NodeJS.Timeout;
const defaultOptions: PluginOptions<LocateUserPluginType> = {
config: {
@ -70,7 +71,7 @@ export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()("loc
},
onUnload(pluginData) {
clearTimeout(pluginData.state.outdatedAlertsTimeout);
clearTimeout(pluginData.state.outdatedAlertsTimeout as Timeout);
pluginData.state.unloaded = true;
},
});

View file

@ -14,7 +14,6 @@ export const WhereCmd = locateUserCmd({
},
async run({ message: msg, args, pluginData }) {
const member = await resolveMember(pluginData.client, pluginData.guild, args.member.id);
sendWhere(pluginData, member, msg.channel, `${msg.member.mention} | `);
sendWhere(pluginData, args.member, msg.channel, `${msg.member.mention} | `);
},
});

View file

@ -13,7 +13,7 @@ export interface LocateUserPluginType extends BasePluginType {
config: TConfigSchema;
state: {
alerts: GuildVCAlerts;
outdatedAlertsTimeout: Timeout;
outdatedAlertsTimeout: Timeout | null;
usersWithAlerts: string[];
unloaded: boolean;
};

View file

@ -8,6 +8,7 @@ import { moveMember } from "./moveMember";
export async function sendAlerts(pluginData: GuildPluginData<LocateUserPluginType>, userId: string) {
const triggeredAlerts = await pluginData.state.alerts.getAlertsByUserId(userId);
const member = await resolveMember(pluginData.client, pluginData.guild, userId);
if (!member) return;
triggeredAlerts.forEach(alert => {
const prepend = `<@!${alert.requestor_id}>, an alert requested by you has triggered!\nReminder: \`${alert.body}\`\n`;

View file

@ -1,4 +1,4 @@
import { Member, TextableChannel, VoiceChannel } from "eris";
import { Invite, Member, TextableChannel, VoiceChannel } from "eris";
import { getInviteLink } from "knub/dist/helpers";
import { createOrReuseInvite } from "./createOrReuseInvite";
import { GuildPluginData } from "knub";
@ -11,12 +11,14 @@ export async function sendWhere(
channel: TextableChannel,
prepend: string,
) {
const voice = pluginData.guild.channels.get(member.voiceState.channelID) as VoiceChannel;
const voice = member.voiceState.channelID
? (pluginData.guild.channels.get(member.voiceState.channelID) as VoiceChannel)
: null;
if (voice == null) {
channel.createMessage(prepend + "That user is not in a channel");
} else {
let invite = null;
let invite: Invite;
try {
invite = await createOrReuseInvite(voice);
} catch (e) {