3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 20:55:01 +00:00

Type fixes for djs

This commit is contained in:
Dark 2021-06-30 04:56:56 +02:00
parent 653d6c1dc2
commit 0822fc15e5
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
130 changed files with 8877 additions and 411 deletions

View file

@ -1,4 +1,4 @@
import { DiscordAPIError, User } from "discord.js";
import { DiscordAPIError, Snowflake, User } from "discord.js";
import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes";
@ -77,7 +77,7 @@ export async function banUserId(
ignoreEvent(pluginData, IgnoredEventType.Ban, userId);
try {
const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1));
await pluginData.guild.bans.create(userId, {
await pluginData.guild.bans.create(userId as Snowflake, {
days: deleteMessageDays,
reason: reason != null ? encodeURIComponent(reason) : undefined,
});

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js";
import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub";
import { UserNotificationMethod } from "../../../utils";
import { ModActionsPluginType } from "../types";
@ -15,7 +15,7 @@ export function getDefaultContactMethods(
}
if (config[`message_on_${type}`] && config.message_channel) {
const channel = pluginData.guild.channels.cache.get(config.message_channel);
const channel = pluginData.guild.channels.cache.get(config.message_channel as Snowflake);
if (channel instanceof TextChannel) {
methods.push({
type: "channel",

View file

@ -1,4 +1,4 @@
import { Permissions } from "discord.js";
import { Permissions, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType";
import { isDiscordHTTPError, isDiscordRESTError, SECONDS, sleep } from "../../../utils";
@ -21,7 +21,7 @@ export async function isBanned(
try {
const potentialBan = await Promise.race([
pluginData.guild.bans.fetch({ user: userId }).catch(() => null),
pluginData.guild.bans.fetch({ user: userId as Snowflake }).catch(() => null),
sleep(timeout),
]);
return potentialBan != null;

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
@ -30,7 +31,10 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
);
try {
ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id);
await pluginData.guild.bans.remove(tempban.user_id, reason != null ? encodeURIComponent(reason) : undefined);
await pluginData.guild.bans.remove(
tempban.user_id as Snowflake,
reason != null ? encodeURIComponent(reason) : undefined,
);
} catch (e) {
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`,

View file

@ -1,4 +1,4 @@
import { GuildMember } from "discord.js";
import { GuildMember, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "../../../data/LogType";
@ -75,7 +75,7 @@ export async function warnMember(
noteDetails: notifyResult.text ? [ucfirst(notifyResult.text)] : [],
});
const mod = await pluginData.guild.members.fetch(modId);
const mod = await pluginData.guild.members.fetch(modId as Snowflake);
pluginData.state.serverLogs.log(LogType.MEMBER_WARN, {
mod: stripObjectToScalars(mod),
member: stripObjectToScalars(member, ["user", "roles"]),