mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35: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,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { resolveMember, stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
|
@ -23,7 +24,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
|
|||
newRoles =
|
||||
muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles;
|
||||
for (const toRestore of mute.roles_to_restore) {
|
||||
if (guildRoles.has(toRestore) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
}
|
||||
await member.roles.set(newRoles);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { GuildMember, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { MutesPluginType } from "../types";
|
||||
|
||||
export function memberHasMutedRole(pluginData: GuildPluginData<MutesPluginType>, member: GuildMember): boolean {
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
return muteRole ? member.roles.cache.has(muteRole) : false;
|
||||
return muteRole ? member.roles.cache.has(muteRole as Snowflake) : false;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel, User } from "discord.js";
|
||||
import { Snowflake, TextChannel, User } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -86,7 +86,7 @@ export async function muteUser(
|
|||
}
|
||||
|
||||
// Apply mute role if it's missing
|
||||
if (!currentUserRoles.includes(muteRole)) {
|
||||
if (!currentUserRoles.includes(muteRole as Snowflake)) {
|
||||
try {
|
||||
await member.roles.add(muteRole);
|
||||
} catch (e) {
|
||||
|
@ -125,7 +125,7 @@ export async function muteUser(
|
|||
if (moveToVoiceChannel || cfg.kick_from_voice_channel) {
|
||||
// TODO: Add back the voiceState check once we figure out how to get voice state for guild members that are loaded on-demand
|
||||
try {
|
||||
await member.edit({ channel: moveToVoiceChannel });
|
||||
await member.edit({ channel: moveToVoiceChannel as Snowflake });
|
||||
} catch {} // tslint:disable-line
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,8 @@ export async function muteUser(
|
|||
}
|
||||
|
||||
const useChannel = existingMute ? config.message_on_update : config.message_on_mute;
|
||||
const channel = config.message_channel && pluginData.guild.channels.cache.get(config.message_channel);
|
||||
const channel =
|
||||
config.message_channel && pluginData.guild.channels.cache.get(config.message_channel as Snowflake);
|
||||
if (useChannel && channel instanceof TextChannel) {
|
||||
contactMethods.push({ type: "channel", channel });
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -35,7 +36,7 @@ export async function unmuteUser(
|
|||
const lock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
if (muteRole && member.roles.cache.has(muteRole)) {
|
||||
if (muteRole && member.roles.cache.has(muteRole as Snowflake)) {
|
||||
await member.roles.remove(muteRole);
|
||||
}
|
||||
if (existingMute?.roles_to_restore) {
|
||||
|
@ -43,7 +44,7 @@ export async function unmuteUser(
|
|||
let newRoles: string[] = member.roles.cache.keyArray();
|
||||
newRoles = muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles;
|
||||
for (const toRestore of existingMute.roles_to_restore) {
|
||||
if (guildRoles.has(toRestore) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
}
|
||||
await member.roles.set(newRoles);
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ export async function unmuteUser(
|
|||
});
|
||||
|
||||
// Log the action
|
||||
const mod = pluginData.client.users.fetch(modId);
|
||||
const mod = pluginData.client.users.fetch(modId as Snowflake);
|
||||
if (unmuteTime) {
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_TIMED_UNMUTE, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue