Turn on strict TS compilation. Fix up and tweak types accordingly.
This commit is contained in:
parent
690955a399
commit
629002b8d9
172 changed files with 720 additions and 534 deletions
|
@ -1,6 +1,6 @@
|
|||
import { utilityCmd } from "../types";
|
||||
import { multiSorter, resolveMember, sorter } from "../../../utils";
|
||||
import { GuildChannel, MessageContent } from "eris";
|
||||
import { EmbedWith, multiSorter, resolveMember, sorter } from "../../../utils";
|
||||
import { GuildChannel, MessageContent, Role } from "eris";
|
||||
import { getCurrentUptime } from "../../../uptime";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import LCL from "last-commit-log";
|
||||
|
@ -40,7 +40,7 @@ export const AboutCmd = utilityCmd({
|
|||
version = "?";
|
||||
}
|
||||
|
||||
const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id]);
|
||||
const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!;
|
||||
|
||||
const lastReload = humanizeDuration(Date.now() - pluginData.state.lastReload, {
|
||||
largest: 2,
|
||||
|
@ -59,12 +59,12 @@ export const AboutCmd = utilityCmd({
|
|||
const loadedPlugins = Array.from(
|
||||
pluginData
|
||||
.getKnubInstance()
|
||||
.getLoadedGuild(pluginData.guild.id)
|
||||
.getLoadedGuild(pluginData.guild.id)!
|
||||
.loadedPlugins.keys(),
|
||||
);
|
||||
loadedPlugins.sort();
|
||||
|
||||
const aboutContent: MessageContent = {
|
||||
const aboutContent: MessageContent & { embed: EmbedWith<"title" | "fields"> } = {
|
||||
embed: {
|
||||
title: `About ${pluginData.client.user.username}`,
|
||||
fields: [
|
||||
|
@ -101,7 +101,7 @@ export const AboutCmd = utilityCmd({
|
|||
|
||||
// For the embed color, find the highest colored role the bot has - this is their color on the server as well
|
||||
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user.id);
|
||||
let botRoles = botMember.roles.map(r => (msg.channel as GuildChannel).guild.roles.get(r));
|
||||
let botRoles = botMember?.roles.map(r => (msg.channel as GuildChannel).guild.roles.get(r)!) || [];
|
||||
botRoles = botRoles.filter(r => !!r); // Drop any unknown roles
|
||||
botRoles = botRoles.filter(r => r.color); // Filter to those with a color
|
||||
botRoles.sort(sorter("position", "DESC")); // Sort by position (highest first)
|
||||
|
|
|
@ -92,7 +92,7 @@ export const CleanCmd = utilityCmd({
|
|||
|
||||
const cleaningMessage = msg.channel.createMessage("Cleaning...");
|
||||
|
||||
const messagesToClean = [];
|
||||
const messagesToClean: SavedMessage[] = [];
|
||||
let beforeId = msg.id;
|
||||
const timeCutoff = msg.timestamp - MAX_CLEAN_TIME;
|
||||
|
||||
|
@ -104,7 +104,7 @@ export const CleanCmd = utilityCmd({
|
|||
);
|
||||
if (potentialMessagesToClean.length === 0) break;
|
||||
|
||||
const filtered = [];
|
||||
const filtered: SavedMessage[] = [];
|
||||
for (const message of potentialMessagesToClean) {
|
||||
const contentString = message.data.content || "";
|
||||
if (args.user && message.user_id !== args.user) continue;
|
||||
|
|
|
@ -22,7 +22,7 @@ export const HelpCmd = utilityCmd({
|
|||
command: PluginCommandDefinition;
|
||||
}> = [];
|
||||
|
||||
const guildData = pluginData.getKnubInstance().getLoadedGuild(pluginData.guild.id);
|
||||
const guildData = pluginData.getKnubInstance().getLoadedGuild(pluginData.guild.id)!;
|
||||
for (const plugin of guildData.loadedPlugins.values()) {
|
||||
const registeredCommands = plugin.pluginData.commands.getAll();
|
||||
for (const registeredCommand of registeredCommands) {
|
||||
|
@ -55,8 +55,8 @@ export const HelpCmd = utilityCmd({
|
|||
: originalTrigger.source
|
||||
: "";
|
||||
|
||||
const description = command.config.extra.blueprint.description;
|
||||
const usage = command.config.extra.blueprint.usage;
|
||||
const description = command.config!.extra!.blueprint.description;
|
||||
const usage = command.config!.extra!.blueprint.usage;
|
||||
const commandSlug = trigger
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
|
|
|
@ -32,7 +32,7 @@ export const InfoCmd = utilityCmd({
|
|||
const channelId = getChannelId(value);
|
||||
const channel = channelId && pluginData.guild.channels.get(channelId);
|
||||
if (channel) {
|
||||
const embed = await getChannelInfoEmbed(pluginData, channelId, message.author.id);
|
||||
const embed = await getChannelInfoEmbed(pluginData, channelId!, message.author.id);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
return;
|
||||
|
|
|
@ -10,9 +10,9 @@ export const PingCmd = utilityCmd({
|
|||
permission: "can_ping",
|
||||
|
||||
async run({ message: msg, pluginData }) {
|
||||
const times = [];
|
||||
const times: number[] = [];
|
||||
const messages: Message[] = [];
|
||||
let msgToMsgDelay = null;
|
||||
let msgToMsgDelay: number | undefined;
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const start = performance.now();
|
||||
|
@ -20,7 +20,7 @@ export const PingCmd = utilityCmd({
|
|||
times.push(performance.now() - start);
|
||||
messages.push(message);
|
||||
|
||||
if (msgToMsgDelay === null) {
|
||||
if (msgToMsgDelay === undefined) {
|
||||
msgToMsgDelay = message.timestamp - msg.timestamp;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export const PingCmd = utilityCmd({
|
|||
const lowest = Math.round(Math.min(...times));
|
||||
const mean = Math.round(times.reduce((total, ms) => total + ms, 0) / times.length);
|
||||
|
||||
const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id]);
|
||||
const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!;
|
||||
|
||||
msg.channel.createMessage(
|
||||
trimLines(`
|
||||
|
@ -37,7 +37,7 @@ export const PingCmd = utilityCmd({
|
|||
Lowest: **${lowest}ms**
|
||||
Highest: **${highest}ms**
|
||||
Mean: **${mean}ms**
|
||||
Time between ping command and first reply: **${msgToMsgDelay}ms**
|
||||
Time between ping command and first reply: **${msgToMsgDelay!}ms**
|
||||
Shard latency: **${shard.latency}ms**
|
||||
`),
|
||||
);
|
||||
|
|
|
@ -51,8 +51,8 @@ export const RolesCmd = utilityCmd({
|
|||
|
||||
if (!sort) sort = "-memberCount";
|
||||
roles.sort((a, b) => {
|
||||
if (a._memberCount > b._memberCount) return -1;
|
||||
if (a._memberCount < b._memberCount) return 1;
|
||||
if (a._memberCount! > b._memberCount!) return -1;
|
||||
if (a._memberCount! < b._memberCount!) return 1;
|
||||
return 0;
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -25,6 +25,8 @@ export const VcmoveCmd = utilityCmd({
|
|||
async run({ message: msg, args, pluginData }) {
|
||||
let channel: VoiceChannel;
|
||||
|
||||
const foo = args.member;
|
||||
|
||||
if (isSnowflake(args.channel)) {
|
||||
// Snowflake -> resolve channel directly
|
||||
const potentialChannel = pluginData.guild.channels.get(args.channel);
|
||||
|
@ -36,7 +38,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
channel = potentialChannel;
|
||||
} else if (channelMentionRegex.test(args.channel)) {
|
||||
// Channel mention -> parse channel id and resolve channel from that
|
||||
const channelId = args.channel.match(channelMentionRegex)[1];
|
||||
const channelId = args.channel.match(channelMentionRegex)![1];
|
||||
const potentialChannel = pluginData.guild.channels.get(channelId);
|
||||
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue