mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Type fixes for djs
This commit is contained in:
parent
653d6c1dc2
commit
0822fc15e5
130 changed files with 8877 additions and 411 deletions
|
@ -1,4 +1,4 @@
|
|||
import { GuildChannel, Permissions, TextChannel } from "discord.js";
|
||||
import { GuildChannel, Permissions, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -11,7 +11,7 @@ export async function applyBotSlowmodeToUserId(
|
|||
userId: string,
|
||||
) {
|
||||
// Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account.
|
||||
const existingOverride = channel.permissionOverwrites.get(userId);
|
||||
const existingOverride = channel.permissionOverwrites.get(userId as Snowflake);
|
||||
const newDeniedPermissions =
|
||||
(existingOverride ? existingOverride.deny.bitfield : 0n) | Permissions.FLAGS.SEND_MESSAGES;
|
||||
const newAllowedPermissions =
|
||||
|
@ -22,7 +22,7 @@ export async function applyBotSlowmodeToUserId(
|
|||
{ id: userId, allow: newAllowedPermissions, deny: newDeniedPermissions, type: "member" },
|
||||
]);
|
||||
} catch (e) {
|
||||
const user = pluginData.client.users.fetch(userId) || new UnknownUser({ id: userId });
|
||||
const user = pluginData.client.users.fetch(userId as Snowflake) || new UnknownUser({ id: userId });
|
||||
|
||||
if (isDiscordRESTError(e) && e.code === 50013) {
|
||||
logger.warn(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildChannel, TextChannel } from "discord.js";
|
||||
import { GuildChannel, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
|
||||
|
@ -13,7 +13,7 @@ export async function clearBotSlowmodeFromUserId(
|
|||
// Previously we diffed the overrides so we could clear the "send messages" override without touching other
|
||||
// overrides. Unfortunately, it seems that was a bit buggy - we didn't always receive the event for the changed
|
||||
// overrides and then we also couldn't diff against them. For consistency's sake, we just delete the override now.
|
||||
await channel.permissionOverwrites.get(userId)?.delete();
|
||||
await channel.permissionOverwrites.get(userId as Snowflake)?.delete();
|
||||
} catch (e) {
|
||||
if (!force) {
|
||||
throw e;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildChannel, TextChannel } from "discord.js";
|
||||
import { GuildChannel, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -9,7 +9,7 @@ import { clearBotSlowmodeFromUserId } from "./clearBotSlowmodeFromUserId";
|
|||
export async function clearExpiredSlowmodes(pluginData: GuildPluginData<SlowmodePluginType>) {
|
||||
const expiredSlowmodeUsers = await pluginData.state.slowmodes.getExpiredSlowmodeUsers();
|
||||
for (const user of expiredSlowmodeUsers) {
|
||||
const channel = pluginData.guild.channels.cache.get(user.channel_id);
|
||||
const channel = pluginData.guild.channels.cache.get(user.channel_id as Snowflake);
|
||||
if (!channel) {
|
||||
await pluginData.state.slowmodes.clearSlowmodeUser(user.channel_id, user.user_id);
|
||||
continue;
|
||||
|
@ -20,7 +20,8 @@ export async function clearExpiredSlowmodes(pluginData: GuildPluginData<Slowmode
|
|||
} catch (e) {
|
||||
logger.error(e);
|
||||
|
||||
const realUser = pluginData.client.users!.fetch(user.user_id) || new UnknownUser({ id: user.user_id });
|
||||
const realUser =
|
||||
pluginData.client.users!.fetch(user.user_id as Snowflake) || new UnknownUser({ id: user.user_id });
|
||||
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
||||
body: `Failed to clear slowmode permissions from {userMention(user)} in {channelMention(channel)}`,
|
||||
user: stripObjectToScalars(realUser),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -15,7 +15,7 @@ import { applyBotSlowmodeToUserId } from "./applyBotSlowmodeToUserId";
|
|||
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
|
||||
if (msg.is_bot) return;
|
||||
|
||||
const channel = pluginData.guild.channels.cache.get(msg.channel_id) as TextChannel;
|
||||
const channel = pluginData.guild.channels.cache.get(msg.channel_id as Snowflake) as TextChannel;
|
||||
if (!channel) return;
|
||||
|
||||
// Don't apply slowmode if the lock was interrupted earlier (e.g. the message was caught by word filters)
|
||||
|
@ -49,7 +49,7 @@ export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePlugin
|
|||
// Delete any extra messages sent after a slowmode was already applied
|
||||
const userHasSlowmode = await pluginData.state.slowmodes.userHasSlowmode(channel.id, msg.user_id);
|
||||
if (userHasSlowmode) {
|
||||
const message = await channel.messages.fetch(msg.id);
|
||||
const message = await channel.messages.fetch(msg.id as Snowflake);
|
||||
if (message) {
|
||||
message.delete();
|
||||
return thisMsgLock.interrupt();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue