mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
Type fixes for djs
This commit is contained in:
parent
653d6c1dc2
commit
0822fc15e5
130 changed files with 8877 additions and 411 deletions
6509
backend/package-lock.json
generated
6509
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -29,7 +29,7 @@
|
|||
"cors": "^2.8.5",
|
||||
"cross-env": "^5.2.0",
|
||||
"deep-diff": "^1.0.2",
|
||||
"discord.js": "github:monbrey/discord.js#9c42f571093b2565df28b756fdca4ac59cad0fe3",
|
||||
"discord.js": "^13.0.0-dev.edab5af.1624996138",
|
||||
"dotenv": "^4.0.0",
|
||||
"emoji-regex": "^8.0.0",
|
||||
"erlpack": "github:discord/erlpack",
|
||||
|
@ -39,8 +39,8 @@
|
|||
"humanize-duration": "^3.15.0",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^30.0.0-beta.38",
|
||||
"knub-command-manager": "^8.1.2",
|
||||
"knub": "file:../../Knub",
|
||||
"knub-command-manager": "^9.1.0",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
|
@ -88,7 +88,7 @@
|
|||
"rimraf": "^2.6.2",
|
||||
"source-map-support": "^0.5.16",
|
||||
"tsc-watch": "^4.0.0",
|
||||
"typescript": "^4.1.3"
|
||||
"typescript": "^4.4.0-dev.20210629"
|
||||
},
|
||||
"ava": {
|
||||
"files": [
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Guild } from "discord.js";
|
||||
import { Guild, Snowflake } from "discord.js";
|
||||
import moment from "moment-timezone";
|
||||
import { getRepository, Repository } from "typeorm";
|
||||
import { renderTemplate } from "../templateFormatter";
|
||||
|
@ -73,7 +73,7 @@ export class GuildArchives extends BaseGuildRepository {
|
|||
protected async renderLinesFromSavedMessages(savedMessages: SavedMessage[], guild: Guild) {
|
||||
const msgLines: string[] = [];
|
||||
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 line = await renderTemplate(MESSAGE_ARCHIVE_MESSAGE_FORMAT, {
|
||||
|
|
|
@ -196,7 +196,7 @@ export async function sendSuccessMessage(
|
|||
: { content: formattedBody };
|
||||
|
||||
return channel
|
||||
.send({ ...content, split: false }) // Force line break
|
||||
.send({ ...content }) // Force line break
|
||||
.catch(err => {
|
||||
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`;
|
||||
logger.warn(`Failed to send success message to ${channelInfo}): ${err.code} ${err.message}`);
|
||||
|
@ -217,7 +217,7 @@ export async function sendErrorMessage(
|
|||
: { content: formattedBody };
|
||||
|
||||
return channel
|
||||
.send({ ...content, split: false }) // Force line break
|
||||
.send({ ...content }) // Force line break
|
||||
.catch(err => {
|
||||
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`;
|
||||
logger.warn(`Failed to send error message to ${channelInfo}): ${err.code} ${err.message}`);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Permissions, TextChannel } from "discord.js";
|
||||
import { Permissions, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -16,7 +16,7 @@ export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePlugi
|
|||
|
||||
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) {
|
||||
// Channel was deleted, ignore
|
||||
return;
|
||||
|
@ -44,7 +44,7 @@ export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePlugi
|
|||
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
||||
|
||||
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) {
|
||||
// "Unknown Message", probably already deleted by automod or another bot, ignore
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Permissions } from "discord.js";
|
||||
import { Permissions, Snowflake } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { nonNullish, unique } from "../../../utils";
|
||||
|
@ -41,7 +41,7 @@ export const AddRolesAction = automodAction({
|
|||
|
||||
if (rolesWeCannotAssign.length) {
|
||||
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);
|
||||
logs.log(LogType.BOT_ALERT, {
|
||||
|
@ -55,7 +55,7 @@ export const AddRolesAction = automodAction({
|
|||
members.map(async member => {
|
||||
const memberRoles = new Set(member.roles.cache.keyArray());
|
||||
for (const roleId of rolesToAssign) {
|
||||
memberRoles.add(roleId);
|
||||
memberRoles.add(roleId as Snowflake);
|
||||
ignoreRoleChange(pluginData, member.id, roleId);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -24,7 +24,7 @@ export const AlertAction = automodAction({
|
|||
defaultConfig: {},
|
||||
|
||||
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);
|
||||
|
||||
if (channel && channel instanceof TextChannel) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { noop } from "../../../utils";
|
||||
|
@ -30,8 +30,8 @@ export const CleanAction = automodAction({
|
|||
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id);
|
||||
}
|
||||
|
||||
const channel = pluginData.guild.channels.cache.get(channelId) as TextChannel;
|
||||
await channel.bulkDelete(messageIds).catch(noop);
|
||||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake) as TextChannel;
|
||||
await channel.bulkDelete(messageIds as Snowflake[]).catch(noop);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Permissions } from "discord.js";
|
||||
import { Permissions, Snowflake } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { nonNullish, unique } from "../../../utils";
|
||||
|
@ -42,7 +42,7 @@ export const RemoveRolesAction = automodAction({
|
|||
|
||||
if (rolesWeCannotRemove.length) {
|
||||
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);
|
||||
logs.log(LogType.BOT_ALERT, {
|
||||
|
@ -56,7 +56,7 @@ export const RemoveRolesAction = automodAction({
|
|||
members.map(async member => {
|
||||
const memberRoles = new Set(member.roles.cache.keyArray());
|
||||
for (const roleId of rolesToRemove) {
|
||||
memberRoles.delete(roleId);
|
||||
memberRoles.delete(roleId as Snowflake);
|
||||
ignoreRoleChange(pluginData, member.id, roleId);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 { LogType } from "../../../data/LogType";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
|
@ -31,7 +31,7 @@ export const ReplyAction = automodAction({
|
|||
async apply({ pluginData, contexts, actionConfig, ruleName }) {
|
||||
const contextsWithTextChannels = contexts
|
||||
.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) => {
|
||||
if (!map.has(context.message!.channel_id)) {
|
||||
|
@ -56,7 +56,7 @@ export const ReplyAction = automodAction({
|
|||
: ((await renderRecursively(actionConfig.text, renderReplyText)) as MessageOptions);
|
||||
|
||||
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
|
||||
if (
|
||||
|
@ -90,7 +90,6 @@ export const ReplyAction = automodAction({
|
|||
allowedMentions: {
|
||||
users: [user.id],
|
||||
},
|
||||
split: false,
|
||||
});
|
||||
|
||||
if (typeof actionConfig === "object" && actionConfig.auto_delete) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { ChannelTypeStrings } from "src/types";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -19,7 +19,7 @@ export const SetSlowmodeAction = automodAction({
|
|||
const slowmodeMs = Math.max(actionConfig.duration ? convertDelayStringToMS(actionConfig.duration)! : 0, 0);
|
||||
|
||||
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
|
||||
if (!channel || !(channel.type === ChannelTypeStrings.TEXT || ChannelTypeStrings.CATEGORY)) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
|
@ -11,8 +12,8 @@ export function runAutomodOnMessage(
|
|||
message: SavedMessage,
|
||||
isEdit: boolean,
|
||||
) {
|
||||
const user = pluginData.client.users.cache!.get(message.user_id);
|
||||
const member = pluginData.guild.members.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 as Snowflake);
|
||||
|
||||
const context: AutomodContext = {
|
||||
timestamp: moment.utc(message.posted_at).valueOf(),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { messageSummary, verboseChannelMention } from "../../../utils";
|
||||
import { AutomodContext, AutomodPluginType } from "../types";
|
||||
|
@ -10,13 +11,13 @@ export function getTextMatchPartialSummary(
|
|||
) {
|
||||
if (type === "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}\``;
|
||||
|
||||
return `message in ${channelMention}:\n${messageSummary(message)}`;
|
||||
} else if (type === "embed") {
|
||||
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}\``;
|
||||
|
||||
return `message embed in ${channelMention}:\n${messageSummary(message)}`;
|
||||
|
@ -28,6 +29,6 @@ export function getTextMatchPartialSummary(
|
|||
const visibleName = context.member?.nickname || context.user!.username;
|
||||
return `visible name: ${visibleName}`;
|
||||
} 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}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
|
||||
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
|
||||
|
@ -18,7 +18,7 @@ export function resolveActionContactMethods(
|
|||
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)) {
|
||||
throw new RecoverablePluginError(ERRORS.INVALID_USER_NOTIFICATION_CHANNEL);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { availableActions } from "../actions/availableActions";
|
||||
import { CleanAction } from "../actions/clean";
|
||||
|
@ -9,10 +9,10 @@ import { checkAndUpdateCooldown } from "./checkAndUpdateCooldown";
|
|||
|
||||
export async function runAutomod(pluginData: GuildPluginData<AutomodPluginType>, context: AutomodContext) {
|
||||
const userId = context.user?.id || context.member?.id || context.message?.user_id;
|
||||
const user = context.user || (userId && pluginData.client.users!.cache.get(userId));
|
||||
const member = context.member || (userId && pluginData.guild.members.cache.get(userId)) || null;
|
||||
const user = context.user || (userId && pluginData.client.users!.cache.get(userId as Snowflake));
|
||||
const member = context.member || (userId && pluginData.guild.members.cache.get(userId as Snowflake)) || null;
|
||||
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 config = await pluginData.config.getMatchingConfig({
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { verboseChannelMention } from "../../../utils";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
@ -21,7 +22,7 @@ export const AnyMessageTrigger = automodTrigger<AnyMessageResultType>()({
|
|||
},
|
||||
|
||||
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 ${
|
||||
channel ? verboseChannelMention(channel) : "Unknown Channel"
|
||||
}`;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { asSingleLine, disableInlineCode, messageSummary, verboseChannelMention } from "../../../utils";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
@ -67,7 +68,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
|
|||
},
|
||||
|
||||
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);
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
@ -33,7 +34,7 @@ export const RoleAddedTrigger = automodTrigger<RoleAddedMatchResult>()({
|
|||
},
|
||||
|
||||
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 member = contexts[0].member!;
|
||||
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
@ -33,7 +34,7 @@ export const RoleRemovedTrigger = automodTrigger<RoleAddedMatchResult>()({
|
|||
},
|
||||
|
||||
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 member = contexts[0].member!;
|
||||
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
import { Configs } from "../../data/Configs";
|
||||
|
@ -58,9 +58,9 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
|||
const [guildId, channelId] = activeReload;
|
||||
resetActiveReload();
|
||||
|
||||
const guild = await pluginData.client.guilds.fetch(guildId);
|
||||
const guild = await pluginData.client.guilds.fetch(guildId as Snowflake);
|
||||
if (guild) {
|
||||
const channel = guild.channels.cache.get(channelId);
|
||||
const channel = guild.channels.cache.get(channelId as Snowflake);
|
||||
if (channel instanceof TextChannel) {
|
||||
sendSuccessMessage(pluginData, channel, "Global plugins reloaded!");
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ export const ServersCmd = botControlCmd({
|
|||
signature: {
|
||||
search: ct.string({ catchAll: true, required: false }),
|
||||
|
||||
all: ct.switchOption({ shortcut: "a" }),
|
||||
initialized: ct.switchOption({ shortcut: "i" }),
|
||||
uninitialized: ct.switchOption({ shortcut: "u" }),
|
||||
all: ct.switchOption({ def: false, shortcut: "a" }),
|
||||
initialized: ct.switchOption({ def: false, shortcut: "i" }),
|
||||
uninitialized: ct.switchOption({ def: false, shortcut: "u" }),
|
||||
},
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
|
|
|
@ -108,5 +108,5 @@ export async function getCaseEmbed(
|
|||
});
|
||||
}
|
||||
|
||||
return { embed };
|
||||
return { embeds: [embed] };
|
||||
}
|
||||
|
|
|
@ -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 { Case } from "../../../data/entities/Case";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -15,7 +15,7 @@ export async function postToCaseLogChannel(
|
|||
const caseLogChannelId = pluginData.config.get().case_log_channel;
|
||||
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;
|
||||
|
||||
let result;
|
||||
|
@ -23,7 +23,7 @@ export async function postToCaseLogChannel(
|
|||
if (file != null) {
|
||||
content.files = file;
|
||||
}
|
||||
result = await caseLogChannel.send({ ...content, split: false });
|
||||
result = await caseLogChannel.send({ ...content });
|
||||
} catch (e) {
|
||||
if (isDiscordRESTError(e) && (e.code === 50013 || e.code === 50001)) {
|
||||
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
||||
|
@ -52,8 +52,8 @@ export async function postCaseToCaseLogChannel(
|
|||
const [channelId, messageId] = theCase.log_message_id.split("-");
|
||||
|
||||
try {
|
||||
const channel = pluginData.guild.channels.resolve(channelId) as TextChannel;
|
||||
await channel.messages.edit(messageId, caseEmbed);
|
||||
const channel = pluginData.guild.channels.resolve(channelId as Snowflake) as TextChannel;
|
||||
await channel.messages.edit(messageId as Snowflake, caseEmbed);
|
||||
return null;
|
||||
} catch {} // tslint:disable-line:no-empty
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { deactivateMentions, disableCodeBlocks } from "knub/dist/helpers";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
|
@ -14,14 +14,14 @@ export async function censorMessage(
|
|||
pluginData.state.serverLogs.ignoreLog(LogType.MESSAGE_DELETE, savedMessage.id);
|
||||
|
||||
try {
|
||||
const resolvedChannel = pluginData.guild.channels.resolve(savedMessage.channel_id) as TextChannel;
|
||||
await resolvedChannel.messages.delete(savedMessage.id);
|
||||
const resolvedChannel = pluginData.guild.channels.resolve(savedMessage.channel_id as Snowflake) as TextChannel;
|
||||
await resolvedChannel.messages.delete(savedMessage.id as Snowflake);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
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, {
|
||||
user: stripObjectToScalars(user),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Collection, Message, Snowflake } from "discord.js";
|
||||
import moment from "moment-timezone";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwner, sendErrorMessage } from "../../../pluginUtils";
|
||||
|
@ -31,11 +32,10 @@ export const ArchiveChannelCmd = channelArchiverCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!args["attachment-channel"]) {
|
||||
const confirmed = await confirm(
|
||||
msg.channel,
|
||||
msg.author.id,
|
||||
"No `-attachment-channel` specified. Continue? Attachments will not be available in the log if their message is deleted.",
|
||||
);
|
||||
const confirmed = await confirm(msg.channel, msg.author.id, {
|
||||
content:
|
||||
"No `-attachment-channel` specified. Continue? Attachments will not be available in the log if their message is deleted.",
|
||||
});
|
||||
if (!confirmed) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Canceled");
|
||||
return;
|
||||
|
@ -60,7 +60,10 @@ export const ArchiveChannelCmd = channelArchiverCmd({
|
|||
|
||||
while (archivedMessages < maxMessagesToArchive) {
|
||||
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;
|
||||
|
||||
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`,
|
||||
},
|
||||
],
|
||||
split: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ export async function rehostAttachment(attachment: MessageAttachment, targetChan
|
|||
content: `Rehost of attachment ${attachment.id}`,
|
||||
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;
|
||||
} catch {
|
||||
return "Failed to rehost attachment";
|
||||
|
|
|
@ -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 { LogType } from "../../../data/LogType";
|
||||
import { isDiscordRESTError, MINUTES } from "../../../utils";
|
||||
|
@ -51,13 +51,15 @@ export async function handleCompanionPermissions(
|
|||
|
||||
try {
|
||||
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;
|
||||
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) {
|
||||
const channel = pluginData.guild.channels.cache.get(channelId);
|
||||
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
|
||||
if (!channel || !(channel instanceof TextChannel)) continue;
|
||||
await channel.updateOverwrite(userId, new Permissions(BigInt(permissions)).serialize(), {
|
||||
reason: `Companion Channel for ${voiceChannel!.id} | User Joined`,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
@ -73,7 +73,7 @@ export const AddCounterCmd = typedGuildCommand<CountersPluginType>()({
|
|||
return;
|
||||
}
|
||||
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content);
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
|
||||
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
|
||||
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
|
||||
return;
|
||||
|
|
|
@ -28,15 +28,13 @@ export const ResetAllCounterValuesCmd = typedGuildCommand<CountersPluginType>()(
|
|||
}
|
||||
|
||||
const counterName = counter.name || args.counterName;
|
||||
const confirmed = await confirm(
|
||||
message.channel,
|
||||
message.author.id,
|
||||
trimMultilineString(`
|
||||
const confirmed = await confirm(message.channel, message.author.id, {
|
||||
content: trimMultilineString(`
|
||||
Do you want to reset **ALL** values for counter **${counterName}**?
|
||||
This will reset the counter for **all** users and channels.
|
||||
**Note:** This will *not* trigger any triggers or counter triggers.
|
||||
`),
|
||||
);
|
||||
});
|
||||
if (!confirmed) {
|
||||
sendErrorMessage(pluginData, message.channel, "Cancelled");
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
@ -68,7 +68,7 @@ export const ResetCounterCmd = typedGuildCommand<CountersPluginType>()({
|
|||
return;
|
||||
}
|
||||
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content);
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
|
||||
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
|
||||
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
@ -73,7 +73,7 @@ export const SetCounterCmd = typedGuildCommand<CountersPluginType>()({
|
|||
return;
|
||||
}
|
||||
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content);
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
|
||||
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
|
||||
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { typedGuildCommand } from "knub";
|
||||
import { waitForReply } from "knub/dist/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
@ -67,7 +67,7 @@ export const ViewCounterCmd = typedGuildCommand<CountersPluginType>()({
|
|||
return;
|
||||
}
|
||||
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content);
|
||||
const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
|
||||
if (!potentialChannel || !(potentialChannel instanceof TextChannel)) {
|
||||
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
|
||||
return;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { convertDelayStringToMS, noop, tDelayString } from "../../../utils";
|
||||
|
@ -18,7 +19,7 @@ export async function makeRoleMentionableAction(
|
|||
event: TCustomEvent,
|
||||
eventData: any,
|
||||
) {
|
||||
const role = pluginData.guild.roles.cache.get(action.role);
|
||||
const role = pluginData.guild.roles.cache.get(action.role as Snowflake);
|
||||
if (!role) {
|
||||
throw new ActionError(`Unknown role: ${role}`);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ActionError } from "../ActionError";
|
||||
|
@ -16,7 +17,7 @@ export async function makeRoleUnmentionableAction(
|
|||
event: TCustomEvent,
|
||||
eventData: any,
|
||||
) {
|
||||
const role = pluginData.guild.roles.cache.get(action.role);
|
||||
const role = pluginData.guild.roles.cache.get(action.role as Snowflake);
|
||||
if (!role) {
|
||||
throw new ActionError(`Unknown role: ${role}`);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
|
@ -18,7 +18,7 @@ export async function messageAction(
|
|||
values: any,
|
||||
) {
|
||||
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 instanceof TextChannel)) throw new ActionError("Target channel is not a text channel");
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { VoiceChannel } from "discord.js";
|
||||
import { Snowflake, VoiceChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { canActOn } from "../../../pluginUtils";
|
||||
|
@ -30,7 +30,7 @@ export async function moveToVoiceChannelAction(
|
|||
}
|
||||
|
||||
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 instanceof VoiceChannel)) throw new ActionError("Target channel is not a voice channel");
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ActionError } from "../ActionError";
|
||||
|
@ -24,7 +25,7 @@ export async function setChannelPermissionOverridesAction(
|
|||
event: TCustomEvent,
|
||||
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) {
|
||||
throw new ActionError(`Unknown channel: ${action.channel}`);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { locateUserEvt } from "../types";
|
||||
import { sendAlerts } from "../utils/sendAlerts";
|
||||
|
||||
|
@ -17,7 +17,7 @@ export const VoiceStateUpdateAlertEvt = locateUserEvt({
|
|||
const voiceChannel = meta.args.oldState.channel!;
|
||||
|
||||
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(
|
||||
`🔴 <@!${alert.requestor_id}> the user <@!${alert.user_id}> disconnected out of \`<#!${voiceChannel.id}>\``,
|
||||
);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember, TextChannel } from "discord.js";
|
||||
import { GuildMember, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { LocateUserPluginType } from "../types";
|
||||
|
@ -9,7 +9,7 @@ export async function moveMember(
|
|||
target: GuildMember,
|
||||
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) {
|
||||
try {
|
||||
await modMember.edit({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { resolveMember } from "../../../utils";
|
||||
import { LocateUserPluginType } from "../types";
|
||||
|
@ -12,7 +12,7 @@ export async function sendAlerts(pluginData: GuildPluginData<LocateUserPluginTyp
|
|||
|
||||
triggeredAlerts.forEach(alert => {
|
||||
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);
|
||||
if (alert.active) {
|
||||
moveMember(pluginData, alert.requestor_id, member, txtChannel);
|
||||
|
|
|
@ -28,7 +28,6 @@ export async function sendWhere(
|
|||
channel.send({
|
||||
content: prepend + `<@${member.id}> is in the following channel: \`${voice.name}\` ${getInviteLink(invite)}`,
|
||||
allowedMentions: { parse: ["users"] },
|
||||
split: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageMentionTypes, TextChannel } from "discord.js";
|
||||
import { MessageMentionTypes, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -19,7 +19,7 @@ export async function log(pluginData: GuildPluginData<LogsPluginType>, type: Log
|
|||
const typeStr = LogType[type];
|
||||
|
||||
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 ((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) {
|
||||
for (const value of Object.values(data || {})) {
|
||||
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 || []) {
|
||||
if (opts.excluded_roles.includes(role[0])) {
|
||||
continue logChannelLoop;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageAttachment } from "discord.js";
|
||||
import { MessageAttachment, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
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) {
|
||||
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) {
|
||||
// Replace attachment URLs with media URLs
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -5,7 +6,7 @@ import { getBaseUrl } from "../../../pluginUtils";
|
|||
import { LogsPluginType } from "../types";
|
||||
|
||||
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 archiveUrl = pluginData.state.archives.getUrl(getBaseUrl(pluginData), archiveId);
|
||||
const authorIds = Array.from(new Set(savedMessages.map(item => `\`${item.user_id}\``))).join(", ");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageEmbed } from "discord.js";
|
||||
import { MessageEmbed, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
|
@ -47,7 +47,7 @@ export async function onMessageUpdate(
|
|||
}
|
||||
|
||||
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, {
|
||||
user: stripObjectToScalars(user),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Message, TextChannel } from "discord.js";
|
||||
import { Message, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { MessageSaverPluginType } from "./types";
|
||||
|
||||
|
@ -15,7 +15,7 @@ export async function saveMessagesToDB(
|
|||
let thisMsg: Message;
|
||||
|
||||
try {
|
||||
thisMsg = await channel.messages.fetch(id);
|
||||
thisMsg = await channel.messages.fetch(id as Snowflake);
|
||||
|
||||
if (!thisMsg) {
|
||||
failed.push(id);
|
||||
|
|
|
@ -71,7 +71,7 @@ export const CasesModCmd = modActionsCmd({
|
|||
],
|
||||
};
|
||||
|
||||
return { embed };
|
||||
return { embeds: [embed] };
|
||||
},
|
||||
{
|
||||
limitToUserId: msg.author.id,
|
||||
|
|
|
@ -12,13 +12,13 @@ import { modActionsCmd } from "../types";
|
|||
const opts = {
|
||||
expand: ct.bool({ option: true, isSwitch: true, shortcut: "e" }),
|
||||
hidden: ct.bool({ option: true, isSwitch: true, shortcut: "h" }),
|
||||
reverseFilters: ct.switchOption({ shortcut: "r" }),
|
||||
notes: ct.switchOption({ shortcut: "n" }),
|
||||
warns: ct.switchOption({ shortcut: "w" }),
|
||||
mutes: ct.switchOption({ shortcut: "m" }),
|
||||
unmutes: ct.switchOption({ shortcut: "um" }),
|
||||
bans: ct.switchOption({ shortcut: "b" }),
|
||||
unbans: ct.switchOption({ shortcut: "ub" }),
|
||||
reverseFilters: ct.switchOption({ def: false, shortcut: "r" }),
|
||||
notes: ct.switchOption({ def: false, shortcut: "n" }),
|
||||
warns: ct.switchOption({ def: false, shortcut: "w" }),
|
||||
mutes: ct.switchOption({ def: false, shortcut: "m" }),
|
||||
unmutes: ct.switchOption({ def: false, shortcut: "um" }),
|
||||
bans: ct.switchOption({ def: false, shortcut: "b" }),
|
||||
unbans: ct.switchOption({ def: false, shortcut: "ub" }),
|
||||
};
|
||||
|
||||
export const CasesUserCmd = modActionsCmd({
|
||||
|
@ -127,7 +127,7 @@ export const CasesUserCmd = modActionsCmd({
|
|||
],
|
||||
};
|
||||
|
||||
msg.channel.send({ embed });
|
||||
msg.channel.send({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export const DeleteCaseCmd = modActionsCmd({
|
|||
signature: {
|
||||
caseNumber: ct.number({ rest: true }),
|
||||
|
||||
force: ct.switchOption({ shortcut: "f" }),
|
||||
force: ct.switchOption({ def: false, shortcut: "f" }),
|
||||
},
|
||||
|
||||
async run({ pluginData, message, args }) {
|
||||
|
@ -49,8 +49,8 @@ export const DeleteCaseCmd = modActionsCmd({
|
|||
const cases = pluginData.getPlugin(CasesPlugin);
|
||||
const embedContent = await cases.getCaseEmbed(theCase);
|
||||
message.channel.send({
|
||||
...embedContent,
|
||||
content: "Delete the following case? Answer 'Yes' to continue, 'No' to cancel.",
|
||||
embed: embedContent.embed,
|
||||
});
|
||||
|
||||
const reply = await helpers.waitForReply(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -66,7 +67,7 @@ export const ForcebanCmd = modActionsCmd({
|
|||
|
||||
try {
|
||||
// FIXME: Use banUserId()?
|
||||
await pluginData.guild.bans.create(user.id, {
|
||||
await pluginData.guild.bans.create(user.id as Snowflake, {
|
||||
days: 1,
|
||||
reason: reason != null ? encodeURIComponent(reason) : undefined,
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -49,7 +50,7 @@ export const UnbanCmd = modActionsCmd({
|
|||
|
||||
try {
|
||||
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 {
|
||||
sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?");
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Permissions, TextChannel } from "discord.js";
|
||||
import { Permissions, Snowflake, TextChannel } from "discord.js";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { resolveMember } from "../../../utils";
|
||||
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
|
||||
|
@ -22,7 +22,7 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt({
|
|||
const logs = pluginData.getPlugin(LogsPlugin);
|
||||
|
||||
if (actions.length) {
|
||||
const alertChannel = pluginData.guild.channels.cache.get(alertChannelId);
|
||||
const alertChannel = pluginData.guild.channels.cache.get(alertChannelId as Snowflake);
|
||||
if (!alertChannel) {
|
||||
logs.log(LogType.BOT_ALERT, {
|
||||
body: `Unknown \`alert_channel\` configured for \`mod_actions\`: \`${alertChannelId}\``,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { DiscordAPIError, User } from "discord.js";
|
||||
import { DiscordAPIError, Snowflake, User } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -77,7 +77,7 @@ export async function banUserId(
|
|||
ignoreEvent(pluginData, IgnoredEventType.Ban, userId);
|
||||
try {
|
||||
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,
|
||||
reason: reason != null ? encodeURIComponent(reason) : undefined,
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { UserNotificationMethod } from "../../../utils";
|
||||
import { ModActionsPluginType } from "../types";
|
||||
|
@ -15,7 +15,7 @@ export function getDefaultContactMethods(
|
|||
}
|
||||
|
||||
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) {
|
||||
methods.push({
|
||||
type: "channel",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Permissions } from "discord.js";
|
||||
import { Permissions, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { isDiscordHTTPError, isDiscordRESTError, SECONDS, sleep } from "../../../utils";
|
||||
|
@ -21,7 +21,7 @@ export async function isBanned(
|
|||
|
||||
try {
|
||||
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),
|
||||
]);
|
||||
return potentialBan != null;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
|
@ -30,7 +31,10 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
|
|||
);
|
||||
try {
|
||||
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) {
|
||||
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
|
||||
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { GuildMember, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -75,7 +75,7 @@ export async function warnMember(
|
|||
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, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
member: stripObjectToScalars(member, ["user", "roles"]),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { GuildMember, Snowflake } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
|
@ -95,7 +95,7 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
|||
hasMutedRole(pluginData) {
|
||||
return (member: GuildMember) => {
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
return muteRole ? member.roles.cache.has(muteRole) : false;
|
||||
return muteRole ? member.roles.cache.has(muteRole as Snowflake) : false;
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { User } from "discord.js";
|
||||
import { Snowflake, User } from "discord.js";
|
||||
import { sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { mutesCmd } from "../types";
|
||||
|
||||
|
@ -19,7 +19,7 @@ export const ClearBannedMutesCmd = mutesCmd({
|
|||
|
||||
let cleared = 0;
|
||||
for (const mute of activeMutes) {
|
||||
if (bannedIds.includes(mute.user_id)) {
|
||||
if (bannedIds.includes(mute.user_id as Snowflake)) {
|
||||
await pluginData.state.mutes.clear(mute.user_id);
|
||||
cleared++;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveMember } from "../../../utils";
|
||||
import { mutesCmd } from "../types";
|
||||
|
@ -19,7 +20,7 @@ export const ClearMutesWithoutRoleCmd = mutesCmd({
|
|||
const member = await resolveMember(pluginData.client, pluginData.guild, mute.user_id);
|
||||
if (!member) continue;
|
||||
|
||||
if (!member.roles.cache.has(muteRole)) {
|
||||
if (!member.roles.cache.has(muteRole as Snowflake)) {
|
||||
await pluginData.state.mutes.clear(mute.user_id);
|
||||
cleared++;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember, MessageActionRow, MessageButton, MessageComponentInteraction } from "discord.js";
|
||||
import { GuildMember, MessageActionRow, MessageButton, MessageComponentInteraction, Snowflake } from "discord.js";
|
||||
import moment from "moment-timezone";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { humanizeDurationShort } from "../../../humanizeDurationShort";
|
||||
|
@ -16,9 +16,9 @@ export const MutesCmd = mutesCmd({
|
|||
shortcut: "a",
|
||||
}),
|
||||
|
||||
left: ct.switchOption({ shortcut: "l" }),
|
||||
manual: ct.switchOption({ shortcut: "m" }),
|
||||
export: ct.switchOption({ shortcut: "e" }),
|
||||
left: ct.switchOption({ def: false, shortcut: "l" }),
|
||||
manual: ct.switchOption({ def: false, shortcut: "m" }),
|
||||
export: ct.switchOption({ def: false, shortcut: "e" }),
|
||||
},
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
|
@ -53,7 +53,7 @@ export const MutesCmd = mutesCmd({
|
|||
if (muteRole) {
|
||||
pluginData.guild.members.cache.forEach(member => {
|
||||
if (muteUserIds.has(member.id)) return;
|
||||
if (member.roles.cache.has(muteRole)) manuallyMutedMembers.push(member);
|
||||
if (member.roles.cache.has(muteRole as Snowflake)) manuallyMutedMembers.push(member);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ export const MutesCmd = mutesCmd({
|
|||
const muteCasesById = muteCases.reduce((map, c) => map.set(c.id, c), new Map());
|
||||
|
||||
lines = filteredMutes.map(mute => {
|
||||
const user = pluginData.client.users.resolve(mute.user_id);
|
||||
const user = pluginData.client.users.resolve(mute.user_id as Snowflake);
|
||||
const username = user ? `${user.username}#${user.discriminator}` : "Unknown#0000";
|
||||
const theCase = muteCasesById.get(mute.case_id);
|
||||
const caseName = theCase ? `Case #${theCase.case_number}` : "No case";
|
||||
|
@ -199,7 +199,6 @@ export const MutesCmd = mutesCmd({
|
|||
new MessageButton()
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("⬅")
|
||||
.setType("BUTTON")
|
||||
.setCustomID(`previousButton:${idMod}`),
|
||||
);
|
||||
|
||||
|
@ -207,7 +206,6 @@ export const MutesCmd = mutesCmd({
|
|||
new MessageButton()
|
||||
.setStyle("SECONDARY")
|
||||
.setEmoji("➡")
|
||||
.setType("BUTTON")
|
||||
.setCustomID(`nextButton:${idMod}`),
|
||||
);
|
||||
|
||||
|
@ -215,13 +213,14 @@ export const MutesCmd = mutesCmd({
|
|||
await listMessage.edit({ components: [row] });
|
||||
|
||||
const filter = (iac: MessageComponentInteraction) => iac.message.id === listMessage.id;
|
||||
const collector = listMessage.createMessageComponentInteractionCollector(filter, {
|
||||
const collector = listMessage.createMessageComponentInteractionCollector({
|
||||
filter,
|
||||
time: stopCollectionDebounce,
|
||||
});
|
||||
|
||||
collector.on("collect", async (interaction: MessageComponentInteraction) => {
|
||||
if (msg.author.id !== interaction.user.id) {
|
||||
interaction.reply(`You are not permitted to use these buttons.`, { ephemeral: true });
|
||||
interaction.reply({ content: `You are not permitted to use these buttons.`, ephemeral: true });
|
||||
} else {
|
||||
collector.resetTimer();
|
||||
if (interaction.customID === `previousButton:${idMod}` && currentPage > 1) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { resolveMember, stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
|
@ -23,7 +24,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginT
|
|||
newRoles =
|
||||
muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles;
|
||||
for (const toRestore of mute.roles_to_restore) {
|
||||
if (guildRoles.has(toRestore) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
}
|
||||
await member.roles.set(newRoles);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { GuildMember, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { MutesPluginType } from "../types";
|
||||
|
||||
export function memberHasMutedRole(pluginData: GuildPluginData<MutesPluginType>, member: GuildMember): boolean {
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
return muteRole ? member.roles.cache.has(muteRole) : false;
|
||||
return muteRole ? member.roles.cache.has(muteRole as Snowflake) : false;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel, User } from "discord.js";
|
||||
import { Snowflake, TextChannel, User } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -86,7 +86,7 @@ export async function muteUser(
|
|||
}
|
||||
|
||||
// Apply mute role if it's missing
|
||||
if (!currentUserRoles.includes(muteRole)) {
|
||||
if (!currentUserRoles.includes(muteRole as Snowflake)) {
|
||||
try {
|
||||
await member.roles.add(muteRole);
|
||||
} catch (e) {
|
||||
|
@ -125,7 +125,7 @@ export async function muteUser(
|
|||
if (moveToVoiceChannel || cfg.kick_from_voice_channel) {
|
||||
// TODO: Add back the voiceState check once we figure out how to get voice state for guild members that are loaded on-demand
|
||||
try {
|
||||
await member.edit({ channel: moveToVoiceChannel });
|
||||
await member.edit({ channel: moveToVoiceChannel as Snowflake });
|
||||
} catch {} // tslint:disable-line
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,8 @@ export async function muteUser(
|
|||
}
|
||||
|
||||
const useChannel = existingMute ? config.message_on_update : config.message_on_mute;
|
||||
const channel = config.message_channel && pluginData.guild.channels.cache.get(config.message_channel);
|
||||
const channel =
|
||||
config.message_channel && pluginData.guild.channels.cache.get(config.message_channel as Snowflake);
|
||||
if (useChannel && channel instanceof TextChannel) {
|
||||
contactMethods.push({ type: "channel", channel });
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -35,7 +36,7 @@ export async function unmuteUser(
|
|||
const lock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
if (muteRole && member.roles.cache.has(muteRole)) {
|
||||
if (muteRole && member.roles.cache.has(muteRole as Snowflake)) {
|
||||
await member.roles.remove(muteRole);
|
||||
}
|
||||
if (existingMute?.roles_to_restore) {
|
||||
|
@ -43,7 +44,7 @@ export async function unmuteUser(
|
|||
let newRoles: string[] = member.roles.cache.keyArray();
|
||||
newRoles = muteRole && newRoles.includes(muteRole) ? newRoles.splice(newRoles.indexOf(muteRole), 1) : newRoles;
|
||||
for (const toRestore of existingMute.roles_to_restore) {
|
||||
if (guildRoles.has(toRestore) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
if (guildRoles.has(toRestore as Snowflake) && toRestore !== muteRole) newRoles.push(toRestore);
|
||||
}
|
||||
await member.roles.set(newRoles);
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ export async function unmuteUser(
|
|||
});
|
||||
|
||||
// Log the action
|
||||
const mod = pluginData.client.users.fetch(modId);
|
||||
const mod = pluginData.client.users.fetch(modId as Snowflake);
|
||||
if (unmuteTime) {
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_TIMED_UNMUTE, {
|
||||
mod: stripObjectToScalars(mod),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { PingableRole } from "../../../data/entities/PingableRole";
|
||||
import { PingableRolesPluginType } from "../types";
|
||||
|
@ -7,7 +8,7 @@ export function disablePingableRoles(
|
|||
pingableRoles: PingableRole[],
|
||||
) {
|
||||
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;
|
||||
|
||||
role.edit(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { PingableRole } from "../../../data/entities/PingableRole";
|
||||
import { PingableRolesPluginType } from "../types";
|
||||
|
@ -7,7 +8,7 @@ export function enablePingableRoles(
|
|||
pingableRoles: PingableRole[],
|
||||
) {
|
||||
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;
|
||||
|
||||
role.edit(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { postCmd } from "../types";
|
||||
|
@ -25,9 +25,12 @@ export const EditCmd = postCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
(pluginData.guild.channels.cache.get(savedMessage.channel_id) as TextChannel).messages.edit(savedMessage.id, {
|
||||
content: formatContent(args.content),
|
||||
});
|
||||
(pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake) as TextChannel).messages.edit(
|
||||
savedMessage.id as Snowflake,
|
||||
{
|
||||
content: formatContent(args.content),
|
||||
},
|
||||
);
|
||||
sendSuccessMessage(pluginData, msg.channel, "Message edited");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageEmbed, TextChannel } from "discord.js";
|
||||
import { MessageEmbed, Snowflake, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { trimLines } from "../../../utils";
|
||||
|
@ -47,9 +47,12 @@ export const EditEmbedCmd = postCmd({
|
|||
if (content) embed.description = formatContent(content);
|
||||
if (color) embed.color = color;
|
||||
|
||||
(pluginData.guild.channels.cache.get(savedMessage.channel_id) as TextChannel).messages.edit(savedMessage.id, {
|
||||
embed,
|
||||
});
|
||||
(pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake) as TextChannel).messages.edit(
|
||||
savedMessage.id as Snowflake,
|
||||
{
|
||||
embeds: [embed],
|
||||
},
|
||||
);
|
||||
await sendSuccessMessage(pluginData, msg.channel, "Embed edited");
|
||||
|
||||
if (args.content) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
if (downloadedAttachment) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel, User } from "discord.js";
|
||||
import { Snowflake, TextChannel, User } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -12,10 +12,10 @@ const SCHEDULED_POST_CHECK_INTERVAL = 5 * SECONDS;
|
|||
export async function scheduledPostLoop(pluginData: GuildPluginData<PostPluginType>) {
|
||||
const duePosts = await pluginData.state.scheduledPosts.getDueScheduledPosts();
|
||||
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) {
|
||||
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,
|
||||
username,
|
||||
discriminator,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Message } from "discord.js";
|
||||
import { Message, Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isDiscordRESTError } from "../../../utils";
|
||||
|
@ -23,7 +23,7 @@ export const ClearReactionRolesCmd = reactionRolesCmd({
|
|||
|
||||
let targetMessage: Message;
|
||||
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) {
|
||||
if (isDiscordRESTError(err) && err.code === 50001) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Missing access to the specified message");
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { canUseEmoji, isDiscordRESTError, isValidEmoji, noop, trimPluginDescription } from "../../../utils";
|
||||
|
@ -39,7 +40,7 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
|||
|
||||
let targetMessage;
|
||||
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) {
|
||||
if (isDiscordRESTError(e)) {
|
||||
sendErrorMessage(pluginData, msg.channel, `Error ${e.code} while getting message: ${e.message}`);
|
||||
|
@ -94,7 +95,7 @@ export const InitReactionRolesCmd = reactionRolesCmd({
|
|||
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]}`);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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 { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { reactionRolesCmd } from "../types";
|
||||
|
@ -38,12 +38,11 @@ export const PostButtonRolesCmd = reactionRolesCmd({
|
|||
const btn = new MessageButton()
|
||||
.setLabel(button.label ?? "")
|
||||
.setStyle(button.style ?? "PRIMARY")
|
||||
.setType("BUTTON")
|
||||
.setCustomID(customId)
|
||||
.setDisabled(button.disabled ?? false);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,5 +87,5 @@ export const ButtonInteractionEvt = reactionRolesEvt({
|
|||
});
|
||||
|
||||
async function sendEphemeralReply(interaction: MessageComponentInteraction, message: string) {
|
||||
await interaction.reply(message, { ephemeral: true });
|
||||
await interaction.reply({ content: message, ephemeral: true });
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { logger } from "../../../logger";
|
||||
import { resolveMember } from "../../../utils";
|
||||
|
@ -25,8 +26,8 @@ export async function addMemberPendingRoleChange(
|
|||
if (member) {
|
||||
const newRoleIds = new Set(member.roles.cache.keyArray());
|
||||
for (const change of newPendingRoleChangeObj.changes) {
|
||||
if (change.mode === "+") newRoleIds.add(change.roleId);
|
||||
else newRoleIds.delete(change.roleId);
|
||||
if (change.mode === "+") newRoleIds.add(change.roleId as Snowflake);
|
||||
else newRoleIds.delete(change.roleId as Snowflake);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ReactionRole } from "../../../data/entities/ReactionRole";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -17,7 +17,7 @@ export async function applyReactionRoleReactionsToMessage(
|
|||
messageId: string,
|
||||
reactionRoles: ReactionRole[],
|
||||
): 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;
|
||||
|
||||
const errors: string[] = [];
|
||||
|
@ -25,7 +25,7 @@ export async function applyReactionRoleReactionsToMessage(
|
|||
|
||||
let targetMessage;
|
||||
try {
|
||||
targetMessage = await channel.messages.fetch(messageId);
|
||||
targetMessage = await channel.messages.fetch(messageId as Snowflake);
|
||||
} catch (e) {
|
||||
if (isDiscordRESTError(e)) {
|
||||
if (e.code === 10008) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageButton, MessageActionRow, MessageComponentInteraction } from "discord.js";
|
||||
import { MessageButton, MessageActionRow, MessageComponentInteraction, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin";
|
||||
|
@ -33,12 +33,11 @@ export async function handleOpenMenu(
|
|||
const btn = new MessageButton()
|
||||
.setLabel(menuButton.label ?? "")
|
||||
.setStyle("PRIMARY")
|
||||
.setType("BUTTON")
|
||||
.setCustomID(customId)
|
||||
.setDisabled(menuButton.disabled ?? false);
|
||||
|
||||
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);
|
||||
}
|
||||
menuButtons.push(btn);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ReactionRolesPluginType } from "../types";
|
||||
import { ButtonMenuActions } from "./buttonMenuActions";
|
||||
|
@ -5,7 +6,7 @@ import { ButtonMenuActions } from "./buttonMenuActions";
|
|||
export const BUTTON_CONTEXT_SEPARATOR = "::";
|
||||
|
||||
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;
|
||||
} else {
|
||||
return ButtonMenuActions.OPEN_MENU;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { disableLinkPreviews } from "knub/dist/helpers";
|
||||
|
@ -12,7 +12,7 @@ const MAX_TRIES = 3;
|
|||
export async function postDueRemindersLoop(pluginData: GuildPluginData<RemindersPluginType>) {
|
||||
const pendingReminders = await pluginData.state.reminders.getDueReminders();
|
||||
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) {
|
||||
try {
|
||||
// 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)\``,
|
||||
),
|
||||
allowedMentions: {
|
||||
users: [reminder.user_id],
|
||||
users: [reminder.user_id as Snowflake],
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await channel.send({
|
||||
content: disableLinkPreviews(`Reminder for <@!${reminder.user_id}>: ${reminder.body}`),
|
||||
allowedMentions: {
|
||||
users: [reminder.user_id],
|
||||
users: [reminder.user_id as Snowflake],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Role } from "discord.js";
|
||||
import { Role, Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||
|
@ -31,7 +31,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
|||
const hasUnknownRoles = matchedRoleIds.length !== roleNames.length;
|
||||
|
||||
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)
|
||||
.reduce((map, role) => {
|
||||
map.set(role.id, role);
|
||||
|
@ -68,10 +68,10 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
|||
newRoleIds.delete(roleId);
|
||||
rolesToAdd.delete(roleId);
|
||||
|
||||
if (msg.member.roles.cache.has(roleId)) {
|
||||
removed.add(pluginData.guild.roles.cache.get(roleId)!);
|
||||
if (msg.member.roles.cache.has(roleId as Snowflake)) {
|
||||
removed.add(pluginData.guild.roles.cache.get(roleId as Snowflake)!);
|
||||
} else {
|
||||
skipped.add(pluginData.guild.roles.cache.get(roleId)!);
|
||||
skipped.add(pluginData.guild.roles.cache.get(roleId as Snowflake)!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,6 @@ export const RoleHelpCmd = selfGrantableRolesCmd({
|
|||
color: parseInt("42bff4", 16),
|
||||
};
|
||||
|
||||
msg.channel.send({ embed: helpEmbed });
|
||||
msg.channel.send({ embeds: [helpEmbed] });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||
|
@ -27,7 +28,9 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
|
|||
const roleNames = normalizeRoleNames(splitRoleNames(args.roleNames));
|
||||
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);
|
||||
|
||||
// Remove the roles
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildChannel, Permissions, TextChannel } from "discord.js";
|
||||
import { GuildChannel, Permissions, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -11,7 +11,7 @@ export async function applyBotSlowmodeToUserId(
|
|||
userId: string,
|
||||
) {
|
||||
// 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 =
|
||||
(existingOverride ? existingOverride.deny.bitfield : 0n) | Permissions.FLAGS.SEND_MESSAGES;
|
||||
const newAllowedPermissions =
|
||||
|
@ -22,7 +22,7 @@ export async function applyBotSlowmodeToUserId(
|
|||
{ id: userId, allow: newAllowedPermissions, deny: newDeniedPermissions, type: "member" },
|
||||
]);
|
||||
} 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) {
|
||||
logger.warn(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildChannel, TextChannel } from "discord.js";
|
||||
import { GuildChannel, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
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
|
||||
// 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.
|
||||
await channel.permissionOverwrites.get(userId)?.delete();
|
||||
await channel.permissionOverwrites.get(userId as Snowflake)?.delete();
|
||||
} catch (e) {
|
||||
if (!force) {
|
||||
throw e;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildChannel, TextChannel } from "discord.js";
|
||||
import { GuildChannel, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -9,7 +9,7 @@ import { clearBotSlowmodeFromUserId } from "./clearBotSlowmodeFromUserId";
|
|||
export async function clearExpiredSlowmodes(pluginData: GuildPluginData<SlowmodePluginType>) {
|
||||
const expiredSlowmodeUsers = await pluginData.state.slowmodes.getExpiredSlowmodeUsers();
|
||||
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) {
|
||||
await pluginData.state.slowmodes.clearSlowmodeUser(user.channel_id, user.user_id);
|
||||
continue;
|
||||
|
@ -20,7 +20,8 @@ export async function clearExpiredSlowmodes(pluginData: GuildPluginData<Slowmode
|
|||
} catch (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, {
|
||||
body: `Failed to clear slowmode permissions from {userMention(user)} in {channelMention(channel)}`,
|
||||
user: stripObjectToScalars(realUser),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -15,7 +15,7 @@ import { applyBotSlowmodeToUserId } from "./applyBotSlowmodeToUserId";
|
|||
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
|
||||
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;
|
||||
|
||||
// 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
|
||||
const userHasSlowmode = await pluginData.state.slowmodes.userHasSlowmode(channel.id, msg.user_id);
|
||||
if (userHasSlowmode) {
|
||||
const message = await channel.messages.fetch(msg.id);
|
||||
const message = await channel.messages.fetch(msg.id as Snowflake);
|
||||
if (message) {
|
||||
message.delete();
|
||||
return thisMsgLock.interrupt();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
|
@ -123,7 +123,9 @@ export async function logAndDetectMessageSpam(
|
|||
// Then, if enabled, remove the spam messages
|
||||
if (spamConfig.clean !== false) {
|
||||
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
|
||||
|
@ -146,7 +148,7 @@ export async function logAndDetectMessageSpam(
|
|||
clearRecentUserActions(pluginData, type, savedMessage.user_id, savedMessage.channel_id);
|
||||
|
||||
// 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);
|
||||
|
||||
// Create a case
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { RecentActionType, SpamPluginType } from "../types";
|
||||
import { logAndDetectMessageSpam } from "./logAndDetectMessageSpam";
|
||||
|
||||
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({
|
||||
userId: savedMessage.user_id,
|
||||
channelId: savedMessage.channel_id,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { getEmojiInString, getRoleMentions, getUrlsInString, getUserMentions } from "../../../utils";
|
||||
|
@ -7,7 +8,7 @@ import { logAndDetectMessageSpam } from "./logAndDetectMessageSpam";
|
|||
export async function onMessageCreate(pluginData: GuildPluginData<SpamPluginType>, savedMessage: SavedMessage) {
|
||||
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({
|
||||
userId: savedMessage.user_id,
|
||||
channelId: savedMessage.channel_id,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { starboardCmd } from "../types";
|
||||
|
@ -23,7 +23,7 @@ export const MigratePinsCmd = starboardCmd({
|
|||
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)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Starboard has an unknown/invalid channel id");
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Message, TextChannel } from "discord.js";
|
||||
import { Message, Snowflake, TextChannel } from "discord.js";
|
||||
import { noop, resolveMember } from "../../../utils";
|
||||
import { allStarboardsLock } from "../../../utils/lockNameHelpers";
|
||||
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 (starboard.show_star_count) {
|
||||
for (const starboardMessage of starboardMessages) {
|
||||
const channel = pluginData.guild.channels.cache.get(starboardMessage.starboard_channel_id) as TextChannel;
|
||||
const realStarboardMessage = await channel.messages.fetch(starboardMessage.starboard_message_id);
|
||||
const channel = pluginData.guild.channels.cache.get(
|
||||
starboardMessage.starboard_channel_id as Snowflake,
|
||||
) as TextChannel;
|
||||
const realStarboardMessage = await channel.messages.fetch(
|
||||
starboardMessage.starboard_message_id as Snowflake,
|
||||
);
|
||||
await updateStarboardMessageStarCount(
|
||||
starboard,
|
||||
msg,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Message, TextChannel } from "discord.js";
|
||||
import { Message, MessageEmbed, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { StarboardPluginType, TStarboardOpts } from "../types";
|
||||
import { createStarboardEmbedFromMessage } from "./createStarboardEmbedFromMessage";
|
||||
|
@ -9,13 +9,13 @@ export async function saveMessageToStarboard(
|
|||
msg: Message,
|
||||
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;
|
||||
|
||||
const starCount = (await pluginData.state.starboardReactions.getAllReactionsForMessageId(msg.id)).length;
|
||||
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ export async function updateStarboardMessageStarCount(
|
|||
const embed = starboardMessage.embeds[0]!;
|
||||
embed.fields!.pop(); // Remove pseudo footer
|
||||
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, originalMessage, starEmoji, starCount)); // Create new pseudo footer
|
||||
starboardMessage.edit({ embed });
|
||||
starboardMessage.edit({ embeds: [embed] });
|
||||
}, DEBOUNCE_DELAY);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { PluginOptions } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
|
@ -214,11 +215,14 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
|
|||
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}>`;
|
||||
}
|
||||
|
||||
if (pluginData.guild.channels.cache.has(input)) {
|
||||
if (pluginData.guild.channels.cache.has(input as Snowflake)) {
|
||||
return `<#${input}>`;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions";
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
if (!deleteWithCommand && deleteInvoke) {
|
||||
// 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { TagsPluginType } from "../types";
|
||||
|
@ -7,26 +7,26 @@ export async function onMessageDelete(pluginData: GuildPluginData<TagsPluginType
|
|||
// Command message was deleted -> delete the response as well
|
||||
const commandMsgResponse = await pluginData.state.tags.findResponseByCommandMessageId(msg.id);
|
||||
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;
|
||||
|
||||
const responseMsg = await pluginData.state.savedMessages.find(commandMsgResponse.response_message_id);
|
||||
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;
|
||||
}
|
||||
|
||||
// Response was deleted -> delete the command message as well
|
||||
const responseMsgResponse = await pluginData.state.tags.findResponseByResponseMessageId(msg.id);
|
||||
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;
|
||||
|
||||
const commandMsg = await pluginData.state.savedMessages.find(responseMsgResponse.command_message_id);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export const AvatarCmd = utilityCmd({
|
|||
image: { url: avatarUrl + `${extension}?size=2048` },
|
||||
};
|
||||
embed.title = `Avatar of ${user.username}#${user.discriminator}:`;
|
||||
msg.channel.send({ embed });
|
||||
msg.channel.send({ embeds: [embed] });
|
||||
} else {
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ export const banSearchSignature = {
|
|||
|
||||
page: ct.number({ option: true, shortcut: "p" }),
|
||||
sort: ct.string({ option: true }),
|
||||
"case-sensitive": ct.switchOption({ shortcut: "cs" }),
|
||||
export: ct.switchOption({ shortcut: "e" }),
|
||||
"case-sensitive": ct.switchOption({ def: false, shortcut: "cs" }),
|
||||
export: ct.switchOption({ def: false, shortcut: "e" }),
|
||||
ids: ct.switchOption(),
|
||||
regex: ct.switchOption({ shortcut: "re" }),
|
||||
regex: ct.switchOption({ def: false, shortcut: "re" }),
|
||||
};
|
||||
|
||||
export const BanSearchCmd = utilityCmd({
|
||||
|
|
|
@ -20,6 +20,6 @@ export const ChannelInfoCmd = utilityCmd({
|
|||
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
Loading…
Add table
Reference in a new issue