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

@ -25,7 +25,7 @@ export const AvatarCmd = utilityCmd({
image: { url: avatarUrl + `${extension}?size=2048` },
};
embed.title = `Avatar of ${user.username}#${user.discriminator}:`;
msg.channel.send({ embed });
msg.channel.send({ embeds: [embed] });
} else {
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
}

View file

@ -8,10 +8,10 @@ export const banSearchSignature = {
page: ct.number({ option: true, shortcut: "p" }),
sort: ct.string({ option: true }),
"case-sensitive": ct.switchOption({ shortcut: "cs" }),
export: ct.switchOption({ shortcut: "e" }),
"case-sensitive": ct.switchOption({ def: false, shortcut: "cs" }),
export: ct.switchOption({ def: false, shortcut: "e" }),
ids: ct.switchOption(),
regex: ct.switchOption({ shortcut: "re" }),
regex: ct.switchOption({ def: false, shortcut: "re" }),
};
export const BanSearchCmd = utilityCmd({

View file

@ -20,6 +20,6 @@ export const ChannelInfoCmd = utilityCmd({
return;
}
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
},
});

View file

@ -1,4 +1,4 @@
import { Message, TextChannel, User } from "discord.js";
import { Message, Snowflake, TextChannel, User } from "discord.js";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes";
@ -25,7 +25,7 @@ async function cleanMessages(
// Delete & archive in ID order
savedMessages = Array.from(savedMessages).sort((a, b) => (a.id > b.id ? 1 : -1));
const idsToDelete = savedMessages.map(m => m.id);
const idsToDelete = savedMessages.map(m => m.id) as Snowflake[];
// Make sure the deletions aren't double logged
idsToDelete.forEach(id => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
@ -53,9 +53,9 @@ async function cleanMessages(
const opts = {
user: ct.userId({ option: true, shortcut: "u" }),
channel: ct.channelId({ option: true, shortcut: "c" }),
bots: ct.switchOption({ shortcut: "b" }),
"delete-pins": ct.switchOption({ shortcut: "p" }),
"has-invites": ct.switchOption({ shortcut: "i" }),
bots: ct.switchOption({ def: false, shortcut: "b" }),
"delete-pins": ct.switchOption({ def: false, shortcut: "p" }),
"has-invites": ct.switchOption({ def: false, shortcut: "i" }),
match: ct.regex({ option: true, shortcut: "m" }),
"to-id": ct.anyId({ option: true, shortcut: "id" }),
};
@ -75,7 +75,7 @@ export const CleanCmd = utilityCmd({
},
{
count: ct.number(),
update: ct.switchOption({ shortcut: "up" }),
update: ct.switchOption({ def: false, shortcut: "up" }),
...opts,
},

View file

@ -27,6 +27,6 @@ export const EmojiInfoCmd = utilityCmd({
return;
}
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
},
});

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { getChannelId, getRoleId } from "knub/dist/utils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
@ -31,7 +32,7 @@ export const InfoCmd = utilityCmd({
signature: {
value: ct.string({ required: false }),
compact: ct.switchOption({ shortcut: "c" }),
compact: ct.switchOption({ def: false, shortcut: "c" }),
},
async run({ message, args, pluginData }) {
@ -45,11 +46,11 @@ export const InfoCmd = utilityCmd({
// 1. Channel
if (userCfg.can_channelinfo) {
const channelId = getChannelId(value);
const channel = channelId && pluginData.guild.channels.cache.get(channelId);
const channel = channelId && pluginData.guild.channels.cache.get(channelId as Snowflake);
if (channel) {
const embed = await getChannelInfoEmbed(pluginData, channelId!, message.author.id);
if (embed) {
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -61,7 +62,7 @@ export const InfoCmd = utilityCmd({
if (guild) {
const embed = await getServerInfoEmbed(pluginData, value, message.author.id);
if (embed) {
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -73,7 +74,7 @@ export const InfoCmd = utilityCmd({
if (user && userCfg.can_userinfo) {
const embed = await getUserInfoEmbed(pluginData, user.id, Boolean(args.compact), message.author.id);
if (embed) {
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -91,7 +92,7 @@ export const InfoCmd = utilityCmd({
message.author.id,
);
if (embed) {
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -106,7 +107,7 @@ export const InfoCmd = utilityCmd({
if (invite) {
const embed = await getInviteInfoEmbed(pluginData, inviteCode);
if (embed) {
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -119,7 +120,7 @@ export const InfoCmd = utilityCmd({
if (serverPreview) {
const embed = await getServerInfoEmbed(pluginData, value, message.author.id);
if (embed) {
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -128,10 +129,10 @@ export const InfoCmd = utilityCmd({
// 7. Role
if (userCfg.can_roleinfo) {
const roleId = getRoleId(value);
const role = roleId && pluginData.guild.roles.cache.get(roleId);
const role = roleId && pluginData.guild.roles.cache.get(roleId as Snowflake);
if (role) {
const embed = await getRoleInfoEmbed(pluginData, role, message.author.id);
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -142,7 +143,7 @@ export const InfoCmd = utilityCmd({
if (emojiIdMatch?.[2]) {
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
if (embed) {
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}
}
@ -151,7 +152,7 @@ export const InfoCmd = utilityCmd({
// 9. Arbitrary ID
if (isValidSnowflake(value) && userCfg.can_snowflake) {
const embed = await getSnowflakeInfoEmbed(pluginData, value, true, message.author.id);
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
return;
}

View file

@ -22,6 +22,6 @@ export const InviteInfoCmd = utilityCmd({
return;
}
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
},
});

View file

@ -83,6 +83,6 @@ export const JumboCmd = utilityCmd({
};
}
msg.channel.send("", file);
msg.channel.send({ content: "", files: [file] });
},
});

View file

@ -31,6 +31,6 @@ export const MessageInfoCmd = utilityCmd({
return;
}
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
},
});

View file

@ -14,6 +14,6 @@ export const RoleInfoCmd = utilityCmd({
async run({ message, args, pluginData }) {
const embed = await getRoleInfoEmbed(pluginData, args.role, message.author.id);
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
},
});

View file

@ -8,14 +8,14 @@ export const searchCmdSignature = {
page: ct.number({ option: true, shortcut: "p" }),
role: ct.string({ option: true, shortcut: "r" }),
voice: ct.switchOption({ shortcut: "v" }),
bot: ct.switchOption({ shortcut: "b" }),
voice: ct.switchOption({ def: false, shortcut: "v" }),
bot: ct.switchOption({ def: false, shortcut: "b" }),
sort: ct.string({ option: true }),
"case-sensitive": ct.switchOption({ shortcut: "cs" }),
export: ct.switchOption({ shortcut: "e" }),
"case-sensitive": ct.switchOption({ def: false, shortcut: "cs" }),
export: ct.switchOption({ def: false, shortcut: "e" }),
ids: ct.switchOption(),
regex: ct.switchOption({ shortcut: "re" }),
"status-search": ct.switchOption({ shortcut: "ss" }),
regex: ct.switchOption({ def: false, shortcut: "re" }),
"status-search": ct.switchOption({ def: false, shortcut: "ss" }),
};
export const SearchCmd = utilityCmd({

View file

@ -21,6 +21,6 @@ export const ServerInfoCmd = utilityCmd({
return;
}
message.channel.send({ embed: serverInfoEmbed });
message.channel.send({ embeds: [serverInfoEmbed] });
},
});

View file

@ -14,6 +14,6 @@ export const SnowflakeInfoCmd = utilityCmd({
async run({ message, args, pluginData }) {
const embed = await getSnowflakeInfoEmbed(pluginData, args.id, false, message.author.id);
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
},
});

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { getBaseUrl, sendErrorMessage } from "../../../pluginUtils";
@ -20,7 +21,7 @@ export const SourceCmd = utilityCmd({
return;
}
const message = await args.message.channel.messages.fetch(args.message.messageId).catch(() => null);
const message = await args.message.channel.messages.fetch(args.message.messageId as Snowflake).catch(() => null);
if (!message) {
sendErrorMessage(pluginData, cmdMessage.channel, "Unknown message");
return;

View file

@ -12,7 +12,7 @@ export const UserInfoCmd = utilityCmd({
signature: {
user: ct.resolvedUserLoose({ required: false }),
compact: ct.switchOption({ shortcut: "c" }),
compact: ct.switchOption({ def: false, shortcut: "c" }),
},
async run({ message, args, pluginData }) {
@ -23,6 +23,6 @@ export const UserInfoCmd = utilityCmd({
return;
}
message.channel.send({ embed });
message.channel.send({ embeds: [embed] });
},
});