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,4 +1,4 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { GuildMember, Snowflake } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
|
@ -95,7 +95,7 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
|||
hasMutedRole(pluginData) {
|
||||
return (member: GuildMember) => {
|
||||
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 { User } from "discord.js";
|
||||
import { Snowflake, User } from "discord.js";
|
||||
import { sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { mutesCmd } from "../types";
|
||||
|
||||
|
@ -19,7 +19,7 @@ export const ClearBannedMutesCmd = mutesCmd({
|
|||
|
||||
let cleared = 0;
|
||||
for (const mute of activeMutes) {
|
||||
if (bannedIds.includes(mute.user_id)) {
|
||||
if (bannedIds.includes(mute.user_id as Snowflake)) {
|
||||
await pluginData.state.mutes.clear(mute.user_id);
|
||||
cleared++;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveMember } from "../../../utils";
|
||||
import { mutesCmd } from "../types";
|
||||
|
@ -19,7 +20,7 @@ export const ClearMutesWithoutRoleCmd = mutesCmd({
|
|||
const member = await resolveMember(pluginData.client, pluginData.guild, mute.user_id);
|
||||
if (!member) continue;
|
||||
|
||||
if (!member.roles.cache.has(muteRole)) {
|
||||
if (!member.roles.cache.has(muteRole as Snowflake)) {
|
||||
await pluginData.state.mutes.clear(mute.user_id);
|
||||
cleared++;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember, MessageActionRow, MessageButton, MessageComponentInteraction } from "discord.js";
|
||||
import { GuildMember, MessageActionRow, MessageButton, MessageComponentInteraction, Snowflake } from "discord.js";
|
||||
import moment from "moment-timezone";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { humanizeDurationShort } from "../../../humanizeDurationShort";
|
||||
|
@ -16,9 +16,9 @@ export const MutesCmd = mutesCmd({
|
|||
shortcut: "a",
|
||||
}),
|
||||
|
||||
left: ct.switchOption({ shortcut: "l" }),
|
||||
manual: ct.switchOption({ shortcut: "m" }),
|
||||
export: ct.switchOption({ shortcut: "e" }),
|
||||
left: ct.switchOption({ def: false, shortcut: "l" }),
|
||||
manual: ct.switchOption({ def: false, shortcut: "m" }),
|
||||
export: ct.switchOption({ def: false, shortcut: "e" }),
|
||||
},
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
|
@ -53,7 +53,7 @@ export const MutesCmd = mutesCmd({
|
|||
if (muteRole) {
|
||||
pluginData.guild.members.cache.forEach(member => {
|
||||
if (muteUserIds.has(member.id)) return;
|
||||
if (member.roles.cache.has(muteRole)) manuallyMutedMembers.push(member);
|
||||
if (member.roles.cache.has(muteRole as Snowflake)) manuallyMutedMembers.push(member);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ export const MutesCmd = mutesCmd({
|
|||
const muteCasesById = muteCases.reduce((map, c) => map.set(c.id, c), new Map());
|
||||
|
||||
lines = filteredMutes.map(mute => {
|
||||
const user = pluginData.client.users.resolve(mute.user_id);
|
||||
const user = pluginData.client.users.resolve(mute.user_id as Snowflake);
|
||||
const username = user ? `${user.username}#${user.discriminator}` : "Unknown#0000";
|
||||
const theCase = muteCasesById.get(mute.case_id);
|
||||
const caseName = theCase ? `Case #${theCase.case_number}` : "No case";
|
||||
|
@ -199,7 +199,6 @@ export const MutesCmd = mutesCmd({
|
|||
new MessageButton()
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("⬅")
|
||||
.setType("BUTTON")
|
||||
.setCustomID(`previousButton:${idMod}`),
|
||||
);
|
||||
|
||||
|
@ -207,7 +206,6 @@ export const MutesCmd = mutesCmd({
|
|||
new MessageButton()
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("➡")
|
||||
.setType("BUTTON")
|
||||
.setCustomID(`nextButton:${idMod}`),
|
||||
);
|
||||
|
||||
|
@ -215,13 +213,14 @@ export const MutesCmd = mutesCmd({
|
|||
await listMessage.edit({ components: [row] });
|
||||
|
||||
const filter = (iac: MessageComponentInteraction) => iac.message.id === listMessage.id;
|
||||
const collector = listMessage.createMessageComponentInteractionCollector(filter, {
|
||||
const collector = listMessage.createMessageComponentInteractionCollector({
|
||||
filter,
|
||||
time: stopCollectionDebounce,
|
||||
});
|
||||
|
||||
collector.on("collect", async (interaction: MessageComponentInteraction) => {
|
||||
if (msg.author.id !== interaction.user.id) {
|
||||
interaction.reply(`You are not permitted to use these buttons.`, { ephemeral: true });
|
||||
interaction.reply({ content: `You are not permitted to use these buttons.`, ephemeral: true });
|
||||
} else {
|
||||
collector.resetTimer();
|
||||
if (interaction.customID === `previousButton:${idMod}` && currentPage > 1) {
|
||||
|
|
|
@ -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