3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

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

6505
backend/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -29,7 +29,7 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"deep-diff": "^1.0.2", "deep-diff": "^1.0.2",
"discord.js": "github:monbrey/discord.js#9c42f571093b2565df28b756fdca4ac59cad0fe3", "discord.js": "^13.0.0-dev.edab5af.1624996138",
"dotenv": "^4.0.0", "dotenv": "^4.0.0",
"emoji-regex": "^8.0.0", "emoji-regex": "^8.0.0",
"erlpack": "github:discord/erlpack", "erlpack": "github:discord/erlpack",
@ -39,8 +39,8 @@
"humanize-duration": "^3.15.0", "humanize-duration": "^3.15.0",
"io-ts": "^2.0.0", "io-ts": "^2.0.0",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"knub": "^30.0.0-beta.38", "knub": "file:../../Knub",
"knub-command-manager": "^8.1.2", "knub-command-manager": "^9.1.0",
"last-commit-log": "^2.1.0", "last-commit-log": "^2.1.0",
"lodash.chunk": "^4.2.0", "lodash.chunk": "^4.2.0",
"lodash.clonedeep": "^4.5.0", "lodash.clonedeep": "^4.5.0",
@ -88,7 +88,7 @@
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"source-map-support": "^0.5.16", "source-map-support": "^0.5.16",
"tsc-watch": "^4.0.0", "tsc-watch": "^4.0.0",
"typescript": "^4.1.3" "typescript": "^4.4.0-dev.20210629"
}, },
"ava": { "ava": {
"files": [ "files": [

View file

@ -1,4 +1,4 @@
import { Guild } from "discord.js"; import { Guild, Snowflake } from "discord.js";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { getRepository, Repository } from "typeorm"; import { getRepository, Repository } from "typeorm";
import { renderTemplate } from "../templateFormatter"; import { renderTemplate } from "../templateFormatter";
@ -73,7 +73,7 @@ export class GuildArchives extends BaseGuildRepository {
protected async renderLinesFromSavedMessages(savedMessages: SavedMessage[], guild: Guild) { protected async renderLinesFromSavedMessages(savedMessages: SavedMessage[], guild: Guild) {
const msgLines: string[] = []; const msgLines: string[] = [];
for (const msg of savedMessages) { for (const msg of savedMessages) {
const channel = guild.channels.cache.get(msg.channel_id); const channel = guild.channels.cache.get(msg.channel_id as Snowflake);
const user = { ...msg.data.author, id: msg.user_id }; const user = { ...msg.data.author, id: msg.user_id };
const line = await renderTemplate(MESSAGE_ARCHIVE_MESSAGE_FORMAT, { const line = await renderTemplate(MESSAGE_ARCHIVE_MESSAGE_FORMAT, {

View file

@ -196,7 +196,7 @@ export async function sendSuccessMessage(
: { content: formattedBody }; : { content: formattedBody };
return channel return channel
.send({ ...content, split: false }) // Force line break .send({ ...content }) // Force line break
.catch(err => { .catch(err => {
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`; const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`;
logger.warn(`Failed to send success message to ${channelInfo}): ${err.code} ${err.message}`); logger.warn(`Failed to send success message to ${channelInfo}): ${err.code} ${err.message}`);
@ -217,7 +217,7 @@ export async function sendErrorMessage(
: { content: formattedBody }; : { content: formattedBody };
return channel return channel
.send({ ...content, split: false }) // Force line break .send({ ...content }) // Force line break
.catch(err => { .catch(err => {
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`; const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`;
logger.warn(`Failed to send error message to ${channelInfo}): ${err.code} ${err.message}`); logger.warn(`Failed to send error message to ${channelInfo}): ${err.code} ${err.message}`);

View file

@ -1,4 +1,4 @@
import { Permissions, TextChannel } from "discord.js"; import { Permissions, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -16,7 +16,7 @@ export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePlugi
scheduleNextDeletion(pluginData); scheduleNextDeletion(pluginData);
const channel = pluginData.guild.channels.cache.get(itemToDelete.message.channel_id); const channel = pluginData.guild.channels.cache.get(itemToDelete.message.channel_id as Snowflake) as TextChannel;
if (!channel) { if (!channel) {
// Channel was deleted, ignore // Channel was deleted, ignore
return; return;
@ -44,7 +44,7 @@ export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePlugi
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin); const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
pluginData.state.guildLogs.ignoreLog(LogType.MESSAGE_DELETE, itemToDelete.message.id); pluginData.state.guildLogs.ignoreLog(LogType.MESSAGE_DELETE, itemToDelete.message.id);
(channel as TextChannel).messages.delete(itemToDelete.message.id).catch(err => { (channel as TextChannel).messages.delete(itemToDelete.message.id as Snowflake).catch(err => {
if (err.code === 10008) { if (err.code === 10008) {
// "Unknown Message", probably already deleted by automod or another bot, ignore // "Unknown Message", probably already deleted by automod or another bot, ignore
return; return;

View file

@ -1,4 +1,4 @@
import { Permissions } from "discord.js"; import { Permissions, Snowflake } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { nonNullish, unique } from "../../../utils"; import { nonNullish, unique } from "../../../utils";
@ -41,7 +41,7 @@ export const AddRolesAction = automodAction({
if (rolesWeCannotAssign.length) { if (rolesWeCannotAssign.length) {
const roleNamesWeCannotAssign = rolesWeCannotAssign.map( const roleNamesWeCannotAssign = rolesWeCannotAssign.map(
roleId => pluginData.guild.roles.cache.get(roleId)?.name || roleId, roleId => pluginData.guild.roles.cache.get(roleId as Snowflake)?.name || roleId,
); );
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
logs.log(LogType.BOT_ALERT, { logs.log(LogType.BOT_ALERT, {
@ -55,7 +55,7 @@ export const AddRolesAction = automodAction({
members.map(async member => { members.map(async member => {
const memberRoles = new Set(member.roles.cache.keyArray()); const memberRoles = new Set(member.roles.cache.keyArray());
for (const roleId of rolesToAssign) { for (const roleId of rolesToAssign) {
memberRoles.add(roleId); memberRoles.add(roleId as Snowflake);
ignoreRoleChange(pluginData, member.id, roleId); ignoreRoleChange(pluginData, member.id, roleId);
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions"; import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -24,7 +24,7 @@ export const AlertAction = automodAction({
defaultConfig: {}, defaultConfig: {},
async apply({ pluginData, contexts, actionConfig, ruleName, matchResult }) { async apply({ pluginData, contexts, actionConfig, ruleName, matchResult }) {
const channel = pluginData.guild.channels.cache.get(actionConfig.channel); const channel = pluginData.guild.channels.cache.get(actionConfig.channel as Snowflake);
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
if (channel && channel instanceof TextChannel) { if (channel && channel instanceof TextChannel) {

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { noop } from "../../../utils"; import { noop } from "../../../utils";
@ -30,8 +30,8 @@ export const CleanAction = automodAction({
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id); pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id);
} }
const channel = pluginData.guild.channels.cache.get(channelId) as TextChannel; const channel = pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel;
await channel.bulkDelete(messageIds).catch(noop); await channel.bulkDelete(messageIds as Snowflake[]).catch(noop);
} }
}, },
}); });

View file

@ -1,4 +1,4 @@
import { Permissions } from "discord.js"; import { Permissions, Snowflake } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { nonNullish, unique } from "../../../utils"; import { nonNullish, unique } from "../../../utils";
@ -42,7 +42,7 @@ export const RemoveRolesAction = automodAction({
if (rolesWeCannotRemove.length) { if (rolesWeCannotRemove.length) {
const roleNamesWeCannotRemove = rolesWeCannotRemove.map( const roleNamesWeCannotRemove = rolesWeCannotRemove.map(
roleId => pluginData.guild.roles.cache.get(roleId)?.name || roleId, roleId => pluginData.guild.roles.cache.get(roleId as Snowflake)?.name || roleId,
); );
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
logs.log(LogType.BOT_ALERT, { logs.log(LogType.BOT_ALERT, {
@ -56,7 +56,7 @@ export const RemoveRolesAction = automodAction({
members.map(async member => { members.map(async member => {
const memberRoles = new Set(member.roles.cache.keyArray()); const memberRoles = new Set(member.roles.cache.keyArray());
for (const roleId of rolesToRemove) { for (const roleId of rolesToRemove) {
memberRoles.delete(roleId); memberRoles.delete(roleId as Snowflake);
ignoreRoleChange(pluginData, member.id, roleId); ignoreRoleChange(pluginData, member.id, roleId);
} }

View file

@ -1,4 +1,4 @@
import { MessageOptions, Permissions, TextChannel, User } from "discord.js"; import { MessageOptions, Permissions, Snowflake, TextChannel, User } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { renderTemplate } from "../../../templateFormatter"; import { renderTemplate } from "../../../templateFormatter";
@ -31,7 +31,7 @@ export const ReplyAction = automodAction({
async apply({ pluginData, contexts, actionConfig, ruleName }) { async apply({ pluginData, contexts, actionConfig, ruleName }) {
const contextsWithTextChannels = contexts const contextsWithTextChannels = contexts
.filter(c => c.message?.channel_id) .filter(c => c.message?.channel_id)
.filter(c => pluginData.guild.channels.cache.get(c.message!.channel_id) instanceof TextChannel); .filter(c => pluginData.guild.channels.cache.get(c.message!.channel_id as Snowflake) instanceof TextChannel);
const contextsByChannelId = contextsWithTextChannels.reduce((map: Map<string, AutomodContext[]>, context) => { const contextsByChannelId = contextsWithTextChannels.reduce((map: Map<string, AutomodContext[]>, context) => {
if (!map.has(context.message!.channel_id)) { if (!map.has(context.message!.channel_id)) {
@ -56,7 +56,7 @@ export const ReplyAction = automodAction({
: ((await renderRecursively(actionConfig.text, renderReplyText)) as MessageOptions); : ((await renderRecursively(actionConfig.text, renderReplyText)) as MessageOptions);
if (formatted) { if (formatted) {
const channel = pluginData.guild.channels.cache.get(channelId) as TextChannel; const channel = pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel;
// Check for basic Send Messages and View Channel permissions // Check for basic Send Messages and View Channel permissions
if ( if (
@ -90,7 +90,6 @@ export const ReplyAction = automodAction({
allowedMentions: { allowedMentions: {
users: [user.id], users: [user.id],
}, },
split: false,
}); });
if (typeof actionConfig === "object" && actionConfig.auto_delete) { if (typeof actionConfig === "object" && actionConfig.auto_delete) {

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { ChannelTypeStrings } from "src/types"; import { ChannelTypeStrings } from "src/types";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -19,7 +19,7 @@ export const SetSlowmodeAction = automodAction({
const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0); const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0);
for (const channelId of actionConfig.channels) { for (const channelId of actionConfig.channels) {
const channel = pluginData.guild.channels.cache.get(channelId); const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
// Only text channels and text channels within categories support slowmodes // Only text channels and text channels within categories support slowmodes
if (!channel || !(channel.type === ChannelTypeStrings.TEXT || ChannelTypeStrings.CATEGORY)) { if (!channel || !(channel.type === ChannelTypeStrings.TEXT || ChannelTypeStrings.CATEGORY)) {

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
@ -11,8 +12,8 @@ export function runAutomodOnMessage(
message: SavedMessage, message: SavedMessage,
isEdit: boolean, isEdit: boolean,
) { ) {
const user = pluginData.client.users.cache!.get(message.user_id); const user = pluginData.client.users.cache!.get(message.user_id as Snowflake);
const member = pluginData.guild.members.cache.get(message.user_id); const member = pluginData.guild.members.cache.get(message.user_id as Snowflake);
const context: AutomodContext = { const context: AutomodContext = {
timestamp: moment.utc(message.posted_at).valueOf(), timestamp: moment.utc(message.posted_at).valueOf(),

View file

@ -1,3 +1,4 @@
import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { messageSummary, verboseChannelMention } from "../../../utils"; import { messageSummary, verboseChannelMention } from "../../../utils";
import { AutomodContext, AutomodPluginType } from "../types"; import { AutomodContext, AutomodPluginType } from "../types";
@ -10,13 +11,13 @@ export function getTextMatchPartialSummary(
) { ) {
if (type === "message") { if (type === "message") {
const message = context.message!; const message = context.message!;
const channel = pluginData.guild.channels.cache.get(message.channel_id); const channel = pluginData.guild.channels.cache.get(message.channel_id as Snowflake) as TextChannel;
const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``; const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``;
return `message in ${channelMention}:\n${messageSummary(message)}`; return `message in ${channelMention}:\n${messageSummary(message)}`;
} else if (type === "embed") { } else if (type === "embed") {
const message = context.message!; const message = context.message!;
const channel = pluginData.guild.channels.cache.get(message.channel_id); const channel = pluginData.guild.channels.cache.get(message.channel_id as Snowflake) as TextChannel;
const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``; const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``;
return `message embed in ${channelMention}:\n${messageSummary(message)}`; return `message embed in ${channelMention}:\n${messageSummary(message)}`;
@ -28,6 +29,6 @@ export function getTextMatchPartialSummary(
const visibleName = context.member?.nickname || context.user!.username; const visibleName = context.member?.nickname || context.user!.username;
return `visible name: ${visibleName}`; return `visible name: ${visibleName}`;
} else if (type === "customstatus") { } else if (type === "customstatus") {
return `custom status: ${context.member!.presence.activities.find(a => a.type === "CUSTOM_STATUS")?.name}`; return `custom status: ${context.member!.presence.activities.find(a => a.type === "CUSTOM")?.name}`;
} }
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError"; import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils"; import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
@ -18,7 +18,7 @@ export function resolveActionContactMethods(
throw new RecoverablePluginError(ERRORS.NO_USER_NOTIFICATION_CHANNEL); throw new RecoverablePluginError(ERRORS.NO_USER_NOTIFICATION_CHANNEL);
} }
const channel = pluginData.guild.channels.cache.get(actionConfig.notifyChannel); const channel = pluginData.guild.channels.cache.get(actionConfig.notifyChannel as Snowflake);
if (!(channel instanceof TextChannel)) { if (!(channel instanceof TextChannel)) {
throw new RecoverablePluginError(ERRORS.INVALID_USER_NOTIFICATION_CHANNEL); throw new RecoverablePluginError(ERRORS.INVALID_USER_NOTIFICATION_CHANNEL);
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { availableActions } from "../actions/availableActions"; import { availableActions } from "../actions/availableActions";
import { CleanAction } from "../actions/clean"; import { CleanAction } from "../actions/clean";
@ -9,10 +9,10 @@ import { checkAndUpdateCooldown } from "./checkAndUpdateCooldown";
export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) { export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
const userId = context.user?.id || context.member?.id || context.message?.user_id; const userId = context.user?.id || context.member?.id || context.message?.user_id;
const user = context.user || (userId && pluginData.client.users!.cache.get(userId)); const user = context.user || (userId && pluginData.client.users!.cache.get(userId as Snowflake));
const member = context.member || (userId && pluginData.guild.members.cache.get(userId)) || null; const member = context.member || (userId && pluginData.guild.members.cache.get(userId as Snowflake)) || null;
const channelId = context.message?.channel_id; const channelId = context.message?.channel_id;
const channel = channelId ? (pluginData.guild.channels.cache.get(channelId) as TextChannel) : null; const channel = channelId ? (pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel) : null;
const categoryId = channel?.parentID; const categoryId = channel?.parentID;
const config = await pluginData.config.getMatchingConfig({ const config = await pluginData.config.getMatchingConfig({

View file

@ -1,3 +1,4 @@
import { Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { verboseChannelMention } from "../../../utils"; import { verboseChannelMention } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -21,7 +22,7 @@ export const AnyMessageTrigger = automodTrigger<AnyMessageResultType>()({
}, },
renderMatchInformation({ pluginData, contexts, matchResult }) { renderMatchInformation({ pluginData, contexts, matchResult }) {
const channel = pluginData.guild.channels.cache.get(contexts[0].message!.channel_id); const channel = pluginData.guild.channels.cache.get(contexts[0].message!.channel_id as Snowflake) as TextChannel;
return `Matched message (\`${contexts[0].message!.id}\`) in ${ return `Matched message (\`${contexts[0].message!.id}\`) in ${
channel ? verboseChannelMention(channel) : "Unknown Channel" channel ? verboseChannelMention(channel) : "Unknown Channel"
}`; }`;

View file

@ -1,3 +1,4 @@
import { Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { asSingleLine, disableInlineCode, messageSummary, verboseChannelMention } from "../../../utils"; import { asSingleLine, disableInlineCode, messageSummary, verboseChannelMention } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -67,7 +68,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
}, },
renderMatchInformation({ pluginData, contexts, matchResult }) { renderMatchInformation({ pluginData, contexts, matchResult }) {
const channel = pluginData.guild.channels.cache.get(contexts[0].message!.channel_id)!; const channel = pluginData.guild.channels.cache.get(contexts[0].message!.channel_id as Snowflake) as TextChannel;
const prettyChannel = verboseChannelMention(channel); const prettyChannel = verboseChannelMention(channel);
return ( return (

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges"; import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -33,7 +34,7 @@ export const RoleAddedTrigger = automodTrigger<RoleAddedMatchResult>()({
}, },
renderMatchInformation({ matchResult, pluginData, contexts }) { renderMatchInformation({ matchResult, pluginData, contexts }) {
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId); const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
const roleName = role?.name || "Unknown"; const roleName = role?.name || "Unknown";
const member = contexts[0].member!; const member = contexts[0].member!;
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`; const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges"; import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
@ -33,7 +34,7 @@ export const RoleRemovedTrigger = automodTrigger<RoleAddedMatchResult>()({
}, },
renderMatchInformation({ matchResult, pluginData, contexts }) { renderMatchInformation({ matchResult, pluginData, contexts }) {
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId); const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId as Snowflake);
const roleName = role?.name || "Unknown"; const roleName = role?.name || "Unknown";
const member = contexts[0].member!; const member = contexts[0].member!;
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`; const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { AllowedGuilds } from "../../data/AllowedGuilds"; import { AllowedGuilds } from "../../data/AllowedGuilds";
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments"; import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
import { Configs } from "../../data/Configs"; import { Configs } from "../../data/Configs";
@ -58,9 +58,9 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
const [guildId, channelId] = activeReload; const [guildId, channelId] = activeReload;
resetActiveReload(); resetActiveReload();
const guild = await pluginData.client.guilds.fetch(guildId); const guild = await pluginData.client.guilds.fetch(guildId as Snowflake);
if (guild) { if (guild) {
const channel = guild.channels.cache.get(channelId); const channel = guild.channels.cache.get(channelId as Snowflake);
if (channel instanceof TextChannel) { if (channel instanceof TextChannel) {
sendSuccessMessage(pluginData, channel, "Global plugins reloaded!"); sendSuccessMessage(pluginData, channel, "Global plugins reloaded!");
} }

View file

@ -15,9 +15,9 @@ export const ServersCmd = botControlCmd({
signature: { signature: {
search: ct.string({ catchAll: true, required: false }), search: ct.string({ catchAll: true, required: false }),
all: ct.switchOption({ shortcut: "a" }), all: ct.switchOption({ def: false, shortcut: "a" }),
initialized: ct.switchOption({ shortcut: "i" }), initialized: ct.switchOption({ def: false, shortcut: "i" }),
uninitialized: ct.switchOption({ shortcut: "u" }), uninitialized: ct.switchOption({ def: false, shortcut: "u" }),
}, },
async run({ pluginData, message: msg, args }) { async run({ pluginData, message: msg, args }) {

View file

@ -108,5 +108,5 @@ export async function getCaseEmbed(
}); });
} }
return { embed }; return { embeds: [embed] };
} }

View file

@ -1,4 +1,4 @@
import { FileOptions, Message, MessageOptions, TextChannel } from "discord.js"; import { FileOptions, Message, MessageOptions, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { Case } from "../../../data/entities/Case"; import { Case } from "../../../data/entities/Case";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -15,7 +15,7 @@ export async function postToCaseLogChannel(
const caseLogChannelId = pluginData.config.get().case_log_channel; const caseLogChannelId = pluginData.config.get().case_log_channel;
if (!caseLogChannelId) return null; if (!caseLogChannelId) return null;
const caseLogChannel = pluginData.guild.channels.cache.get(caseLogChannelId); const caseLogChannel = pluginData.guild.channels.cache.get(caseLogChannelId as Snowflake);
if (!caseLogChannel || !(caseLogChannel instanceof TextChannel)) return null; if (!caseLogChannel || !(caseLogChannel instanceof TextChannel)) return null;
let result; let result;
@ -23,7 +23,7 @@ export async function postToCaseLogChannel(
if (file != null) { if (file != null) {
content.files = file; content.files = file;
} }
result = await caseLogChannel.send({ ...content, split: false }); result = await caseLogChannel.send({ ...content });
} catch (e) { } catch (e) {
if (isDiscordRESTError(e) && (e.code === 50013 || e.code === 50001)) { if (isDiscordRESTError(e) && (e.code === 50013 || e.code === 50001)) {
pluginData.state.logs.log(LogType.BOT_ALERT, { pluginData.state.logs.log(LogType.BOT_ALERT, {
@ -52,8 +52,8 @@ export async function postCaseToCaseLogChannel(
const [channelId, messageId] = theCase.log_message_id.split("-"); const [channelId, messageId] = theCase.log_message_id.split("-");
try { try {
const channel = pluginData.guild.channels.resolve(channelId) as TextChannel; const channel = pluginData.guild.channels.resolve(channelId as Snowflake) as TextChannel;
await channel.messages.edit(messageId, caseEmbed); await channel.messages.edit(messageId as Snowflake, caseEmbed);
return null; return null;
} catch {} // tslint:disable-line:no-empty } catch {} // tslint:disable-line:no-empty
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { deactivateMentions, disableCodeBlocks } from "knub/dist/helpers"; import { deactivateMentions, disableCodeBlocks } from "knub/dist/helpers";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
@ -14,14 +14,14 @@ export async function censorMessage(
pluginData.state.serverLogs.ignoreLog(LogType.MESSAGE_DELETE, savedMessage.id); pluginData.state.serverLogs.ignoreLog(LogType.MESSAGE_DELETE, savedMessage.id);
try { try {
const resolvedChannel = pluginData.guild.channels.resolve(savedMessage.channel_id) as TextChannel; const resolvedChannel = pluginData.guild.channels.resolve(savedMessage.channel_id as Snowflake) as TextChannel;
await resolvedChannel.messages.delete(savedMessage.id); await resolvedChannel.messages.delete(savedMessage.id as Snowflake);
} catch { } catch {
return; return;
} }
const user = await resolveUser(pluginData.client, savedMessage.user_id); const user = await resolveUser(pluginData.client, savedMessage.user_id);
const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id); const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake);
pluginData.state.serverLogs.log(LogType.CENSOR, { pluginData.state.serverLogs.log(LogType.CENSOR, {
user: stripObjectToScalars(user), user: stripObjectToScalars(user),

View file

@ -1,3 +1,4 @@
import { Collection, Message, Snowflake } from "discord.js";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { isOwner, sendErrorMessage } from "../../../pluginUtils"; import { isOwner, sendErrorMessage } from "../../../pluginUtils";
@ -31,11 +32,10 @@ export const ArchiveChannelCmd = channelArchiverCmd({
async run({ message: msg, args, pluginData }) { async run({ message: msg, args, pluginData }) {
if (!args["attachment-channel"]) { if (!args["attachment-channel"]) {
const confirmed = await confirm( const confirmed = await confirm(msg.channel, msg.author.id, {
msg.channel, content:
msg.author.id,
"No `-attachment-channel` specified. Continue? Attachments will not be available in the log if their message is deleted.", "No `-attachment-channel` specified. Continue? Attachments will not be available in the log if their message is deleted.",
); });
if (!confirmed) { if (!confirmed) {
sendErrorMessage(pluginData, msg.channel, "Canceled"); sendErrorMessage(pluginData, msg.channel, "Canceled");
return; return;
@ -60,7 +60,10 @@ export const ArchiveChannelCmd = channelArchiverCmd({
while (archivedMessages < maxMessagesToArchive) { while (archivedMessages < maxMessagesToArchive) {
const messagesToFetch = Math.min(MAX_MESSAGES_PER_FETCH, maxMessagesToArchive - archivedMessages); const messagesToFetch = Math.min(MAX_MESSAGES_PER_FETCH, maxMessagesToArchive - archivedMessages);
const messages = await args.channel.messages.fetch({ limit: messagesToFetch, before: previousId }); const messages = (await args.channel.messages.fetch({
limit: messagesToFetch,
before: previousId,
})) as Collection<Snowflake, Message>;
if (messages.size === 0) break; if (messages.size === 0) break;
for (const message of messages.values()) { for (const message of messages.values()) {
@ -111,7 +114,6 @@ export const ArchiveChannelCmd = channelArchiverCmd({
name: `archive-${args.channel.name}-${moment.utc().format("YYYY-MM-DD-HH-mm-ss")}.txt`, name: `archive-${args.channel.name}-${moment.utc().format("YYYY-MM-DD-HH-mm-ss")}.txt`,
}, },
], ],
split: false,
}); });
}, },
}); });

View file

@ -22,7 +22,7 @@ export async function rehostAttachment(attachment: MessageAttachment, targetChan
content: `Rehost of attachment ${attachment.id}`, content: `Rehost of attachment ${attachment.id}`,
files: [{ name: attachment.name ? attachment.name : undefined, attachment: await fsp.readFile(downloaded.path) }], files: [{ name: attachment.name ? attachment.name : undefined, attachment: await fsp.readFile(downloaded.path) }],
}; };
const rehostMessage = await targetChannel.send({ content, split: false }); const rehostMessage = await targetChannel.send(content);
return rehostMessage.attachments.values()[0].url; return rehostMessage.attachments.values()[0].url;
} catch { } catch {
return "Failed to rehost attachment"; return "Failed to rehost attachment";

View file

@ -1,4 +1,4 @@
import { Permissions, StageChannel, TextChannel, VoiceChannel } from "discord.js"; import { Permissions, Snowflake, StageChannel, TextChannel, VoiceChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { isDiscordRESTError, MINUTES } from "../../../utils"; import { isDiscordRESTError, MINUTES } from "../../../utils";
@ -51,13 +51,15 @@ export async function handleCompanionPermissions(
try { try {
for (const channelId of permsToDelete) { for (const channelId of permsToDelete) {
const channel = pluginData.guild.channels.cache.get(channelId); const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!channel || !(channel instanceof TextChannel)) continue; if (!channel || !(channel instanceof TextChannel)) continue;
await channel.permissionOverwrites.get(userId)?.delete(`Companion Channel for ${oldChannel!.id} | User Left`); await channel.permissionOverwrites
.get(userId as Snowflake)
?.delete(`Companion Channel for ${oldChannel!.id} | User Left`);
} }
for (const [channelId, permissions] of permsToSet) { for (const [channelId, permissions] of permsToSet) {
const channel = pluginData.guild.channels.cache.get(channelId); const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!channel || !(channel instanceof TextChannel)) continue; if (!channel || !(channel instanceof TextChannel)) continue;
await channel.updateOverwrite(userId, new Permissions(BigInt(permissions)).serialize(), { await channel.updateOverwrite(userId, new Permissions(BigInt(permissions)).serialize(), {
reason: `Companion Channel for ${voiceChannel!.id} | User Joined`, reason: `Companion Channel for ${voiceChannel!.id} | User Joined`,

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { typedGuildCommand } from "knub"; import { typedGuildCommand } from "knub";
import { waitForReply } from "knub/dist/helpers"; import { waitForReply } from "knub/dist/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
@ -73,7 +73,7 @@ export const AddCounterCmd = typedGuildCommand<CountersPluginType>()({
return; return;
} }
const potentialChannel = pluginData.guild.channels.resolve(reply.content); const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) { if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling"); sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
return; return;

View file

@ -28,15 +28,13 @@ export const ResetAllCounterValuesCmd = typedGuildCommand<CountersPluginType>()(
} }
const counterName = counter.name || args.counterName; const counterName = counter.name || args.counterName;
const confirmed = await confirm( const confirmed = await confirm(message.channel, message.author.id, {
message.channel, content: trimMultilineString(`
message.author.id,
trimMultilineString(`
Do you want to reset **ALL** values for counter **${counterName}**? Do you want to reset **ALL** values for counter **${counterName}**?
This will reset the counter for **all** users and channels. This will reset the counter for **all** users and channels.
**Note:** This will *not* trigger any triggers or counter triggers. **Note:** This will *not* trigger any triggers or counter triggers.
`), `),
); });
if (!confirmed) { if (!confirmed) {
sendErrorMessage(pluginData, message.channel, "Cancelled"); sendErrorMessage(pluginData, message.channel, "Cancelled");
return; return;

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { typedGuildCommand } from "knub"; import { typedGuildCommand } from "knub";
import { waitForReply } from "knub/dist/helpers"; import { waitForReply } from "knub/dist/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
@ -68,7 +68,7 @@ export const ResetCounterCmd = typedGuildCommand<CountersPluginType>()({
return; return;
} }
const potentialChannel = pluginData.guild.channels.resolve(reply.content); const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) { if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling"); sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
return; return;

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { typedGuildCommand } from "knub"; import { typedGuildCommand } from "knub";
import { waitForReply } from "knub/dist/helpers"; import { waitForReply } from "knub/dist/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
@ -73,7 +73,7 @@ export const SetCounterCmd = typedGuildCommand<CountersPluginType>()({
return; return;
} }
const potentialChannel = pluginData.guild.channels.resolve(reply.content); const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) { if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling"); sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
return; return;

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { typedGuildCommand } from "knub"; import { typedGuildCommand } from "knub";
import { waitForReply } from "knub/dist/helpers"; import { waitForReply } from "knub/dist/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
@ -67,7 +67,7 @@ export const ViewCounterCmd = typedGuildCommand<CountersPluginType>()({
return; return;
} }
const potentialChannel = pluginData.guild.channels.resolve(reply.content); const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) { if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling"); sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
return; return;

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { convertDelayStringToMS, noop, tDelayString } from "../../../utils"; import { convertDelayStringToMS, noop, tDelayString } from "../../../utils";
@ -18,7 +19,7 @@ export async function makeRoleMentionableAction(
event: TCustomEvent, event: TCustomEvent,
eventData: any, eventData: any,
) { ) {
const role = pluginData.guild.roles.cache.get(action.role); const role = pluginData.guild.roles.cache.get(action.role as Snowflake);
if (!role) { if (!role) {
throw new ActionError(`Unknown role: ${role}`); throw new ActionError(`Unknown role: ${role}`);
} }

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { ActionError } from "../ActionError"; import { ActionError } from "../ActionError";
@ -16,7 +17,7 @@ export async function makeRoleUnmentionableAction(
event: TCustomEvent, event: TCustomEvent,
eventData: any, eventData: any,
) { ) {
const role = pluginData.guild.roles.cache.get(action.role); const role = pluginData.guild.roles.cache.get(action.role as Snowflake);
if (!role) { if (!role) {
throw new ActionError(`Unknown role: ${role}`); throw new ActionError(`Unknown role: ${role}`);
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { renderTemplate } from "../../../templateFormatter"; import { renderTemplate } from "../../../templateFormatter";
@ -18,7 +18,7 @@ export async function messageAction(
values: any, values: any,
) { ) {
const targetChannelId = await renderTemplate(action.channel, values, false); const targetChannelId = await renderTemplate(action.channel, values, false);
const targetChannel = pluginData.guild.channels.cache.get(targetChannelId); const targetChannel = pluginData.guild.channels.cache.get(targetChannelId as Snowflake);
if (!targetChannel) throw new ActionError("Unknown target channel"); if (!targetChannel) throw new ActionError("Unknown target channel");
if (!(targetChannel instanceof TextChannel)) throw new ActionError("Target channel is not a text channel"); if (!(targetChannel instanceof TextChannel)) throw new ActionError("Target channel is not a text channel");

View file

@ -1,4 +1,4 @@
import { VoiceChannel } from "discord.js"; import { Snowflake, VoiceChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { canActOn } from "../../../pluginUtils"; import { canActOn } from "../../../pluginUtils";
@ -30,7 +30,7 @@ export async function moveToVoiceChannelAction(
} }
const targetChannelId = await renderTemplate(action.channel, values, false); const targetChannelId = await renderTemplate(action.channel, values, false);
const targetChannel = pluginData.guild.channels.cache.get(targetChannelId); const targetChannel = pluginData.guild.channels.cache.get(targetChannelId as Snowflake);
if (!targetChannel) throw new ActionError("Unknown target channel"); if (!targetChannel) throw new ActionError("Unknown target channel");
if (!(targetChannel instanceof VoiceChannel)) throw new ActionError("Target channel is not a voice channel"); if (!(targetChannel instanceof VoiceChannel)) throw new ActionError("Target channel is not a voice channel");

View file

@ -1,3 +1,4 @@
import { Snowflake, TextChannel } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { ActionError } from "../ActionError"; import { ActionError } from "../ActionError";
@ -24,7 +25,7 @@ export async function setChannelPermissionOverridesAction(
event: TCustomEvent, event: TCustomEvent,
eventData: any, eventData: any,
) { ) {
const channel = pluginData.guild.channels.cache.get(action.channel); const channel = pluginData.guild.channels.cache.get(action.channel as Snowflake) as TextChannel;
if (!channel) { if (!channel) {
throw new ActionError(`Unknown channel: ${action.channel}`); throw new ActionError(`Unknown channel: ${action.channel}`);
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { locateUserEvt } from "../types"; import { locateUserEvt } from "../types";
import { sendAlerts } from "../utils/sendAlerts"; import { sendAlerts } from "../utils/sendAlerts";
@ -17,7 +17,7 @@ export const VoiceStateUpdateAlertEvt = locateUserEvt({
const voiceChannel = meta.args.oldState.channel!; const voiceChannel = meta.args.oldState.channel!;
triggeredAlerts.forEach(alert => { triggeredAlerts.forEach(alert => {
const txtChannel = meta.pluginData.guild.channels.resolve(alert.channel_id) as TextChannel; const txtChannel = meta.pluginData.guild.channels.resolve(alert.channel_id as Snowflake) as TextChannel;
txtChannel.send( txtChannel.send(
`🔴 <@!${alert.requestor_id}> the user <@!${alert.user_id}> disconnected out of \`<#!${voiceChannel.id}>\``, `🔴 <@!${alert.requestor_id}> the user <@!${alert.user_id}> disconnected out of \`<#!${voiceChannel.id}>\``,
); );

View file

@ -1,4 +1,4 @@
import { GuildMember, TextChannel } from "discord.js"; import { GuildMember, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { LocateUserPluginType } from "../types"; import { LocateUserPluginType } from "../types";
@ -9,7 +9,7 @@ export async function moveMember(
target: GuildMember, target: GuildMember,
errorChannel: TextChannel, errorChannel: TextChannel,
) { ) {
const modMember: GuildMember = await pluginData.guild.members.fetch(toMoveID); const modMember: GuildMember = await pluginData.guild.members.fetch(toMoveID as Snowflake);
if (modMember.voice.channelID != null) { if (modMember.voice.channelID != null) {
try { try {
await modMember.edit({ await modMember.edit({

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { resolveMember } from "../../../utils"; import { resolveMember } from "../../../utils";
import { LocateUserPluginType } from "../types"; import { LocateUserPluginType } from "../types";
@ -12,7 +12,7 @@ export async function sendAlerts(pluginData: GuildPluginData<LocateUserPluginTyp
triggeredAlerts.forEach(alert => { triggeredAlerts.forEach(alert => {
const prepend = `<@!${alert.requestor_id}>, an alert requested by you has triggered!\nReminder: \`${alert.body}\`\n`; const prepend = `<@!${alert.requestor_id}>, an alert requested by you has triggered!\nReminder: \`${alert.body}\`\n`;
const txtChannel = pluginData.guild.channels.resolve(alert.channel_id) as TextChannel; const txtChannel = pluginData.guild.channels.resolve(alert.channel_id as Snowflake) as TextChannel;
sendWhere(pluginData, member, txtChannel, prepend); sendWhere(pluginData, member, txtChannel, prepend);
if (alert.active) { if (alert.active) {
moveMember(pluginData, alert.requestor_id, member, txtChannel); moveMember(pluginData, alert.requestor_id, member, txtChannel);

View file

@ -28,7 +28,6 @@ export async function sendWhere(
channel.send({ channel.send({
content: prepend + `<@${member.id}> is in the following channel: \`${voice.name}\` ${getInviteLink(invite)}`, content: prepend + `<@${member.id}> is in the following channel: \`${voice.name}\` ${getInviteLink(invite)}`,
allowedMentions: { parse: ["users"] }, allowedMentions: { parse: ["users"] },
split: false,
}); });
} }
} }

View file

@ -1,4 +1,4 @@
import { MessageMentionTypes, TextChannel } from "discord.js"; import { MessageMentionTypes, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -19,7 +19,7 @@ export async function log(pluginData: GuildPluginData<LogsPluginType>, type: Log
const typeStr = LogType[type]; const typeStr = LogType[type];
logChannelLoop: for (const [channelId, opts] of Object.entries(logChannels)) { logChannelLoop: for (const [channelId, opts] of Object.entries(logChannels)) {
const channel = pluginData.guild.channels.cache.get(channelId); const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!channel || !(channel instanceof TextChannel)) continue; if (!channel || !(channel instanceof TextChannel)) continue;
if ((opts.include && opts.include.includes(typeStr)) || (opts.exclude && !opts.exclude.includes(typeStr))) { if ((opts.include && opts.include.includes(typeStr)) || (opts.exclude && !opts.exclude.includes(typeStr))) {
@ -45,7 +45,7 @@ export async function log(pluginData: GuildPluginData<LogsPluginType>, type: Log
if (opts.excluded_roles) { if (opts.excluded_roles) {
for (const value of Object.values(data || {})) { for (const value of Object.values(data || {})) {
if (value instanceof SavedMessage) { if (value instanceof SavedMessage) {
const member = pluginData.guild.members.cache.get(value.user_id); const member = pluginData.guild.members.cache.get(value.user_id as Snowflake);
for (const role of member?.roles.cache || []) { for (const role of member?.roles.cache || []) {
if (opts.excluded_roles.includes(role[0])) { if (opts.excluded_roles.includes(role[0])) {
continue logChannelLoop; continue logChannelLoop;

View file

@ -1,4 +1,4 @@
import { MessageAttachment } from "discord.js"; import { MessageAttachment, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
@ -9,7 +9,7 @@ import { FORMAT_NO_TIMESTAMP, LogsPluginType } from "../types";
export async function onMessageDelete(pluginData: GuildPluginData<LogsPluginType>, savedMessage: SavedMessage) { export async function onMessageDelete(pluginData: GuildPluginData<LogsPluginType>, savedMessage: SavedMessage) {
const user = await resolveUser(pluginData.client, savedMessage.user_id); const user = await resolveUser(pluginData.client, savedMessage.user_id);
const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id); const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake);
if (user) { if (user) {
// Replace attachment URLs with media URLs // Replace attachment URLs with media URLs

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -5,7 +6,7 @@ import { getBaseUrl } from "../../../pluginUtils";
import { LogsPluginType } from "../types"; import { LogsPluginType } from "../types";
export async function onMessageDeleteBulk(pluginData: GuildPluginData<LogsPluginType>, savedMessages: SavedMessage[]) { export async function onMessageDeleteBulk(pluginData: GuildPluginData<LogsPluginType>, savedMessages: SavedMessage[]) {
const channel = pluginData.guild.channels.cache.get(savedMessages[0].channel_id); const channel = pluginData.guild.channels.cache.get(savedMessages[0].channel_id as Snowflake);
const archiveId = await pluginData.state.archives.createFromSavedMessages(savedMessages, pluginData.guild); const archiveId = await pluginData.state.archives.createFromSavedMessages(savedMessages, pluginData.guild);
const archiveUrl = pluginData.state.archives.getUrl(getBaseUrl(pluginData), archiveId); const archiveUrl = pluginData.state.archives.getUrl(getBaseUrl(pluginData), archiveId);
const authorIds = Array.from(new Set(savedMessages.map(item => `\`${item.user_id}\``))).join(", "); const authorIds = Array.from(new Set(savedMessages.map(item => `\`${item.user_id}\``))).join(", ");

View file

@ -1,4 +1,4 @@
import { MessageEmbed } from "discord.js"; import { MessageEmbed, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import cloneDeep from "lodash.clonedeep"; import cloneDeep from "lodash.clonedeep";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
@ -47,7 +47,7 @@ export async function onMessageUpdate(
} }
const user = await resolveUser(pluginData.client, savedMessage.user_id); const user = await resolveUser(pluginData.client, savedMessage.user_id);
const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id); const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake);
pluginData.state.guildLogs.log(LogType.MESSAGE_EDIT, { pluginData.state.guildLogs.log(LogType.MESSAGE_EDIT, {
user: stripObjectToScalars(user), user: stripObjectToScalars(user),

View file

@ -1,4 +1,4 @@
import { Message, TextChannel } from "discord.js"; import { Message, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { MessageSaverPluginType } from "./types"; import { MessageSaverPluginType } from "./types";
@ -15,7 +15,7 @@ export async function saveMessagesToDB(
let thisMsg: Message; let thisMsg: Message;
try { try {
thisMsg = await channel.messages.fetch(id); thisMsg = await channel.messages.fetch(id as Snowflake);
if (!thisMsg) { if (!thisMsg) {
failed.push(id); failed.push(id);

View file

@ -71,7 +71,7 @@ export const CasesModCmd = modActionsCmd({
], ],
}; };
return { embed }; return { embeds: [embed] };
}, },
{ {
limitToUserId: msg.author.id, limitToUserId: msg.author.id,

View file

@ -12,13 +12,13 @@ import { modActionsCmd } from "../types";
const opts = { const opts = {
expand: ct.bool({ option: true, isSwitch: true, shortcut: "e" }), expand: ct.bool({ option: true, isSwitch: true, shortcut: "e" }),
hidden: ct.bool({ option: true, isSwitch: true, shortcut: "h" }), hidden: ct.bool({ option: true, isSwitch: true, shortcut: "h" }),
reverseFilters: ct.switchOption({ shortcut: "r" }), reverseFilters: ct.switchOption({ def: false, shortcut: "r" }),
notes: ct.switchOption({ shortcut: "n" }), notes: ct.switchOption({ def: false, shortcut: "n" }),
warns: ct.switchOption({ shortcut: "w" }), warns: ct.switchOption({ def: false, shortcut: "w" }),
mutes: ct.switchOption({ shortcut: "m" }), mutes: ct.switchOption({ def: false, shortcut: "m" }),
unmutes: ct.switchOption({ shortcut: "um" }), unmutes: ct.switchOption({ def: false, shortcut: "um" }),
bans: ct.switchOption({ shortcut: "b" }), bans: ct.switchOption({ def: false, shortcut: "b" }),
unbans: ct.switchOption({ shortcut: "ub" }), unbans: ct.switchOption({ def: false, shortcut: "ub" }),
}; };
export const CasesUserCmd = modActionsCmd({ export const CasesUserCmd = modActionsCmd({
@ -127,7 +127,7 @@ export const CasesUserCmd = modActionsCmd({
], ],
}; };
msg.channel.send({ embed }); msg.channel.send({ embeds: [embed] });
} }
} }
} }

View file

@ -21,7 +21,7 @@ export const DeleteCaseCmd = modActionsCmd({
signature: { signature: {
caseNumber: ct.number({ rest: true }), caseNumber: ct.number({ rest: true }),
force: ct.switchOption({ shortcut: "f" }), force: ct.switchOption({ def: false, shortcut: "f" }),
}, },
async run({ pluginData, message, args }) { async run({ pluginData, message, args }) {
@ -49,8 +49,8 @@ export const DeleteCaseCmd = modActionsCmd({
const cases = pluginData.getPlugin(CasesPlugin); const cases = pluginData.getPlugin(CasesPlugin);
const embedContent = await cases.getCaseEmbed(theCase); const embedContent = await cases.getCaseEmbed(theCase);
message.channel.send({ message.channel.send({
...embedContent,
content: "Delete the following case? Answer 'Yes' to continue, 'No' to cancel.", content: "Delete the following case? Answer 'Yes' to continue, 'No' to cancel.",
embed: embedContent.embed,
}); });
const reply = await helpers.waitForReply( const reply = await helpers.waitForReply(

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -66,7 +67,7 @@ export const ForcebanCmd = modActionsCmd({
try { try {
// FIXME: Use banUserId()? // FIXME: Use banUserId()?
await pluginData.guild.bans.create(user.id, { await pluginData.guild.bans.create(user.id as Snowflake, {
days: 1, days: 1,
reason: reason != null ? encodeURIComponent(reason) : undefined, reason: reason != null ? encodeURIComponent(reason) : undefined,
}); });

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -49,7 +50,7 @@ export const UnbanCmd = modActionsCmd({
try { try {
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id); ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
await pluginData.guild.bans.remove(user.id, reason != null ? encodeURIComponent(reason) : undefined); await pluginData.guild.bans.remove(user.id as Snowflake, reason != null ? encodeURIComponent(reason) : undefined);
} catch { } catch {
sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?"); sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?");
return; return;

View file

@ -1,4 +1,4 @@
import { Permissions, TextChannel } from "discord.js"; import { Permissions, Snowflake, TextChannel } from "discord.js";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { resolveMember } from "../../../utils"; import { resolveMember } from "../../../utils";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions"; import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
@ -22,7 +22,7 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt({
const logs = pluginData.getPlugin(LogsPlugin); const logs = pluginData.getPlugin(LogsPlugin);
if (actions.length) { if (actions.length) {
const alertChannel = pluginData.guild.channels.cache.get(alertChannelId); const alertChannel = pluginData.guild.channels.cache.get(alertChannelId as Snowflake);
if (!alertChannel) { if (!alertChannel) {
logs.log(LogType.BOT_ALERT, { logs.log(LogType.BOT_ALERT, {
body: `Unknown \`alert_channel\` configured for \`mod_actions\`: \`${alertChannelId}\``, body: `Unknown \`alert_channel\` configured for \`mod_actions\`: \`${alertChannelId}\``,

View file

@ -1,4 +1,4 @@
import { DiscordAPIError, User } from "discord.js"; import { DiscordAPIError, Snowflake, User } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
@ -77,7 +77,7 @@ export async function banUserId(
ignoreEvent(pluginData, IgnoredEventType.Ban, userId); ignoreEvent(pluginData, IgnoredEventType.Ban, userId);
try { try {
const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1)); const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1));
await pluginData.guild.bans.create(userId, { await pluginData.guild.bans.create(userId as Snowflake, {
days: deleteMessageDays, days: deleteMessageDays,
reason: reason != null ? encodeURIComponent(reason) : undefined, reason: reason != null ? encodeURIComponent(reason) : undefined,
}); });

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { UserNotificationMethod } from "../../../utils"; import { UserNotificationMethod } from "../../../utils";
import { ModActionsPluginType } from "../types"; import { ModActionsPluginType } from "../types";
@ -15,7 +15,7 @@ export function getDefaultContactMethods(
} }
if (config[`message_on_${type}`] && config.message_channel) { if (config[`message_on_${type}`] && config.message_channel) {
const channel = pluginData.guild.channels.cache.get(config.message_channel); const channel = pluginData.guild.channels.cache.get(config.message_channel as Snowflake);
if (channel instanceof TextChannel) { if (channel instanceof TextChannel) {
methods.push({ methods.push({
type: "channel", type: "channel",

View file

@ -1,4 +1,4 @@
import { Permissions } from "discord.js"; import { Permissions, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { isDiscordHTTPError, isDiscordRESTError, SECONDS, sleep } from "../../../utils"; import { isDiscordHTTPError, isDiscordRESTError, SECONDS, sleep } from "../../../utils";
@ -21,7 +21,7 @@ export async function isBanned(
try { try {
const potentialBan = await Promise.race([ const potentialBan = await Promise.race([
pluginData.guild.bans.fetch({ user: userId }).catch(() => null), pluginData.guild.bans.fetch({ user: userId as Snowflake }).catch(() => null),
sleep(timeout), sleep(timeout),
]); ]);
return potentialBan != null; return potentialBan != null;

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
@ -30,7 +31,10 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
); );
try { try {
ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id); ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id);
await pluginData.guild.bans.remove(tempban.user_id, reason != null ? encodeURIComponent(reason) : undefined); await pluginData.guild.bans.remove(
tempban.user_id as Snowflake,
reason != null ? encodeURIComponent(reason) : undefined,
);
} catch (e) { } catch (e) {
pluginData.state.serverLogs.log(LogType.BOT_ALERT, { pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`, body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`,

View file

@ -1,4 +1,4 @@
import { GuildMember } from "discord.js"; import { GuildMember, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -75,7 +75,7 @@ export async function warnMember(
noteDetails: notifyResult.text ? [ucfirst(notifyResult.text)] : [], noteDetails: notifyResult.text ? [ucfirst(notifyResult.text)] : [],
}); });
const mod = await pluginData.guild.members.fetch(modId); const mod = await pluginData.guild.members.fetch(modId as Snowflake);
pluginData.state.serverLogs.log(LogType.MEMBER_WARN, { pluginData.state.serverLogs.log(LogType.MEMBER_WARN, {
mod: stripObjectToScalars(mod), mod: stripObjectToScalars(mod),
member: stripObjectToScalars(member, ["user", "roles"]), member: stripObjectToScalars(member, ["user", "roles"]),

View file

@ -1,4 +1,4 @@
import { GuildMember } from "discord.js"; import { GuildMember, Snowflake } from "discord.js";
import { EventEmitter } from "events"; import { EventEmitter } from "events";
import { GuildArchives } from "../../data/GuildArchives"; import { GuildArchives } from "../../data/GuildArchives";
import { GuildCases } from "../../data/GuildCases"; import { GuildCases } from "../../data/GuildCases";
@ -95,7 +95,7 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
hasMutedRole(pluginData) { hasMutedRole(pluginData) {
return (member: GuildMember) => { return (member: GuildMember) => {
const muteRole = pluginData.config.get().mute_role; 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;
}; };
}, },

View file

@ -1,4 +1,4 @@
import { User } from "discord.js"; import { Snowflake, User } from "discord.js";
import { sendSuccessMessage } from "../../../pluginUtils"; import { sendSuccessMessage } from "../../../pluginUtils";
import { mutesCmd } from "../types"; import { mutesCmd } from "../types";
@ -19,7 +19,7 @@ export const ClearBannedMutesCmd = mutesCmd({
let cleared = 0; let cleared = 0;
for (const mute of activeMutes) { 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); await pluginData.state.mutes.clear(mute.user_id);
cleared++; cleared++;
} }

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { sendSuccessMessage } from "../../../pluginUtils"; import { sendSuccessMessage } from "../../../pluginUtils";
import { resolveMember } from "../../../utils"; import { resolveMember } from "../../../utils";
import { mutesCmd } from "../types"; import { mutesCmd } from "../types";
@ -19,7 +20,7 @@ export const ClearMutesWithoutRoleCmd = mutesCmd({
const member = await resolveMember(pluginData.client, pluginData.guild, mute.user_id); const member = await resolveMember(pluginData.client, pluginData.guild, mute.user_id);
if (!member) continue; 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); await pluginData.state.mutes.clear(mute.user_id);
cleared++; cleared++;
} }

View file

@ -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 moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { humanizeDurationShort } from "../../../humanizeDurationShort"; import { humanizeDurationShort } from "../../../humanizeDurationShort";
@ -16,9 +16,9 @@ export const MutesCmd = mutesCmd({
shortcut: "a", shortcut: "a",
}), }),
left: ct.switchOption({ shortcut: "l" }), left: ct.switchOption({ def: false, shortcut: "l" }),
manual: ct.switchOption({ shortcut: "m" }), manual: ct.switchOption({ def: false, shortcut: "m" }),
export: ct.switchOption({ shortcut: "e" }), export: ct.switchOption({ def: false, shortcut: "e" }),
}, },
async run({ pluginData, message: msg, args }) { async run({ pluginData, message: msg, args }) {
@ -53,7 +53,7 @@ export const MutesCmd = mutesCmd({
if (muteRole) { if (muteRole) {
pluginData.guild.members.cache.forEach(member => { pluginData.guild.members.cache.forEach(member => {
if (muteUserIds.has(member.id)) return; 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()); const muteCasesById = muteCases.reduce((map, c) => map.set(c.id, c), new Map());
lines = filteredMutes.map(mute => { 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 username = user ? `${user.username}#${user.discriminator}` : "Unknown#0000";
const theCase = muteCasesById.get(mute.case_id); const theCase = muteCasesById.get(mute.case_id);
const caseName = theCase ? `Case #${theCase.case_number}` : "No case"; const caseName = theCase ? `Case #${theCase.case_number}` : "No case";
@ -199,7 +199,6 @@ export const MutesCmd = mutesCmd({
new MessageButton() new MessageButton()
.setStyle("SECONDARY") .setStyle("SECONDARY")
.setEmoji("⬅") .setEmoji("⬅")
.setType("BUTTON")
.setCustomID(`previousButton:${idMod}`), .setCustomID(`previousButton:${idMod}`),
); );
@ -207,7 +206,6 @@ export const MutesCmd = mutesCmd({
new MessageButton() new MessageButton()
.setStyle("SECONDARY") .setStyle("SECONDARY")
.setEmoji("➡") .setEmoji("➡")
.setType("BUTTON")
.setCustomID(`nextButton:${idMod}`), .setCustomID(`nextButton:${idMod}`),
); );
@ -215,13 +213,14 @@ export const MutesCmd = mutesCmd({
await listMessage.edit({ components: [row] }); await listMessage.edit({ components: [row] });
const filter = (iac: MessageComponentInteraction) => iac.message.id === listMessage.id; const filter = (iac: MessageComponentInteraction) => iac.message.id === listMessage.id;
const collector = listMessage.createMessageComponentInteractionCollector(filter, { const collector = listMessage.createMessageComponentInteractionCollector({
filter,
time: stopCollectionDebounce, time: stopCollectionDebounce,
}); });
collector.on("collect", async (interaction: MessageComponentInteraction) => { collector.on("collect", async (interaction: MessageComponentInteraction) => {
if (msg.author.id !== interaction.user.id) { 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 { } else {
collector.resetTimer(); collector.resetTimer();
if (interaction.customID === `previousButton:${idMod}` && currentPage > 1) { if (interaction.customID === `previousButton:${idMod}` && currentPage > 1) {

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { resolveMember, stripObjectToScalars, UnknownUser } from "../../../utils"; import { resolveMember, stripObjectToScalars, UnknownUser } from "../../../utils";
@ -23,7 +24,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
newRoles = newRoles =
muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles; muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles;
for (const toRestore of mute.roles_to_restore) { 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); await member.roles.set(newRoles);
} }

View file

@ -1,8 +1,8 @@
import { GuildMember } from "discord.js"; import { GuildMember, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { MutesPluginType } from "../types"; import { MutesPluginType } from "../types";
export function memberHasMutedRole(pluginData: GuildPluginData<MutesPluginType>, member: GuildMember): boolean { export function memberHasMutedRole(pluginData: GuildPluginData<MutesPluginType>, member: GuildMember): boolean {
const muteRole = pluginData.config.get().mute_role; 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;
} }

View file

@ -1,4 +1,4 @@
import { TextChannel, User } from "discord.js"; import { Snowflake, TextChannel, User } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
@ -86,7 +86,7 @@ export async function muteUser(
} }
// Apply mute role if it's missing // Apply mute role if it's missing
if (!currentUserRoles.includes(muteRole)) { if (!currentUserRoles.includes(muteRole as Snowflake)) {
try { try {
await member.roles.add(muteRole); await member.roles.add(muteRole);
} catch (e) { } catch (e) {
@ -125,7 +125,7 @@ export async function muteUser(
if (moveToVoiceChannel || cfg.kick_from_voice_channel) { 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 // TODO: Add back the voiceState check once we figure out how to get voice state for guild members that are loaded on-demand
try { try {
await member.edit({ channel: moveToVoiceChannel }); await member.edit({ channel: moveToVoiceChannel as Snowflake });
} catch {} // tslint:disable-line } catch {} // tslint:disable-line
} }
} }
@ -172,7 +172,8 @@ export async function muteUser(
} }
const useChannel = existingMute ? config.message_on_update : config.message_on_mute; 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) { if (useChannel && channel instanceof TextChannel) {
contactMethods.push({ type: "channel", channel }); contactMethods.push({ type: "channel", channel });
} }

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
@ -35,7 +36,7 @@ export async function unmuteUser(
const lock = await pluginData.locks.acquire(memberRolesLock(member)); const lock = await pluginData.locks.acquire(memberRolesLock(member));
const muteRole = pluginData.config.get().mute_role; 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); await member.roles.remove(muteRole);
} }
if (existingMute?.roles_to_restore) { if (existingMute?.roles_to_restore) {
@ -43,7 +44,7 @@ export async function unmuteUser(
let newRoles: string[] = member.roles.cache.keyArray(); let newRoles: string[] = member.roles.cache.keyArray();
newRoles = muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles; newRoles = muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles;
for (const toRestore of existingMute.roles_to_restore) { 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); await member.roles.set(newRoles);
} }
@ -83,7 +84,7 @@ export async function unmuteUser(
}); });
// Log the action // Log the action
const mod = pluginData.client.users.fetch(modId); const mod = pluginData.client.users.fetch(modId as Snowflake);
if (unmuteTime) { if (unmuteTime) {
pluginData.state.serverLogs.log(LogType.MEMBER_TIMED_UNMUTE, { pluginData.state.serverLogs.log(LogType.MEMBER_TIMED_UNMUTE, {
mod: stripObjectToScalars(mod), mod: stripObjectToScalars(mod),

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { PingableRole } from "../../../data/entities/PingableRole"; import { PingableRole } from "../../../data/entities/PingableRole";
import { PingableRolesPluginType } from "../types"; import { PingableRolesPluginType } from "../types";
@ -7,7 +8,7 @@ export function disablePingableRoles(
pingableRoles: PingableRole[], pingableRoles: PingableRole[],
) { ) {
for (const pingableRole of pingableRoles) { for (const pingableRole of pingableRoles) {
const role = pluginData.guild.roles.cache.get(pingableRole.role_id); const role = pluginData.guild.roles.cache.get(pingableRole.role_id as Snowflake);
if (!role) continue; if (!role) continue;
role.edit( role.edit(

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { PingableRole } from "../../../data/entities/PingableRole"; import { PingableRole } from "../../../data/entities/PingableRole";
import { PingableRolesPluginType } from "../types"; import { PingableRolesPluginType } from "../types";
@ -7,7 +8,7 @@ export function enablePingableRoles(
pingableRoles: PingableRole[], pingableRoles: PingableRole[],
) { ) {
for (const pingableRole of pingableRoles) { for (const pingableRole of pingableRoles) {
const role = pluginData.guild.roles.cache.get(pingableRole.role_id); const role = pluginData.guild.roles.cache.get(pingableRole.role_id as Snowflake);
if (!role) continue; if (!role) continue;
role.edit( role.edit(

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { postCmd } from "../types"; import { postCmd } from "../types";
@ -25,9 +25,12 @@ export const EditCmd = postCmd({
return; return;
} }
(pluginData.guild.channels.cache.get(savedMessage.channel_id) as TextChannel).messages.edit(savedMessage.id, { (pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake) as TextChannel).messages.edit(
savedMessage.id as Snowflake,
{
content: formatContent(args.content), content: formatContent(args.content),
}); },
);
sendSuccessMessage(pluginData, msg.channel, "Message edited"); sendSuccessMessage(pluginData, msg.channel, "Message edited");
}, },
}); });

View file

@ -1,4 +1,4 @@
import { MessageEmbed, TextChannel } from "discord.js"; import { MessageEmbed, Snowflake, TextChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { trimLines } from "../../../utils"; import { trimLines } from "../../../utils";
@ -47,9 +47,12 @@ export const EditEmbedCmd = postCmd({
if (content) embed.description = formatContent(content); if (content) embed.description = formatContent(content);
if (color) embed.color = color; if (color) embed.color = color;
(pluginData.guild.channels.cache.get(savedMessage.channel_id) as TextChannel).messages.edit(savedMessage.id, { (pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake) as TextChannel).messages.edit(
embed, savedMessage.id as Snowflake,
}); {
embeds: [embed],
},
);
await sendSuccessMessage(pluginData, msg.channel, "Embed edited"); await sendSuccessMessage(pluginData, msg.channel, "Embed edited");
if (args.content) { if (args.content) {

View file

@ -38,7 +38,7 @@ export async function postMessage(
}; };
} }
const createdMsg = await channel.send(content, file); const createdMsg = await channel.send({ ...content, files: [file] });
pluginData.state.savedMessages.setPermanent(createdMsg.id); pluginData.state.savedMessages.setPermanent(createdMsg.id);
if (downloadedAttachment) { if (downloadedAttachment) {

View file

@ -1,4 +1,4 @@
import { TextChannel, User } from "discord.js"; import { Snowflake, TextChannel, User } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -12,10 +12,10 @@ const SCHEDULED_POST_CHECK_INTERVAL = 5 * SECONDS;
export async function scheduledPostLoop(pluginData: GuildPluginData<PostPluginType>) { export async function scheduledPostLoop(pluginData: GuildPluginData<PostPluginType>) {
const duePosts = await pluginData.state.scheduledPosts.getDueScheduledPosts(); const duePosts = await pluginData.state.scheduledPosts.getDueScheduledPosts();
for (const post of duePosts) { for (const post of duePosts) {
const channel = pluginData.guild.channels.cache.get(post.channel_id); const channel = pluginData.guild.channels.cache.get(post.channel_id as Snowflake);
if (channel instanceof TextChannel) { if (channel instanceof TextChannel) {
const [username, discriminator] = post.author_name.split("#"); const [username, discriminator] = post.author_name.split("#");
const author: User = (await pluginData.client.users.fetch(post.author_id)) || { const author: User = (await pluginData.client.users.fetch(post.author_id as Snowflake)) || {
id: post.author_id, id: post.author_id,
username, username,
discriminator, discriminator,

View file

@ -1,4 +1,4 @@
import { Message } from "discord.js"; import { Message, Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { isDiscordRESTError } from "../../../utils"; import { isDiscordRESTError } from "../../../utils";
@ -23,7 +23,7 @@ export const ClearReactionRolesCmd = reactionRolesCmd({
let targetMessage: Message; let targetMessage: Message;
try { try {
targetMessage = await args.message.channel.messages.fetch(args.message.messageId); targetMessage = await args.message.channel.messages.fetch(args.message.messageId as Snowflake);
} catch (err) { } catch (err) {
if (isDiscordRESTError(err) && err.code === 50001) { if (isDiscordRESTError(err) && err.code === 50001) {
sendErrorMessage(pluginData, msg.channel, "Missing access to the specified message"); sendErrorMessage(pluginData, msg.channel, "Missing access to the specified message");

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { canUseEmoji, isDiscordRESTError, isValidEmoji, noop, trimPluginDescription } from "../../../utils"; import { canUseEmoji, isDiscordRESTError, isValidEmoji, noop, trimPluginDescription } from "../../../utils";
@ -39,7 +40,7 @@ export const InitReactionRolesCmd = reactionRolesCmd({
let targetMessage; let targetMessage;
try { try {
targetMessage = await args.message.channel.messages.fetch(args.message.messageId).catch(noop); targetMessage = await args.message.channel.messages.fetch(args.message.messageId as Snowflake).catch(noop);
} catch (e) { } catch (e) {
if (isDiscordRESTError(e)) { if (isDiscordRESTError(e)) {
sendErrorMessage(pluginData, msg.channel, `Error ${e.code} while getting message: ${e.message}`); sendErrorMessage(pluginData, msg.channel, `Error ${e.code} while getting message: ${e.message}`);
@ -94,7 +95,7 @@ export const InitReactionRolesCmd = reactionRolesCmd({
return; return;
} }
if (!pluginData.guild.roles.cache.has(pair[1])) { if (!pluginData.guild.roles.cache.has(pair[1] as Snowflake)) {
sendErrorMessage(pluginData, msg.channel, `Unknown role ${pair[1]}`); sendErrorMessage(pluginData, msg.channel, `Unknown role ${pair[1]}`);
return; return;
} }

View file

@ -1,4 +1,4 @@
import { MessageActionRow, MessageButton, TextChannel } from "discord.js"; import { MessageActionRow, MessageButton, Snowflake, TextChannel } from "discord.js";
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { reactionRolesCmd } from "../types"; import { reactionRolesCmd } from "../types";
@ -38,12 +38,11 @@ export const PostButtonRolesCmd = reactionRolesCmd({
const btn = new MessageButton() const btn = new MessageButton()
.setLabel(button.label ?? "") .setLabel(button.label ?? "")
.setStyle(button.style ?? "PRIMARY") .setStyle(button.style ?? "PRIMARY")
.setType("BUTTON")
.setCustomID(customId) .setCustomID(customId)
.setDisabled(button.disabled ?? false); .setDisabled(button.disabled ?? false);
if (button.emoji) { if (button.emoji) {
const emo = pluginData.client.emojis.resolve(button.emoji) ?? button.emoji; const emo = pluginData.client.emojis.resolve(button.emoji as Snowflake) ?? button.emoji;
btn.setEmoji(emo); btn.setEmoji(emo);
} }

View file

@ -87,5 +87,5 @@ export const ButtonInteractionEvt = reactionRolesEvt({
}); });
async function sendEphemeralReply(interaction: MessageComponentInteraction, message: string) { async function sendEphemeralReply(interaction: MessageComponentInteraction, message: string) {
await interaction.reply(message, { ephemeral: true }); await interaction.reply({ content: message, ephemeral: true });
} }

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
import { resolveMember } from "../../../utils"; import { resolveMember } from "../../../utils";
@ -25,8 +26,8 @@ export async function addMemberPendingRoleChange(
if (member) { if (member) {
const newRoleIds = new Set(member.roles.cache.keyArray()); const newRoleIds = new Set(member.roles.cache.keyArray());
for (const change of newPendingRoleChangeObj.changes) { for (const change of newPendingRoleChangeObj.changes) {
if (change.mode === "+") newRoleIds.add(change.roleId); if (change.mode === "+") newRoleIds.add(change.roleId as Snowflake);
else newRoleIds.delete(change.roleId); else newRoleIds.delete(change.roleId as Snowflake);
} }
try { try {

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { ReactionRole } from "../../../data/entities/ReactionRole"; import { ReactionRole } from "../../../data/entities/ReactionRole";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -17,7 +17,7 @@ export async function applyReactionRoleReactionsToMessage(
messageId: string, messageId: string,
reactionRoles: ReactionRole[], reactionRoles: ReactionRole[],
): Promise<string[] | undefined> { ): Promise<string[] | undefined> {
const channel = pluginData.guild.channels.cache.get(channelId) as TextChannel; const channel = pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel;
if (!channel) return; if (!channel) return;
const errors: string[] = []; const errors: string[] = [];
@ -25,7 +25,7 @@ export async function applyReactionRoleReactionsToMessage(
let targetMessage; let targetMessage;
try { try {
targetMessage = await channel.messages.fetch(messageId); targetMessage = await channel.messages.fetch(messageId as Snowflake);
} catch (e) { } catch (e) {
if (isDiscordRESTError(e)) { if (isDiscordRESTError(e)) {
if (e.code === 10008) { if (e.code === 10008) {

View file

@ -1,4 +1,4 @@
import { MessageButton, MessageActionRow, MessageComponentInteraction } from "discord.js"; import { MessageButton, MessageActionRow, MessageComponentInteraction, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin"; import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin";
@ -33,12 +33,11 @@ export async function handleOpenMenu(
const btn = new MessageButton() const btn = new MessageButton()
.setLabel(menuButton.label ?? "") .setLabel(menuButton.label ?? "")
.setStyle("PRIMARY") .setStyle("PRIMARY")
.setType("BUTTON")
.setCustomID(customId) .setCustomID(customId)
.setDisabled(menuButton.disabled ?? false); .setDisabled(menuButton.disabled ?? false);
if (menuButton.emoji) { if (menuButton.emoji) {
const emo = pluginData.client.emojis.resolve(menuButton.emoji) ?? menuButton.emoji; const emo = pluginData.client.emojis.resolve(menuButton.emoji as Snowflake) ?? menuButton.emoji;
btn.setEmoji(emo); btn.setEmoji(emo);
} }
menuButtons.push(btn); menuButtons.push(btn);

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { ReactionRolesPluginType } from "../types"; import { ReactionRolesPluginType } from "../types";
import { ButtonMenuActions } from "./buttonMenuActions"; import { ButtonMenuActions } from "./buttonMenuActions";
@ -5,7 +6,7 @@ import { ButtonMenuActions } from "./buttonMenuActions";
export const BUTTON_CONTEXT_SEPARATOR = "::"; export const BUTTON_CONTEXT_SEPARATOR = "::";
export async function getButtonAction(pluginData: GuildPluginData<ReactionRolesPluginType>, roleOrMenu: string) { export async function getButtonAction(pluginData: GuildPluginData<ReactionRolesPluginType>, roleOrMenu: string) {
if (await pluginData.guild.roles.fetch(roleOrMenu)) { if (await pluginData.guild.roles.fetch(roleOrMenu as Snowflake).catch(() => false)) {
return ButtonMenuActions.MODIFY_ROLE; return ButtonMenuActions.MODIFY_ROLE;
} else { } else {
return ButtonMenuActions.OPEN_MENU; return ButtonMenuActions.OPEN_MENU;

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { disableLinkPreviews } from "knub/dist/helpers"; import { disableLinkPreviews } from "knub/dist/helpers";
@ -12,7 +12,7 @@ const MAX_TRIES = 3;
export async function postDueRemindersLoop(pluginData: GuildPluginData<RemindersPluginType>) { export async function postDueRemindersLoop(pluginData: GuildPluginData<RemindersPluginType>) {
const pendingReminders = await pluginData.state.reminders.getDueReminders(); const pendingReminders = await pluginData.state.reminders.getDueReminders();
for (const reminder of pendingReminders) { for (const reminder of pendingReminders) {
const channel = pluginData.guild.channels.cache.get(reminder.channel_id); const channel = pluginData.guild.channels.cache.get(reminder.channel_id as Snowflake);
if (channel && channel instanceof TextChannel) { if (channel && channel instanceof TextChannel) {
try { try {
// Only show created at date if one exists // Only show created at date if one exists
@ -25,14 +25,14 @@ export async function postDueRemindersLoop(pluginData: GuildPluginData<Reminders
`Reminder for <@!${reminder.user_id}>: ${reminder.body} \n\`Set at ${reminder.created_at} (${result} ago)\``, `Reminder for <@!${reminder.user_id}>: ${reminder.body} \n\`Set at ${reminder.created_at} (${result} ago)\``,
), ),
allowedMentions: { allowedMentions: {
users: [reminder.user_id], users: [reminder.user_id as Snowflake],
}, },
}); });
} else { } else {
await channel.send({ await channel.send({
content: disableLinkPreviews(`Reminder for <@!${reminder.user_id}>: ${reminder.body}`), content: disableLinkPreviews(`Reminder for <@!${reminder.user_id}>: ${reminder.body}`),
allowedMentions: { allowedMentions: {
users: [reminder.user_id], users: [reminder.user_id as Snowflake],
}, },
}); });
} }

View file

@ -1,4 +1,4 @@
import { Role } from "discord.js"; import { Role, Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { memberRolesLock } from "../../../utils/lockNameHelpers"; import { memberRolesLock } from "../../../utils/lockNameHelpers";
@ -31,7 +31,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
const hasUnknownRoles = matchedRoleIds.length !== roleNames.length; const hasUnknownRoles = matchedRoleIds.length !== roleNames.length;
const rolesToAdd: Map<string, Role> = Array.from(matchedRoleIds.values()) const rolesToAdd: Map<string, Role> = Array.from(matchedRoleIds.values())
.map(id => pluginData.guild.roles.cache.get(id)!) .map(id => pluginData.guild.roles.cache.get(id as Snowflake)!)
.filter(Boolean) .filter(Boolean)
.reduce((map, role) => { .reduce((map, role) => {
map.set(role.id, role); map.set(role.id, role);
@ -68,10 +68,10 @@ export const RoleAddCmd = selfGrantableRolesCmd({
newRoleIds.delete(roleId); newRoleIds.delete(roleId);
rolesToAdd.delete(roleId); rolesToAdd.delete(roleId);
if (msg.member.roles.cache.has(roleId)) { if (msg.member.roles.cache.has(roleId as Snowflake)) {
removed.add(pluginData.guild.roles.cache.get(roleId)!); removed.add(pluginData.guild.roles.cache.get(roleId as Snowflake)!);
} else { } else {
skipped.add(pluginData.guild.roles.cache.get(roleId)!); skipped.add(pluginData.guild.roles.cache.get(roleId as Snowflake)!);
} }
} }
} }

View file

@ -47,6 +47,6 @@ export const RoleHelpCmd = selfGrantableRolesCmd({
color: parseInt("42bff4", 16), color: parseInt("42bff4", 16),
}; };
msg.channel.send({ embed: helpEmbed }); msg.channel.send({ embeds: [helpEmbed] });
}, },
}); });

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { memberRolesLock } from "../../../utils/lockNameHelpers"; import { memberRolesLock } from "../../../utils/lockNameHelpers";
@ -27,7 +28,9 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
const roleNames = normalizeRoleNames(splitRoleNames(args.roleNames)); const roleNames = normalizeRoleNames(splitRoleNames(args.roleNames));
const matchedRoleIds = findMatchingRoles(roleNames, applyingEntries); const matchedRoleIds = findMatchingRoles(roleNames, applyingEntries);
const rolesToRemove = Array.from(matchedRoleIds.values()).map(id => pluginData.guild.roles.cache.get(id)!); const rolesToRemove = Array.from(matchedRoleIds.values()).map(
id => pluginData.guild.roles.cache.get(id as Snowflake)!,
);
const roleIdsToRemove = rolesToRemove.map(r => r.id); const roleIdsToRemove = rolesToRemove.map(r => r.id);
// Remove the roles // Remove the roles

View file

@ -1,4 +1,4 @@
import { GuildChannel, Permissions, TextChannel } from "discord.js"; import { GuildChannel, Permissions, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
@ -11,7 +11,7 @@ export async function applyBotSlowmodeToUserId(
userId: string, userId: string,
) { ) {
// Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account. // 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 = const newDeniedPermissions =
(existingOverride ? existingOverride.deny.bitfield : 0n) | Permissions.FLAGS.SEND_MESSAGES; (existingOverride ? existingOverride.deny.bitfield : 0n) | Permissions.FLAGS.SEND_MESSAGES;
const newAllowedPermissions = const newAllowedPermissions =
@ -22,7 +22,7 @@ export async function applyBotSlowmodeToUserId(
{ id: userId, allow: newAllowedPermissions, deny: newDeniedPermissions, type: "member" }, { id: userId, allow: newAllowedPermissions, deny: newDeniedPermissions, type: "member" },
]); ]);
} catch (e) { } 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) { if (isDiscordRESTError(e) && e.code === 50013) {
logger.warn( logger.warn(

View file

@ -1,4 +1,4 @@
import { GuildChannel, TextChannel } from "discord.js"; import { GuildChannel, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SlowmodePluginType } from "../types"; 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 // 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. 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. // 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) { } catch (e) {
if (!force) { if (!force) {
throw e; throw e;

View file

@ -1,4 +1,4 @@
import { GuildChannel, TextChannel } from "discord.js"; import { GuildChannel, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
@ -9,7 +9,7 @@ import { clearBotSlowmodeFromUserId } from "./clearBotSlowmodeFromUserId";
export async function clearExpiredSlowmodes(pluginData: GuildPluginData<SlowmodePluginType>) { export async function clearExpiredSlowmodes(pluginData: GuildPluginData<SlowmodePluginType>) {
const expiredSlowmodeUsers = await pluginData.state.slowmodes.getExpiredSlowmodeUsers(); const expiredSlowmodeUsers = await pluginData.state.slowmodes.getExpiredSlowmodeUsers();
for (const user of expiredSlowmodeUsers) { 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) { if (!channel) {
await pluginData.state.slowmodes.clearSlowmodeUser(user.channel_id, user.user_id); await pluginData.state.slowmodes.clearSlowmodeUser(user.channel_id, user.user_id);
continue; continue;
@ -20,7 +20,8 @@ export async function clearExpiredSlowmodes(pluginData: GuildPluginData<Slowmode
} catch (e) { } catch (e) {
logger.error(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, { pluginData.state.logs.log(LogType.BOT_ALERT, {
body: `Failed to clear slowmode permissions from {userMention(user)} in {channelMention(channel)}`, body: `Failed to clear slowmode permissions from {userMention(user)} in {channelMention(channel)}`,
user: stripObjectToScalars(realUser), user: stripObjectToScalars(realUser),

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
@ -15,7 +15,7 @@ import { applyBotSlowmodeToUserId } from "./applyBotSlowmodeToUserId";
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) { export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
if (msg.is_bot) return; 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; if (!channel) return;
// Don't apply slowmode if the lock was interrupted earlier (e.g. the message was caught by word filters) // 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 // Delete any extra messages sent after a slowmode was already applied
const userHasSlowmode = await pluginData.state.slowmodes.userHasSlowmode(channel.id, msg.user_id); const userHasSlowmode = await pluginData.state.slowmodes.userHasSlowmode(channel.id, msg.user_id);
if (userHasSlowmode) { if (userHasSlowmode) {
const message = await channel.messages.fetch(msg.id); const message = await channel.messages.fetch(msg.id as Snowflake);
if (message) { if (message) {
message.delete(); message.delete();
return thisMsgLock.interrupt(); return thisMsgLock.interrupt();

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
@ -123,7 +123,9 @@ export async function logAndDetectMessageSpam(
// Then, if enabled, remove the spam messages // Then, if enabled, remove the spam messages
if (spamConfig.clean !== false) { if (spamConfig.clean !== false) {
msgIds.forEach(id => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id)); msgIds.forEach(id => pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id));
(pluginData.guild.channels.cache.get(savedMessage.channel_id)! as TextChannel).bulkDelete(msgIds).catch(noop); (pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake)! as TextChannel)
.bulkDelete(msgIds as Snowflake[])
.catch(noop);
} }
// Store the ID of the last handled message // Store the ID of the last handled message
@ -146,7 +148,7 @@ export async function logAndDetectMessageSpam(
clearRecentUserActions(pluginData, type, savedMessage.user_id, savedMessage.channel_id); clearRecentUserActions(pluginData, type, savedMessage.user_id, savedMessage.channel_id);
// Generate a log from the detected messages // Generate a log from the detected messages
const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id); const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake);
const archiveUrl = await saveSpamArchives(pluginData, uniqueMessages); const archiveUrl = await saveSpamArchives(pluginData, uniqueMessages);
// Create a case // Create a case

View file

@ -1,10 +1,11 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { RecentActionType, SpamPluginType } from "../types"; import { RecentActionType, SpamPluginType } from "../types";
import { logAndDetectMessageSpam } from "./logAndDetectMessageSpam"; import { logAndDetectMessageSpam } from "./logAndDetectMessageSpam";
export async function logCensor(pluginData: GuildPluginData<SpamPluginType>, savedMessage: SavedMessage) { export async function logCensor(pluginData: GuildPluginData<SpamPluginType>, savedMessage: SavedMessage) {
const member = pluginData.guild.members.cache.get(savedMessage.user_id); const member = pluginData.guild.members.cache.get(savedMessage.user_id as Snowflake);
const config = await pluginData.config.getMatchingConfig({ const config = await pluginData.config.getMatchingConfig({
userId: savedMessage.user_id, userId: savedMessage.user_id,
channelId: savedMessage.channel_id, channelId: savedMessage.channel_id,

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils"; import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils";
@ -7,7 +8,7 @@ import { logAndDetectMessageSpam } from "./logAndDetectMessageSpam";
export async function onMessageCreate(pluginData: GuildPluginData<SpamPluginType>, savedMessage: SavedMessage) { export async function onMessageCreate(pluginData: GuildPluginData<SpamPluginType>, savedMessage: SavedMessage) {
if (savedMessage.is_bot) return; if (savedMessage.is_bot) return;
const member = pluginData.guild.members.cache.get(savedMessage.user_id); const member = pluginData.guild.members.cache.get(savedMessage.user_id as Snowflake);
const config = await pluginData.config.getMatchingConfig({ const config = await pluginData.config.getMatchingConfig({
userId: savedMessage.user_id, userId: savedMessage.user_id,
channelId: savedMessage.channel_id, channelId: savedMessage.channel_id,

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { starboardCmd } from "../types"; import { starboardCmd } from "../types";
@ -23,7 +23,7 @@ export const MigratePinsCmd = starboardCmd({
return; return;
} }
const starboardChannel = pluginData.guild.channels.cache.get(starboard.channel_id); const starboardChannel = pluginData.guild.channels.cache.get(starboard.channel_id as Snowflake);
if (!starboardChannel || !(starboardChannel instanceof TextChannel)) { if (!starboardChannel || !(starboardChannel instanceof TextChannel)) {
sendErrorMessage(pluginData, msg.channel, "Starboard has an unknown/invalid channel id"); sendErrorMessage(pluginData, msg.channel, "Starboard has an unknown/invalid channel id");
return; return;

View file

@ -1,4 +1,4 @@
import { Message, TextChannel } from "discord.js"; import { Message, Snowflake, TextChannel } from "discord.js";
import { noop, resolveMember } from "../../../utils"; import { noop, resolveMember } from "../../../utils";
import { allStarboardsLock } from "../../../utils/lockNameHelpers"; import { allStarboardsLock } from "../../../utils/lockNameHelpers";
import { starboardEvt } from "../types"; import { starboardEvt } from "../types";
@ -76,8 +76,12 @@ export const StarboardReactionAddEvt = starboardEvt({
// If the message has already been posted to this starboard, update star counts // If the message has already been posted to this starboard, update star counts
if (starboard.show_star_count) { if (starboard.show_star_count) {
for (const starboardMessage of starboardMessages) { for (const starboardMessage of starboardMessages) {
const channel = pluginData.guild.channels.cache.get(starboardMessage.starboard_channel_id) as TextChannel; const channel = pluginData.guild.channels.cache.get(
const realStarboardMessage = await channel.messages.fetch(starboardMessage.starboard_message_id); starboardMessage.starboard_channel_id as Snowflake,
) as TextChannel;
const realStarboardMessage = await channel.messages.fetch(
starboardMessage.starboard_message_id as Snowflake,
);
await updateStarboardMessageStarCount( await updateStarboardMessageStarCount(
starboard, starboard,
msg, msg,

View file

@ -1,4 +1,4 @@
import { Message, TextChannel } from "discord.js"; import { Message, MessageEmbed, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { StarboardPluginType, TStarboardOpts } from "../types"; import { StarboardPluginType, TStarboardOpts } from "../types";
import { createStarboardEmbedFromMessage } from "./createStarboardEmbedFromMessage"; import { createStarboardEmbedFromMessage } from "./createStarboardEmbedFromMessage";
@ -9,13 +9,13 @@ export async function saveMessageToStarboard(
msg: Message, msg: Message,
starboard: TStarboardOpts, starboard: TStarboardOpts,
) { ) {
const channel = pluginData.guild.channels.cache.get(starboard.channel_id); const channel = pluginData.guild.channels.cache.get(starboard.channel_id as Snowflake);
if (!channel) return; if (!channel) return;
const starCount = (await pluginData.state.starboardReactions.getAllReactionsForMessageId(msg.id)).length; const starCount = (await pluginData.state.starboardReactions.getAllReactionsForMessageId(msg.id)).length;
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color); const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color);
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount)); embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount));
const starboardMessage = await (channel as TextChannel).send(embed); const starboardMessage = await (channel as TextChannel).send({ embeds: [embed as MessageEmbed] });
await pluginData.state.starboardMessages.createStarboardMessage(channel.id, msg.id, starboardMessage.id); await pluginData.state.starboardMessages.createStarboardMessage(channel.id, msg.id, starboardMessage.id);
} }

View file

@ -23,6 +23,6 @@ export async function updateStarboardMessageStarCount(
const embed = starboardMessage.embeds[0]!; const embed = starboardMessage.embeds[0]!;
embed.fields!.pop(); // Remove pseudo footer embed.fields!.pop(); // Remove pseudo footer
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, originalMessage, starEmoji, starCount)); // Create new pseudo footer embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, originalMessage, starEmoji, starCount)); // Create new pseudo footer
starboardMessage.edit({ embed }); starboardMessage.edit({ embeds: [embed] });
}, DEBOUNCE_DELAY); }, DEBOUNCE_DELAY);
} }

View file

@ -1,3 +1,4 @@
import { Snowflake } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { PluginOptions } from "knub"; import { PluginOptions } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
@ -214,11 +215,14 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
return input; return input;
} }
if (pluginData.guild.members.cache.has(input) || pluginData.client.users.resolve(input)) { if (
pluginData.guild.members.cache.has(input as Snowflake) ||
pluginData.client.users.resolve(input as Snowflake)
) {
return `<@!${input}>`; return `<@!${input}>`;
} }
if (pluginData.guild.channels.cache.has(input)) { if (pluginData.guild.channels.cache.has(input as Snowflake)) {
return `<#${input}>`; return `<#${input}>`;
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions"; import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
@ -16,7 +16,7 @@ export async function onMessageCreate(pluginData: GuildPluginData<TagsPluginType
const member = await resolveMember(pluginData.client, pluginData.guild, msg.user_id); const member = await resolveMember(pluginData.client, pluginData.guild, msg.user_id);
if (!member) return; if (!member) 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; if (!channel) return;
const config = await pluginData.config.getMatchingConfig({ const config = await pluginData.config.getMatchingConfig({
@ -117,6 +117,8 @@ export async function onMessageCreate(pluginData: GuildPluginData<TagsPluginType
const deleteInvoke = tagResult.category?.auto_delete_command ?? config.auto_delete_command; const deleteInvoke = tagResult.category?.auto_delete_command ?? config.auto_delete_command;
if (!deleteWithCommand && deleteInvoke) { if (!deleteWithCommand && deleteInvoke) {
// Try deleting the invoking message, ignore errors silently // Try deleting the invoking message, ignore errors silently
(pluginData.guild.channels.resolve(msg.channel_id) as TextChannel).messages.delete(msg.id); (pluginData.guild.channels.resolve(msg.channel_id as Snowflake) as TextChannel).messages.delete(
msg.id as Snowflake,
);
} }
} }

View file

@ -1,4 +1,4 @@
import { TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { TagsPluginType } from "../types"; import { TagsPluginType } from "../types";
@ -7,26 +7,26 @@ export async function onMessageDelete(pluginData: GuildPluginData<TagsPluginType
// Command message was deleted -> delete the response as well // Command message was deleted -> delete the response as well
const commandMsgResponse = await pluginData.state.tags.findResponseByCommandMessageId(msg.id); const commandMsgResponse = await pluginData.state.tags.findResponseByCommandMessageId(msg.id);
if (commandMsgResponse) { if (commandMsgResponse) {
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; if (!channel) return;
const responseMsg = await pluginData.state.savedMessages.find(commandMsgResponse.response_message_id); const responseMsg = await pluginData.state.savedMessages.find(commandMsgResponse.response_message_id);
if (!responseMsg || responseMsg.deleted_at != null) return; if (!responseMsg || responseMsg.deleted_at != null) return;
await channel.messages.delete(commandMsgResponse.response_message_id); await channel.messages.delete(commandMsgResponse.response_message_id as Snowflake);
return; return;
} }
// Response was deleted -> delete the command message as well // Response was deleted -> delete the command message as well
const responseMsgResponse = await pluginData.state.tags.findResponseByResponseMessageId(msg.id); const responseMsgResponse = await pluginData.state.tags.findResponseByResponseMessageId(msg.id);
if (responseMsgResponse) { if (responseMsgResponse) {
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; if (!channel) return;
const commandMsg = await pluginData.state.savedMessages.find(responseMsgResponse.command_message_id); const commandMsg = await pluginData.state.savedMessages.find(responseMsgResponse.command_message_id);
if (!commandMsg || commandMsg.deleted_at != null) return; if (!commandMsg || commandMsg.deleted_at != null) return;
await channel.messages.delete(responseMsgResponse.command_message_id); await channel.messages.delete(responseMsgResponse.command_message_id as Snowflake);
return; return;
} }
} }

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more