upgrade discord.js

This commit is contained in:
almeidx 2021-08-04 20:45:42 +01:00
parent 036d46f08a
commit 3537305c59
No known key found for this signature in database
GPG key ID: 8558FBFF849BD664
32 changed files with 232 additions and 107 deletions

View file

@ -118,7 +118,7 @@ export const CleanCmd = utilityCmd({
const deletePins = args["delete-pins"] != null ? args["delete-pins"] : false;
let pins: Message[] = [];
if (!deletePins) {
pins = (await msg.channel.messages.fetchPinned()).array();
pins = [...(await msg.channel.messages.fetchPinned().catch(() => [])).values()];
}
while (messagesToClean.length < args.count) {
@ -128,14 +128,14 @@ export const CleanCmd = utilityCmd({
});
if (potentialMessages.size === 0) break;
const existingStored = await pluginData.state.savedMessages.getMultiple(potentialMessages.keyArray());
const existingStored = await pluginData.state.savedMessages.getMultiple([...potentialMessages.keys()]);
const alreadyStored = existingStored.map(stored => stored.id);
const messagesToStore = potentialMessages
.array()
.filter(potentialMsg => !alreadyStored.includes(potentialMsg.id));
const messagesToStore = [
...potentialMessages.filter(potentialMsg => !alreadyStored.includes(potentialMsg.id)).values(),
];
await pluginData.state.savedMessages.createFromMessages(messagesToStore);
const potentialMessagesToClean = await pluginData.state.savedMessages.getMultiple(potentialMessages.keyArray());
const potentialMessagesToClean = await pluginData.state.savedMessages.getMultiple([...potentialMessages.keys()]);
if (potentialMessagesToClean.length === 0) break;
const filtered: SavedMessage[] = [];

View file

@ -32,7 +32,7 @@ export const VcdisconnectCmd = utilityCmd({
const channel = pluginData.guild.channels.cache.get(args.member.voice.channelId) as VoiceChannel;
try {
await args.member.voice.kick();
await args.member.voice.disconnect();
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to disconnect member");
return;

View file

@ -9,6 +9,7 @@ import { LogType } from "../../../data/LogType";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { channelMentionRegex, isSnowflake, simpleClosestStringMatch } from "../../../utils";
import { utilityCmd } from "../types";
import { ChannelTypeStrings } from "../../../types";
export const VcmoveCmd = utilityCmd({
trigger: "vcmove",
@ -45,9 +46,11 @@ export const VcmoveCmd = utilityCmd({
channel = potentialChannel;
} else {
// Search string -> find closest matching voice channel name
const voiceChannels = pluginData.guild.channels.cache.array().filter(theChannel => {
return theChannel instanceof VoiceChannel;
}) as VoiceChannel[];
const voiceChannels = [
...pluginData.guild.channels.cache
.filter((c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE)
.values(),
];
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name);
if (!closestMatch) {
sendErrorMessage(pluginData, msg.channel, "No matching voice channels");
@ -124,9 +127,11 @@ export const VcmoveAllCmd = utilityCmd({
channel = potentialChannel;
} else {
// Search string -> find closest matching voice channel name
const voiceChannels = pluginData.guild.channels.cache.array().filter(theChannel => {
return theChannel instanceof VoiceChannel;
}) as VoiceChannel[];
const voiceChannels = [
...pluginData.guild.channels.cache
.filter((c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE)
.values(),
];
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name);
if (!closestMatch) {
sendErrorMessage(pluginData, msg.channel, "No matching voice channels");

View file

@ -130,11 +130,13 @@ export async function getChannelInfoEmbed(
if (channel.type === ChannelTypeStrings.PRIVATE_THREAD || channel.type === ChannelTypeStrings.PUBLIC_THREAD) {
const thread = channel as ThreadChannel;
const parentChannelName = thread.parent?.name ? thread.parent.name : `<#${thread.parentId}>`;
const parentChannelName = thread.parent?.name ?? `<#${thread.parentId}>`;
const memberCount = thread.memberCount ?? thread.members.cache.size;
const owner = await pluginData.guild.members.fetch(thread.ownerId).catch(() => null);
const ownerMention = owner ? verboseUserMention(owner.user) : "Unknown#0000";
const humanizedArchiveTime = `Archive duration: **${humanizeDuration(thread.autoArchiveDuration * MINUTES)}**`;
const owner = await thread.fetchOwner().catch(() => null);
const ownerMention = owner?.user ? verboseUserMention(owner.user) : "Unknown#0000";
const humanizedArchiveTime = `Archive duration: **${humanizeDuration(
(thread.autoArchiveDuration ?? 0) * MINUTES,
)}**`;
embed.fields.push({
name: preEmbedPadding + "Thread information",