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

More rework progress, remove all eris imports

This commit is contained in:
Dark 2021-06-01 02:05:55 +02:00
parent 8f7a6510eb
commit 52839cc9f3
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
181 changed files with 352 additions and 343 deletions

View file

@ -7,8 +7,8 @@ import { logger } from "../../../logger";
import { scheduleNextDeletion } from "./scheduleNextDeletion";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
import { Constants } from "eris";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { Permissions, TextChannel } from "discord.js";
export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePluginType>) {
const [itemToDelete] = pluginData.state.deletionQueue.splice(0, 1);
@ -16,16 +16,16 @@ export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePlugi
scheduleNextDeletion(pluginData);
const channel = pluginData.guild.channels.get(itemToDelete.message.channel_id);
const channel = pluginData.guild.channels.cache.get(itemToDelete.message.channel_id);
if (!channel) {
// Channel was deleted, ignore
return;
}
const logs = pluginData.getPlugin(LogsPlugin);
const perms = channel.permissionsOf(pluginData.client.user.id);
const perms = channel.permissionsFor(pluginData.client.user!.id);
if (!hasDiscordPermissions(perms, Constants.Permissions.readMessages | Constants.Permissions.readMessageHistory)) {
if (!hasDiscordPermissions(perms, Permissions.FLAGS.VIEW_CHANNEL | Permissions.FLAGS.READ_MESSAGE_HISTORY)) {
logs.log(LogType.BOT_ALERT, {
body: `Missing permissions to read messages or message history in auto-delete channel ${verboseChannelMention(
channel,
@ -34,7 +34,7 @@ export async function deleteNextItem(pluginData: GuildPluginData<AutoDeletePlugi
return;
}
if (!hasDiscordPermissions(perms, Constants.Permissions.manageMessages)) {
if (!hasDiscordPermissions(perms, Permissions.FLAGS.MANAGE_MESSAGES)) {
logs.log(LogType.BOT_ALERT, {
body: `Missing permissions to delete messages in auto-delete channel ${verboseChannelMention(channel)}`,
});
@ -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);
pluginData.client.deleteMessage(itemToDelete.message.channel_id, itemToDelete.message.id).catch(err => {
(channel as TextChannel).messages.delete(itemToDelete.message.id).catch(err => {
if (err.code === 10008) {
// "Unknown Message", probably already deleted by automod or another bot, ignore
return;

View file

@ -3,11 +3,12 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { canUseEmoji, customEmojiRegex, isEmoji } from "../../../utils";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
import { Constants, GuildChannel } from "eris";
import { readChannelPermissions } from "../../../utils/readChannelPermissions";
import { missingPermissionError } from "../../../utils/missingPermissionError";
import { GuildChannel, Permissions } from "discord.js";
const requiredPermissions = readChannelPermissions | Constants.Permissions.addReactions;
const requiredPermissions = readChannelPermissions | Permissions.FLAGS.ADD_REACTIONS;
export const NewAutoReactionsCmd = autoReactionsCmd({
trigger: "auto_reactions",
@ -22,7 +23,7 @@ export const NewAutoReactionsCmd = autoReactionsCmd({
async run({ message: msg, args, pluginData }) {
const finalReactions: string[] = [];
const me = pluginData.guild.members.get(pluginData.client.user.id)!;
const me = pluginData.guild.members.cache.get(pluginData.client.user!.id)!;
const missingPermissions = getMissingChannelPermissions(me, args.channel as GuildChannel, requiredPermissions);
if (missingPermissions) {
sendErrorMessage(

View file

@ -1,17 +1,17 @@
import { autoReactionsEvt } from "../types";
import { isDiscordRESTError } from "../../../utils";
import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { Constants, GuildChannel } from "eris";
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
import { readChannelPermissions } from "../../../utils/readChannelPermissions";
import { missingPermissionError } from "../../../utils/missingPermissionError";
import { GuildChannel, Permissions } from "discord.js";
const p = Constants.Permissions;
const p = Permissions.FLAGS;
export const AddReactionsEvt = autoReactionsEvt({
event: "messageCreate",
event: "message",
allowBots: true,
allowSelf: true,
@ -19,11 +19,11 @@ export const AddReactionsEvt = autoReactionsEvt({
const autoReaction = await pluginData.state.autoReactions.getForChannel(message.channel.id);
if (!autoReaction) return;
const me = pluginData.guild.members.get(pluginData.client.user.id)!;
const me = pluginData.guild.members.cache.get(pluginData.client.user!.id)!;
const missingPermissions = getMissingChannelPermissions(
me,
message.channel as GuildChannel,
readChannelPermissions | p.addReactions,
readChannelPermissions | p.ADD_REACTIONS,
);
if (missingPermissions) {
const logs = pluginData.getPlugin(LogsPlugin);
@ -35,7 +35,7 @@ export const AddReactionsEvt = autoReactionsEvt({
for (const reaction of autoReaction.reactions) {
try {
await message.addReaction(reaction);
await message.react(reaction);
} catch (e) {
if (isDiscordRESTError(e)) {
const logs = pluginData.getPlugin(LogsPlugin);

View file

@ -1,17 +1,16 @@
import { Permissions } from "discord.js";
import * as t from "io-ts";
import { automodAction } from "../helpers";
import { LogType } from "../../../data/LogType";
import { nonNullish, unique } from "../../../utils";
import { Constants } from "eris";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { getMissingPermissions } from "../../../utils/getMissingPermissions";
import { canAssignRole } from "../../../utils/canAssignRole";
import { missingPermissionError } from "../../../utils/missingPermissionError";
import { ignoreRoleChange } from "../functions/ignoredRoleChanges";
import { getMissingPermissions } from "../../../utils/getMissingPermissions";
import { memberRolesLock } from "../../../utils/lockNameHelpers";
import { missingPermissionError } from "../../../utils/missingPermissionError";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { ignoreRoleChange } from "../functions/ignoredRoleChanges";
import { automodAction } from "../helpers";
const p = Constants.Permissions;
const p = Permissions.FLAGS;
export const AddRolesAction = automodAction({
configType: t.array(t.string),
@ -19,9 +18,9 @@ export const AddRolesAction = automodAction({
async apply({ pluginData, contexts, actionConfig, ruleName }) {
const members = unique(contexts.map(c => c.member).filter(nonNullish));
const me = pluginData.guild.members.get(pluginData.client.user.id)!;
const me = pluginData.guild.members.cache.get(pluginData.client.user!.id)!;
const missingPermissions = getMissingPermissions(me.permission, p.manageRoles);
const missingPermissions = getMissingPermissions(me.permissions, p.MANAGE_ROLES);
if (missingPermissions) {
const logs = pluginData.getPlugin(LogsPlugin);
logs.log(LogType.BOT_ALERT, {
@ -42,7 +41,7 @@ export const AddRolesAction = automodAction({
if (rolesWeCannotAssign.length) {
const roleNamesWeCannotAssign = rolesWeCannotAssign.map(
roleId => pluginData.guild.roles.get(roleId)?.name || roleId,
roleId => pluginData.guild.roles.cache.get(roleId)?.name || roleId,
);
const logs = pluginData.getPlugin(LogsPlugin);
logs.log(LogType.BOT_ALERT, {

View file

@ -2,22 +2,17 @@ import * as t from "io-ts";
import { automodAction } from "../helpers";
import { LogType } from "../../../data/LogType";
import {
asyncMap,
createChunkedMessage,
isDiscordRESTError,
messageLink,
resolveMember,
stripObjectToScalars,
tAllowedMentions,
tNormalizedNullOptional,
tNullable,
verboseChannelMention,
} from "../../../utils";
import { resolveActionContactMethods } from "../functions/resolveActionContactMethods";
import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin";
import { TextChannel } from "eris";
import { renderTemplate, TemplateParseError } from "../../../templateFormatter";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { TextChannel } from "discord.js";
import { erisAllowedMentionsToDjsMentionOptions } from "src/utils/erisAllowedMentionsToDjsMentionOptions";
export const AlertAction = automodAction({
configType: t.type({
@ -29,7 +24,7 @@ export const AlertAction = automodAction({
defaultConfig: {},
async apply({ pluginData, contexts, actionConfig, ruleName, matchResult }) {
const channel = pluginData.guild.channels.get(actionConfig.channel);
const channel = pluginData.guild.channels.cache.get(actionConfig.channel);
const logs = pluginData.getPlugin(LogsPlugin);
if (channel && channel instanceof TextChannel) {
@ -73,7 +68,11 @@ export const AlertAction = automodAction({
}
try {
await createChunkedMessage(channel, rendered, actionConfig.allowed_mentions);
await createChunkedMessage(
channel,
rendered,
erisAllowedMentionsToDjsMentionOptions(actionConfig.allowed_mentions),
);
} catch (err) {
if (err.code === 50001) {
logs.log(LogType.BOT_ALERT, {

View file

@ -37,7 +37,7 @@ export const BanAction = automodAction({
const deleteMessageDays = actionConfig.deleteMessageDays || undefined;
const caseArgs: Partial<CaseArgs> = {
modId: pluginData.client.user.id,
modId: pluginData.client.user!.id,
extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [],
automatic: true,
postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined,

View file

@ -2,6 +2,7 @@ import * as t from "io-ts";
import { automodAction } from "../helpers";
import { LogType } from "../../../data/LogType";
import { noop } from "../../../utils";
import { TextChannel } from "discord.js";
export const CleanAction = automodAction({
configType: t.boolean,
@ -29,7 +30,8 @@ export const CleanAction = automodAction({
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE, id);
}
await pluginData.client.deleteMessages(channelId, messageIds).catch(noop);
const channel = pluginData.guild.channels.cache.get(channelId) as TextChannel;
await channel.bulkDelete(messageIds).catch(noop);
}
},
});

View file

@ -25,7 +25,7 @@ export const KickAction = automodAction({
const contactMethods = actionConfig.notify ? resolveActionContactMethods(pluginData, actionConfig) : undefined;
const caseArgs: Partial<CaseArgs> = {
modId: pluginData.client.user.id,
modId: pluginData.client.user!.id,
extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [],
automatic: true,
postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined,

View file

@ -42,7 +42,7 @@ export const MuteAction = automodAction({
const rolesToRestore = actionConfig.restore_roles_on_mute;
const caseArgs: Partial<CaseArgs> = {
modId: pluginData.client.user.id,
modId: pluginData.client.user!.id,
extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [],
automatic: true,
postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined,

View file

@ -8,11 +8,12 @@ import { getMissingPermissions } from "../../../utils/getMissingPermissions";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { missingPermissionError } from "../../../utils/missingPermissionError";
import { canAssignRole } from "../../../utils/canAssignRole";
import { Constants } from "eris";
import { ignoreRoleChange } from "../functions/ignoredRoleChanges";
import { memberRolesLock } from "../../../utils/lockNameHelpers";
import { Permissions } from "discord.js";
const p = Constants.Permissions;
const p = Permissions.FLAGS;
export const RemoveRolesAction = automodAction({
configType: t.array(t.string),
@ -21,9 +22,9 @@ export const RemoveRolesAction = automodAction({
async apply({ pluginData, contexts, actionConfig, ruleName }) {
const members = unique(contexts.map(c => c.member).filter(nonNullish));
const me = pluginData.guild.members.get(pluginData.client.user.id)!;
const me = pluginData.guild.members.cache.get(pluginData.client.user!.id)!;
const missingPermissions = getMissingPermissions(me.permission, p.manageRoles);
const missingPermissions = getMissingPermissions(me.permissions, p.MANAGE_ROLES);
if (missingPermissions) {
const logs = pluginData.getPlugin(LogsPlugin);
logs.log(LogType.BOT_ALERT, {
@ -44,7 +45,7 @@ export const RemoveRolesAction = automodAction({
if (rolesWeCannotRemove.length) {
const roleNamesWeCannotRemove = rolesWeCannotRemove.map(
roleId => pluginData.guild.roles.get(roleId)?.name || roleId,
roleId => pluginData.guild.roles.cache.get(roleId)?.name || roleId,
);
const logs = pluginData.getPlugin(LogsPlugin);
logs.log(LogType.BOT_ALERT, {

View file

@ -12,11 +12,12 @@ import {
unique,
verboseChannelMention,
} from "../../../utils";
import { AdvancedMessageContent, Constants, MessageContent, TextChannel, User } from "eris";
import { AutomodContext } from "../types";
import { renderTemplate } from "../../../templateFormatter";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
import { LogType } from "../../../data/LogType";
import { TextChannel, User, Constants, MessageOptions, Permissions } from "discord.js";
export const ReplyAction = automodAction({
configType: t.union([
@ -32,7 +33,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.get(c.message!.channel_id) instanceof TextChannel);
.filter(c => pluginData.guild.channels.cache.get(c.message!.channel_id) instanceof TextChannel);
const contextsByChannelId = contextsWithTextChannels.reduce((map: Map<string, AutomodContext[]>, context) => {
if (!map.has(context.message!.channel_id)) {
@ -54,16 +55,16 @@ export const ReplyAction = automodAction({
const formatted =
typeof actionConfig === "string"
? await renderReplyText(actionConfig)
: ((await renderRecursively(actionConfig.text, renderReplyText)) as AdvancedMessageContent);
: ((await renderRecursively(actionConfig.text, renderReplyText)) as MessageOptions);
if (formatted) {
const channel = pluginData.guild.channels.get(channelId) as TextChannel;
const channel = pluginData.guild.channels.cache.get(channelId) as TextChannel;
// Check for basic Send Messages and View Channel permissions
if (
!hasDiscordPermissions(
channel.permissionsOf(pluginData.client.user.id),
Constants.Permissions.sendMessages | Constants.Permissions.readMessages,
channel.permissionsFor(pluginData.client.user!.id),
Permissions.FLAGS.SEND_MESSAGES | Permissions.FLAGS.VIEW_CHANNEL,
)
) {
pluginData.state.logs.log(LogType.BOT_ALERT, {
@ -75,7 +76,7 @@ export const ReplyAction = automodAction({
// If the message is an embed, check for embed permissions
if (
typeof formatted !== "string" &&
!hasDiscordPermissions(channel.permissionsOf(pluginData.client.user.id), Constants.Permissions.embedLinks)
!hasDiscordPermissions(channel.permissionsFor(pluginData.client.user!.id), Permissions.FLAGS.EMBED_LINKS)
) {
pluginData.state.logs.log(LogType.BOT_ALERT, {
body: `Missing permissions to reply **with an embed** in ${verboseChannelMention(
@ -85,12 +86,13 @@ export const ReplyAction = automodAction({
continue;
}
const messageContent: StrictMessageContent = typeof formatted === "string" ? { content: formatted } : formatted;
const replyMsg = await channel.createMessage({
const messageContent: MessageOptions = typeof formatted === "string" ? { content: formatted } : formatted;
const replyMsg = await channel.send({
...messageContent,
allowedMentions: {
users: [user.id],
},
split: false,
});
if (typeof actionConfig === "object" && actionConfig.auto_delete) {

View file

@ -2,7 +2,8 @@ import * as t from "io-ts";
import { automodAction } from "../helpers";
import { convertDelayStringToMS, isDiscordRESTError, tDelayString, tNullable } from "../../../utils";
import { LogType } from "../../../data/LogType";
import { Constants, TextChannel } from "eris";
import { Constants, TextChannel } from "discord.js";
import { ChannelTypeStrings } from "src/types";
export const SetSlowmodeAction = automodAction({
configType: t.type({
@ -18,24 +19,22 @@ 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.get(channelId);
const channel = pluginData.guild.channels.cache.get(channelId);
// Only text channels and text channels within categories support slowmodes
if (
!channel ||
!(channel.type === Constants.ChannelTypes.GUILD_TEXT || channel.type === Constants.ChannelTypes.GUILD_CATEGORY)
) {
if (!channel || !(channel.type === ChannelTypeStrings.TEXT || ChannelTypeStrings.CATEGORY)) {
continue;
}
let channelsToSlowmode: TextChannel[] = [];
if (channel.type === Constants.ChannelTypes.GUILD_CATEGORY) {
if (channel.type === ChannelTypeStrings.CATEGORY) {
// Find all text channels within the category
channelsToSlowmode = pluginData.guild.channels.filter(
ch => ch.parentID === channel.id && ch.type === Constants.ChannelTypes.GUILD_TEXT,
) as TextChannel[];
for (const ch of pluginData.guild.channels.cache.values()) {
if (ch.parentID === channel.id && ch.type === ChannelTypeStrings.TEXT)
channelsToSlowmode.push(ch as TextChannel);
}
} else {
channelsToSlowmode.push(channel);
channelsToSlowmode.push(channel as TextChannel);
}
const slowmodeSeconds = Math.ceil(slowmodeMs / 1000);

View file

@ -25,7 +25,7 @@ export const WarnAction = automodAction({
const contactMethods = actionConfig.notify ? resolveActionContactMethods(pluginData, actionConfig) : undefined;
const caseArgs: Partial<CaseArgs> = {
modId: pluginData.client.user.id,
modId: pluginData.client.user!.id,
extraNotes: matchResult.fullSummary ? [matchResult.fullSummary] : [],
automatic: true,
postInCaseLogOverride: actionConfig.postInCaseLog ?? undefined,

View file

@ -10,9 +10,9 @@ export const ViewAntiraidCmd = typedGuildCommand<AutomodPluginType>()({
async run({ pluginData, message }) {
if (pluginData.state.cachedAntiraidLevel) {
message.channel.createMessage(`Anti-raid is set to **${pluginData.state.cachedAntiraidLevel}**`);
message.channel.send(`Anti-raid is set to **${pluginData.state.cachedAntiraidLevel}**`);
} else {
message.channel.createMessage(`Anti-raid is **off**`);
message.channel.send(`Anti-raid is **off**`);
}
},
});

View file

@ -7,19 +7,19 @@ import diff from "lodash.difference";
export const RunAutomodOnMemberUpdate = typedGuildEventListener<AutomodPluginType>()({
event: "guildMemberUpdate",
listener({ pluginData, args: { member, oldMember } }) {
listener({ pluginData, args: { oldMember, newMember } }) {
if (!oldMember) return;
if (isEqual(oldMember.roles, member.roles)) return;
if (isEqual(oldMember.roles, newMember.roles)) return;
const addedRoles = diff(member.roles, oldMember.roles);
const removedRoles = diff(oldMember.roles, member.roles);
const addedRoles = diff(newMember.roles, oldMember.roles);
const removedRoles = diff(oldMember.roles, newMember.roles);
if (addedRoles.length || removedRoles.length) {
const context: AutomodContext = {
timestamp: Date.now(),
user: member.user,
member,
user: newMember.user,
member: newMember,
rolesChanged: {
added: addedRoles,
removed: removedRoles,

View file

@ -1,7 +1,7 @@
import { GuildPluginData } from "knub";
import { AutomodContext, AutomodPluginType } from "../types";
import { runAutomod } from "../functions/runAutomod";
import { User } from "eris";
import { User } from "discord.js";
export async function runAutomodOnAntiraidLevel(
pluginData: GuildPluginData<AutomodPluginType>,

View file

@ -11,8 +11,8 @@ export function runAutomodOnMessage(
message: SavedMessage,
isEdit: boolean,
) {
const user = pluginData.client.users.get(message.user_id);
const member = pluginData.guild.members.get(message.user_id);
const user = pluginData.client.users.cache!.get(message.user_id);
const member = pluginData.guild.members.cache.get(message.user_id);
const context: AutomodContext = {
timestamp: moment.utc(message.posted_at).valueOf(),

View file

@ -2,7 +2,6 @@ import { MatchableTextType } from "./matchMultipleTextTypesOnMessage";
import { AutomodContext, AutomodPluginType } from "../types";
import { messageSummary, verboseChannelMention } from "../../../utils";
import { GuildPluginData } from "knub";
import { User } from "eris";
export function getTextMatchPartialSummary(
pluginData: GuildPluginData<AutomodPluginType>,
@ -11,13 +10,13 @@ export function getTextMatchPartialSummary(
) {
if (type === "message") {
const message = context.message!;
const channel = pluginData.guild.channels.get(message.channel_id);
const channel = pluginData.guild.channels.cache.get(message.channel_id);
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.get(message.channel_id);
const channel = pluginData.guild.channels.cache.get(message.channel_id);
const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``;
return `message embed in ${channelMention}:\n${messageSummary(message)}`;

View file

@ -2,6 +2,7 @@ import { SavedMessage } from "../../../data/entities/SavedMessage";
import { resolveMember } from "../../../utils";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { Activity, Constants } from "discord.js";
type TextTriggerWithMultipleMatchTypes = {
match_messages: boolean;
@ -40,19 +41,21 @@ export async function* matchMultipleTextTypesOnMessage(
}
if (trigger.match_visible_names) {
yield ["visiblename", member.nick || msg.data.author.username];
yield ["visiblename", member.nickname || msg.data.author.username];
}
if (trigger.match_usernames) {
yield ["username", `${msg.data.author.username}#${msg.data.author.discriminator}`];
}
if (trigger.match_nicknames && member.nick) {
yield ["nickname", member.nick];
if (trigger.match_nicknames && member.nickname) {
yield ["nickname", member.nickname];
}
// type 4 = custom status
if (trigger.match_custom_status && member.game?.type === 4 && member.game?.state) {
yield ["customstatus", member.game.state];
for (const activity of member.presence.activities) {
if (activity.type === Constants.ActivityTypes[4]) {
yield ["customstatus", `${activity.emoji} ${activity.name}`];
break;
}
}
}

View file

@ -1,8 +1,9 @@
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { TextChannel } from "eris";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { TextChannel } from "discord.js";
export function resolveActionContactMethods(
pluginData: GuildPluginData<AutomodPluginType>,
@ -18,7 +19,7 @@ export function resolveActionContactMethods(
throw new RecoverablePluginError(ERRORS.NO_USER_NOTIFICATION_CHANNEL);
}
const channel = pluginData.guild.channels.get(actionConfig.notifyChannel);
const channel = pluginData.guild.channels.cache.get(actionConfig.notifyChannel);
if (!(channel instanceof TextChannel)) {
throw new RecoverablePluginError(ERRORS.INVALID_USER_NOTIFICATION_CHANNEL);
}

View file

@ -5,14 +5,14 @@ import { availableActions } from "../actions/availableActions";
import { AutomodTriggerMatchResult } from "../helpers";
import { CleanAction } from "../actions/clean";
import { checkAndUpdateCooldown } from "./checkAndUpdateCooldown";
import { TextChannel } from "eris";
import { TextChannel } from "discord.js";
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.get(userId));
const member = context.member || (userId && pluginData.guild.members.get(userId)) || null;
const user = context.user || (userId && pluginData.client.users!.cache.get(userId));
const member = context.member || (userId && pluginData.guild.members.cache.get(userId)) || null;
const channelId = context.message?.channel_id;
const channel = channelId ? (pluginData.guild.channels.get(channelId) as TextChannel) : null;
const channel = channelId ? (pluginData.guild.channels.cache.get(channelId) as TextChannel) : null;
const categoryId = channel?.parentID;
const config = await pluginData.config.getMatchingConfig({

View file

@ -1,10 +1,10 @@
import { User } from "eris";
import { GuildPluginData } from "knub";
import { AutomodPluginType } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
import { stripObjectToScalars } from "../../../utils";
import { runAutomodOnAntiraidLevel } from "../events/runAutomodOnAntiraidLevel";
import { User } from "discord.js";
export async function setAntiraidLevel(
pluginData: GuildPluginData<AutomodPluginType>,

View file

@ -21,7 +21,7 @@ export const AnyMessageTrigger = automodTrigger<AnyMessageResultType>()({
},
renderMatchInformation({ pluginData, contexts, matchResult }) {
const channel = pluginData.guild.channels.get(contexts[0].message!.channel_id);
const channel = pluginData.guild.channels.cache.get(contexts[0].message!.channel_id);
return `Matched message (\`${contexts[0].message!.id}\`) in ${
channel ? verboseChannelMention(channel) : "Unknown Channel"
}`;

View file

@ -73,7 +73,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
},
renderMatchInformation({ pluginData, contexts, matchResult }) {
const channel = pluginData.guild.channels.get(contexts[0].message!.channel_id)!;
const channel = pluginData.guild.channels.cache.get(contexts[0].message!.channel_id)!;
const prettyChannel = verboseChannelMention(channel);
return (

View file

@ -33,7 +33,7 @@ export const RoleAddedTrigger = automodTrigger<RoleAddedMatchResult>()({
},
renderMatchInformation({ matchResult, pluginData, contexts }) {
const role = pluginData.guild.roles.get(matchResult.extra.matchedRoleId);
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId);
const roleName = role?.name || "Unknown";
const member = contexts[0].member!;
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;

View file

@ -33,7 +33,7 @@ export const RoleRemovedTrigger = automodTrigger<RoleAddedMatchResult>()({
},
renderMatchInformation({ matchResult, pluginData, contexts }) {
const role = pluginData.guild.roles.get(matchResult.extra.matchedRoleId);
const role = pluginData.guild.roles.cache.get(matchResult.extra.matchedRoleId);
const roleName = role?.name || "Unknown";
const member = contexts[0].member!;
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;

View file

@ -4,7 +4,7 @@ import { BasePluginType, CooldownManager } from "knub";
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildLogs } from "../../data/GuildLogs";
import { SavedMessage } from "../../data/entities/SavedMessage";
import { Member, User } from "eris";
import { AvailableTriggers } from "./triggers/availableTriggers";
import { AvailableActions } from "./actions/availableActions";
import { Queue } from "../../Queue";
@ -16,6 +16,7 @@ import { RegExpRunner } from "../../RegExpRunner";
import { CounterEvents } from "../Counters/types";
import { ModActionsEvents, ModActionType } from "../ModActions/types";
import { MutesEvents } from "../Mutes/types";
import { GuildMember, User } from "discord.js";
export const Rule = t.type({
enabled: t.boolean,
@ -113,7 +114,7 @@ export interface AutomodContext {
};
user?: User;
message?: SavedMessage;
member?: Member;
member?: GuildMember;
joined?: boolean;
rolesChanged?: {
added?: string[];

View file

@ -1,7 +1,7 @@
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
import { BotControlPluginType, ConfigSchema } from "./types";
import { GuildArchives } from "../../data/GuildArchives";
import { TextChannel } from "eris";
import { sendSuccessMessage } from "../../pluginUtils";
import { getActiveReload, resetActiveReload } from "./activeReload";
import { ReloadGlobalPluginsCmd } from "./commands/ReloadGlobalPluginsCmd";
@ -18,6 +18,7 @@ import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
import { ListDashboardUsersCmd } from "./commands/ListDashboardUsersCmd";
import { ListDashboardPermsCmd } from "./commands/ListDashboardPermsCmd";
import { EligibleCmd } from "./commands/EligibleCmd";
import { TextChannel } from "discord.js";
const defaultOptions = {
config: {
@ -47,7 +48,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
EligibleCmd,
],
afterLoad(pluginData) {
async afterLoad(pluginData) {
pluginData.state.archives = new GuildArchives(0);
pluginData.state.allowedGuilds = new AllowedGuilds();
pluginData.state.configs = new Configs();
@ -58,9 +59,9 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
const [guildId, channelId] = activeReload;
resetActiveReload();
const guild = pluginData.client.guilds.get(guildId);
const guild = await pluginData.client.guilds.fetch(guildId);
if (guild) {
const channel = guild.channels.get(channelId);
const channel = guild.channels.cache.get(channelId);
if (channel instanceof TextChannel) {
sendSuccessMessage(pluginData, channel, "Global plugins reloaded!");
}

View file

@ -3,7 +3,6 @@ import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../..
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { ApiPermissions } from "@shared/apiPermissions";
import { resolveUser, UnknownUser } from "../../../utils";
import { User } from "eris";
export const ListDashboardUsersCmd = botControlCmd({
trigger: ["list_dashboard_users"],

View file

@ -1,7 +1,6 @@
import { botControlCmd } from "../types";
import { isOwnerPreFilter } from "../../../pluginUtils";
import { getActiveReload, setActiveReload } from "../activeReload";
import { TextChannel } from "eris";
export const ReloadGlobalPluginsCmd = botControlCmd({
trigger: "bot_reload_global_plugins",

View file

@ -1,5 +1,5 @@
import { Case } from "../../../data/entities/Case";
import { AdvancedMessageContent, MessageContent } from "eris";
import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes";
import { GuildPluginData, helpers } from "knub";
@ -8,13 +8,14 @@ import { resolveCaseId } from "./resolveCaseId";
import { chunkLines, chunkMessageLines, emptyEmbedValue, messageLink } from "../../../utils";
import { getCaseColor } from "./getCaseColor";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { MessageOptions } from "discord.js";
export async function getCaseEmbed(
pluginData: GuildPluginData<CasesPluginType>,
caseOrCaseId: Case | number,
requestMemberId?: string,
noOriginalCaseLink?: boolean,
): Promise<AdvancedMessageContent> {
): Promise<MessageOptions> {
const theCase = await pluginData.state.cases.with("notes").find(resolveCaseId(caseOrCaseId));
if (!theCase) {
throw new Error("Unknown case");

View file

@ -1,27 +1,30 @@
import { GuildPluginData } from "knub";
import { CasesPluginType } from "../types";
import { Message, MessageContent, MessageFile, TextChannel } from "eris";
import { isDiscordRESTError } from "../../../utils";
import { LogType } from "../../../data/LogType";
import { Case } from "../../../data/entities/Case";
import { getCaseEmbed } from "./getCaseEmbed";
import { resolveCaseId } from "./resolveCaseId";
import { logger } from "../../../logger";
import { FileOptions, Message, MessageOptions, TextChannel } from "discord.js";
export async function postToCaseLogChannel(
pluginData: GuildPluginData<CasesPluginType>,
content: MessageContent,
file?: MessageFile,
content: MessageOptions,
file?: FileOptions[],
): Promise<Message | null> {
const caseLogChannelId = pluginData.config.get().case_log_channel;
if (!caseLogChannelId) return null;
const caseLogChannel = pluginData.guild.channels.get(caseLogChannelId);
const caseLogChannel = pluginData.guild.channels.cache.get(caseLogChannelId);
if (!caseLogChannel || !(caseLogChannel instanceof TextChannel)) return null;
let result;
try {
result = await caseLogChannel.createMessage(content, file);
if (file != undefined) {
content.files = file;
}
result = await caseLogChannel.send({ ...content, split: false });
} catch (e) {
if (isDiscordRESTError(e) && (e.code === 50013 || e.code === 50001)) {
pluginData.state.logs.log(LogType.BOT_ALERT, {
@ -50,7 +53,8 @@ export async function postCaseToCaseLogChannel(
const [channelId, messageId] = theCase.log_message_id.split("-");
try {
await pluginData.client.editMessage(channelId, messageId, caseEmbed);
const channel = pluginData.guild.channels.resolve(channelId) as TextChannel;
await channel.messages.edit(messageId, caseEmbed);
return null;
} catch {} // tslint:disable-line:no-empty
}

View file

@ -1,7 +1,7 @@
import { GuildPluginData } from "knub";
import { CensorPluginType } from "../types";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { Embed, Invite } from "eris";
import { ZalgoRegex } from "../../../data/Zalgo";
import { getInviteCodesInString, getUrlsInString, resolveMember, resolveInvite, isGuildInvite } from "../../../utils";
import cloneDeep from "lodash.clonedeep";

View file

@ -19,7 +19,7 @@ export async function censorMessage(
}
const user = await resolveUser(pluginData.client, savedMessage.user_id);
const channel = pluginData.guild.channels.get(savedMessage.channel_id);
const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id);
pluginData.state.serverLogs.log(LogType.CENSOR, {
user: stripObjectToScalars(user),

View file

@ -1,4 +1,3 @@
import { Attachment, TextChannel } from "eris";
import { downloadFile } from "../../utils";
import fs from "fs";
const fsp = fs.promises;

View file

@ -1,4 +1,3 @@
import { VoiceChannel } from "eris";
import { GuildPluginData } from "knub";
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";

View file

@ -1,7 +1,7 @@
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
import { getCompanionChannelOptsForVoiceChannelId } from "./getCompanionChannelOptsForVoiceChannelId";
import { GuildPluginData } from "knub";
import { TextChannel, VoiceChannel } from "eris";
import { isDiscordRESTError, MINUTES } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
@ -63,13 +63,13 @@ export async function handleCompanionPermissions(
try {
for (const channelId of permsToDelete) {
const channel = pluginData.guild.channels.get(channelId);
const channel = pluginData.guild.channels.cache.get(channelId);
if (!channel || !(channel instanceof TextChannel)) continue;
await channel.deletePermission(userId, `Companion Channel for ${oldChannel!.id} | User Left`);
}
for (const [channelId, permissions] of permsToSet) {
const channel = pluginData.guild.channels.get(channelId);
const channel = pluginData.guild.channels.cache.get(channelId);
if (!channel || !(channel instanceof TextChannel)) continue;
await channel.editPermission(
userId,

View file

@ -3,7 +3,7 @@ import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { resolveChannel, waitForReply } from "knub/dist/helpers";
import { TextChannel, User } from "eris";
import { resolveUser, UnknownUser } from "../../../utils";
import { changeCounterValue } from "../functions/changeCounterValue";

View file

@ -3,7 +3,7 @@ import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { resolveChannel, waitForReply } from "knub/dist/helpers";
import { TextChannel, User } from "eris";
import { confirm, MINUTES, noop, resolveUser, trimMultilineString, UnknownUser } from "../../../utils";
import { changeCounterValue } from "../functions/changeCounterValue";
import { setCounterValue } from "../functions/setCounterValue";

View file

@ -3,7 +3,7 @@ import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { resolveChannel, waitForReply } from "knub/dist/helpers";
import { TextChannel } from "eris";
import { resolveUser, UnknownUser } from "../../../utils";
import { setCounterValue } from "../functions/setCounterValue";

View file

@ -3,7 +3,7 @@ import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { resolveChannel, waitForReply } from "knub/dist/helpers";
import { TextChannel, User } from "eris";
import { resolveUser, UnknownUser } from "../../../utils";
import { changeCounterValue } from "../functions/changeCounterValue";
import { setCounterValue } from "../functions/setCounterValue";

View file

@ -3,7 +3,7 @@ import { CountersPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { resolveChannel, waitForReply } from "knub/dist/helpers";
import { TextChannel, User } from "eris";
import { resolveUser, UnknownUser } from "../../../utils";
export const ViewCounterCmd = typedGuildCommand<CountersPluginType>()({

View file

@ -5,7 +5,6 @@ import { renderTemplate } from "../../../templateFormatter";
import { resolveMember } from "../../../utils";
import { ActionError } from "../ActionError";
import { canActOn } from "../../../pluginUtils";
import { Message } from "eris";
export const AddRoleAction = t.type({
type: t.literal("add_role"),

View file

@ -18,7 +18,7 @@ export async function makeRoleMentionableAction(
event: TCustomEvent,
eventData: any,
) {
const role = pluginData.guild.roles.get(action.role);
const role = pluginData.guild.roles.cache.get(action.role);
if (!role) {
throw new ActionError(`Unknown role: ${role}`);
}

View file

@ -16,7 +16,7 @@ export async function makeRoleUnmentionableAction(
event: TCustomEvent,
eventData: any,
) {
const role = pluginData.guild.roles.get(action.role);
const role = pluginData.guild.roles.cache.get(action.role);
if (!role) {
throw new ActionError(`Unknown role: ${role}`);
}

View file

@ -3,7 +3,6 @@ import { CustomEventsPluginType } from "../types";
import * as t from "io-ts";
import { renderTemplate } from "../../../templateFormatter";
import { ActionError } from "../ActionError";
import { TextChannel } from "eris";
export const MessageAction = t.type({
type: t.literal("message"),
@ -18,7 +17,7 @@ export async function messageAction(
values: any,
) {
const targetChannelId = await renderTemplate(action.channel, values, false);
const targetChannel = pluginData.guild.channels.get(targetChannelId);
const targetChannel = pluginData.guild.channels.cache.get(targetChannelId);
if (!targetChannel) throw new ActionError("Unknown target channel");
if (!(targetChannel instanceof TextChannel)) throw new ActionError("Target channel is not a text channel");

View file

@ -5,7 +5,6 @@ import { renderTemplate } from "../../../templateFormatter";
import { resolveMember } from "../../../utils";
import { ActionError } from "../ActionError";
import { canActOn } from "../../../pluginUtils";
import { Message, VoiceChannel } from "eris";
export const MoveToVoiceChannelAction = t.type({
type: t.literal("move_to_vc"),
@ -30,7 +29,7 @@ export async function moveToVoiceChannelAction(
}
const targetChannelId = await renderTemplate(action.channel, values, false);
const targetChannel = pluginData.guild.channels.get(targetChannelId);
const targetChannel = pluginData.guild.channels.cache.get(targetChannelId);
if (!targetChannel) throw new ActionError("Unknown target channel");
if (!(targetChannel instanceof VoiceChannel)) throw new ActionError("Target channel is not a voice channel");

View file

@ -24,7 +24,7 @@ export async function setChannelPermissionOverridesAction(
event: TCustomEvent,
eventData: any,
) {
const channel = pluginData.guild.channels.get(action.channel);
const channel = pluginData.guild.channels.cache.get(action.channel);
if (!channel) {
throw new ActionError(`Unknown channel: ${action.channel}`);
}

View file

@ -2,7 +2,7 @@ import { GuildPluginData } from "knub";
import { CustomEventsPluginType, TCustomEvent } from "../types";
import { sendErrorMessage } from "../../../pluginUtils";
import { ActionError } from "../ActionError";
import { Message } from "eris";
import { addRoleAction } from "../actions/addRoleAction";
import { createCaseAction } from "../actions/createCaseAction";
import { moveToVoiceChannelAction } from "../actions/moveToVoiceChannelAction";

View file

@ -2,7 +2,6 @@ import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
import { BasePluginType, typedGlobalEventListener, GlobalPluginData } from "knub";
import * as t from "io-ts";
import { AllowedGuilds } from "../../data/AllowedGuilds";
import { Guild } from "eris";
interface GuildAccessMonitorPluginType extends BasePluginType {
config: {};

View file

@ -1,6 +1,5 @@
import { locateUserEvt } from "../types";
import { sendAlerts } from "../utils/sendAlerts";
import { TextableChannel, VoiceChannel } from "eris";
export const ChannelJoinAlertsEvt = locateUserEvt({
event: "voiceChannelJoin",

View file

@ -1,5 +1,3 @@
import { VoiceChannel } from "eris";
export async function createOrReuseInvite(vc: VoiceChannel) {
const existingInvites = await vc.getInvites();

View file

@ -1,4 +1,3 @@
import { Member, TextableChannel } from "eris";
import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { sendErrorMessage } from "../../../pluginUtils";

View file

@ -2,7 +2,7 @@ import { GuildPluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { resolveMember } from "../../../utils";
import { sendWhere } from "./sendWhere";
import { TextableChannel } from "eris";
import { moveMember } from "./moveMember";
export async function sendAlerts(pluginData: GuildPluginData<LocateUserPluginType>, userId: string) {

View file

@ -1,4 +1,3 @@
import { Invite, Member, TextableChannel, VoiceChannel } from "eris";
import { getInviteLink } from "knub/dist/helpers";
import { createOrReuseInvite } from "./createOrReuseInvite";
import { GuildPluginData } from "knub";
@ -12,7 +11,7 @@ export async function sendWhere(
prepend: string,
) {
const voice = member.voiceState.channelID
? (pluginData.guild.channels.get(member.voiceState.channelID) as VoiceChannel)
? (pluginData.guild.channels.cache.get(member.voiceState.channelID) as VoiceChannel)
: null;
if (voice == null) {

View file

@ -14,7 +14,6 @@ import { LogsGuildMemberRemoveEvt } from "./events/LogsGuildMemberRemoveEvt";
import { LogsGuildMemberUpdateEvt } from "./events/LogsUserUpdateEvts";
import { LogsChannelCreateEvt, LogsChannelDeleteEvt } from "./events/LogsChannelModifyEvts";
import { LogsRoleCreateEvt, LogsRoleDeleteEvt } from "./events/LogsRoleModifyEvts";
import { LogsVoiceJoinEvt, LogsVoiceLeaveEvt, LogsVoiceSwitchEvt } from "./events/LogsVoiceChannelEvts";
import { log } from "./util/log";
import { LogType } from "../../data/LogType";
import { getLogMessage } from "./util/getLogMessage";
@ -23,6 +22,7 @@ import { disableCodeBlocks } from "../../utils";
import { logger } from "../../logger";
import { CasesPlugin } from "../Cases/CasesPlugin";
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
import { LogsVoiceStateUpdateEvt } from "./events/LogsVoiceChannelEvts";
const defaultOptions: PluginOptions<LogsPluginType> = {
config: {
@ -66,9 +66,7 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()({
LogsChannelDeleteEvt,
LogsRoleCreateEvt,
LogsRoleDeleteEvt,
LogsVoiceJoinEvt,
LogsVoiceLeaveEvt,
LogsVoiceSwitchEvt,
LogsVoiceStateUpdateEvt,
],
public: {

View file

@ -1,7 +1,7 @@
import { logsEvt } from "../types";
import { stripObjectToScalars, UnknownUser } from "../../../utils";
import { LogType } from "../../../data/LogType";
import { Constants as ErisConstants } from "eris";
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";
export const LogsGuildBanAddEvt = logsEvt({

View file

@ -3,7 +3,7 @@ import { stripObjectToScalars } from "../../../utils";
import { LogType } from "../../../data/LogType";
export const LogsRoleCreateEvt = logsEvt({
event: "guildRoleCreate",
event: "roleCreate",
async listener(meta) {
meta.pluginData.state.guildLogs.log(LogType.ROLE_CREATE, {
@ -13,7 +13,7 @@ export const LogsRoleCreateEvt = logsEvt({
});
export const LogsRoleDeleteEvt = logsEvt({
event: "guildRoleDelete",
event: "roleDelete",
async listener(meta) {
meta.pluginData.state.guildLogs.log(LogType.ROLE_DELETE, {

View file

@ -1,6 +1,6 @@
import { logsEvt } from "../types";
import { stripObjectToScalars, UnknownUser } from "../../../utils";
import { Constants as ErisConstants } from "eris";
import { LogType } from "../../../data/LogType";
import isEqual from "lodash.isequal";
import diff from "lodash.difference";
@ -61,11 +61,11 @@ export const LogsGuildMemberUpdateEvt = logsEvt({
{
member: logMember,
addedRoles: addedRoles
.map(roleId => pluginData.guild.roles.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(r => r.name)
.join(", "),
removedRoles: removedRoles
.map(roleId => pluginData.guild.roles.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(r => r.name)
.join(", "),
mod: stripObjectToScalars(mod),
@ -79,7 +79,7 @@ export const LogsGuildMemberUpdateEvt = logsEvt({
{
member: logMember,
roles: addedRoles
.map(roleId => pluginData.guild.roles.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(r => r.name)
.join(", "),
mod: stripObjectToScalars(mod),
@ -93,7 +93,7 @@ export const LogsGuildMemberUpdateEvt = logsEvt({
{
member: logMember,
roles: removedRoles
.map(roleId => pluginData.guild.roles.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(roleId => pluginData.guild.roles.cache.get(roleId) || { id: roleId, name: `Unknown (${roleId})` })
.map(r => r.name)
.join(", "),
mod: stripObjectToScalars(mod),

View file

@ -1,7 +1,7 @@
import { logsEvt } from "../types";
import { stripObjectToScalars } from "../../../utils";
import { LogType } from "../../../data/LogType";
/** Merge into single event
export const LogsVoiceJoinEvt = logsEvt({
event: "voiceChannelJoin",
@ -35,3 +35,12 @@ export const LogsVoiceSwitchEvt = logsEvt({
});
},
});
**/
export const LogsVoiceStateUpdateEvt = logsEvt({
event: "voiceStateUpdate",
async listener(meta) {
console.error(`Fixme @LogsVoiceChannelEvts.ts`);
},
});

View file

@ -14,7 +14,6 @@ import { renderTemplate, TemplateParseError } from "../../../templateFormatter";
import { logger } from "../../../logger";
import moment from "moment-timezone";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { MessageContent } from "eris";
export async function getLogMessage(
pluginData: GuildPluginData<LogsPluginType>,

View file

@ -1,7 +1,7 @@
import { GuildPluginData } from "knub";
import { LogsPluginType, TLogChannelMap } from "../types";
import { LogType } from "../../../data/LogType";
import { TextChannel } from "eris";
import { createChunkedMessage, get, noop } from "../../../utils";
import { getLogMessage } from "./getLogMessage";
import { allowTimeout } from "../../../RegExpRunner";
@ -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.get(channelId);
const channel = pluginData.guild.channels.cache.get(channelId);
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.get(value.user_id);
const member = pluginData.guild.members.cache.get(value.user_id);
for (const role of member?.roles || []) {
if (opts.excluded_roles.includes(role)) {
continue logChannelLoop;

View file

@ -1,5 +1,5 @@
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { Attachment } from "eris";
import { useMediaUrls, stripObjectToScalars, resolveUser } from "../../../utils";
import { LogType } from "../../../data/LogType";
import moment from "moment-timezone";
@ -9,7 +9,7 @@ import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
export async function onMessageDelete(pluginData: GuildPluginData<LogsPluginType>, savedMessage: SavedMessage) {
const user = await resolveUser(pluginData.client, savedMessage.user_id);
const channel = pluginData.guild.channels.get(savedMessage.channel_id);
const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id);
if (user) {
// Replace attachment URLs with media URLs

View file

@ -5,7 +5,7 @@ import { LogType } from "../../../data/LogType";
import { getBaseUrl } from "../../../pluginUtils";
export async function onMessageDeleteBulk(pluginData: GuildPluginData<LogsPluginType>, savedMessages: SavedMessage[]) {
const channel = pluginData.guild.channels.get(savedMessages[0].channel_id);
const channel = pluginData.guild.channels.cache.get(savedMessages[0].channel_id);
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(", ");

View file

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

View file

@ -1,8 +1,7 @@
import { messageSaverEvt } from "../types";
import { Message } from "eris";
export const MessageCreateEvt = messageSaverEvt({
event: "messageCreate",
event: "message",
allowBots: true,
allowSelf: true,

View file

@ -1,6 +1,5 @@
import { MessageSaverPluginType } from "./types";
import { GuildPluginData } from "knub";
import { Message, TextChannel } from "eris";
export async function saveMessagesToDB(
pluginData: GuildPluginData<MessageSaverPluginType>,

View file

@ -30,7 +30,7 @@ import { GuildCases } from "../../data/GuildCases";
import { GuildLogs } from "../../data/GuildLogs";
import { ForceUnmuteCmd } from "./commands/ForceunmuteCmd";
import { warnMember } from "./functions/warnMember";
import { Member, Message } from "eris";
import { kickMember } from "./functions/kickMember";
import { banUserId } from "./functions/banUserId";
import { MassmuteCmd } from "./commands/MassmuteCmd";

View file

@ -4,7 +4,7 @@ import { sendErrorMessage } from "../../../pluginUtils";
import { trimLines, createChunkedMessage, emptyEmbedValue, sorter, resolveUser } from "../../../utils";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { asyncMap } from "../../../utils/async";
import { EmbedOptions, User } from "eris";
import { getChunkedEmbedFields } from "../../../utils/getChunkedEmbedFields";
import { getDefaultPrefix } from "knub/dist/commands/commandUtils";
import { getGuildPrefix } from "../../../utils/getGuildPrefix";

View file

@ -12,7 +12,7 @@ import {
chunkArray,
} from "../../../utils";
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
import { EmbedOptions, User } from "eris";
import { getChunkedEmbedFields } from "../../../utils/getChunkedEmbedFields";
import { asyncMap } from "../../../utils/async";
import { CaseTypes } from "../../../data/CaseTypes";

View file

@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { helpers } from "knub";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { TextChannel } from "eris";
import { SECONDS, stripObjectToScalars, trimLines } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";

View file

@ -7,7 +7,7 @@ import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromA
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
import { banUserId } from "../functions/banUserId";
import { CaseTypes } from "../../../data/CaseTypes";
import { TextChannel } from "eris";
import { waitForReply } from "knub/dist/helpers";
import { ignoreEvent } from "../functions/ignoreEvent";
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
@ -46,7 +46,7 @@ export const MassbanCmd = modActionsCmd({
// Verify we can act on each of the users specified
for (const userId of args.userIds) {
const member = pluginData.guild.members.get(userId); // TODO: Get members on demand?
const member = pluginData.guild.members.cache.get(userId); // TODO: Get members on demand?
if (member && !canActOn(pluginData, msg.member, member)) {
sendErrorMessage(pluginData, msg.channel, "Cannot massban one or more users: insufficient permissions");
return;

View file

@ -5,7 +5,7 @@ import { stripObjectToScalars } from "../../../utils";
import { isBanned } from "../functions/isBanned";
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
import { CaseTypes } from "../../../data/CaseTypes";
import { TextChannel } from "eris";
import { waitForReply } from "knub/dist/helpers";
import { ignoreEvent } from "../functions/ignoreEvent";
import { CasesPlugin } from "../../Cases/CasesPlugin";

View file

@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { stripObjectToScalars } from "../../../utils";
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
import { TextChannel } from "eris";
import { waitForReply } from "knub/dist/helpers";
import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger";
@ -43,7 +43,7 @@ export const MassmuteCmd = modActionsCmd({
// Verify we can act upon all users
for (const userId of args.userIds) {
const member = pluginData.guild.members.get(userId);
const member = pluginData.guild.members.cache.get(userId);
if (member && !canActOn(pluginData, msg.member, member)) {
sendErrorMessage(pluginData, msg.channel, "Cannot massmute one or more users: insufficient permissions");
return;

View file

@ -11,7 +11,7 @@ import { isBanned } from "../functions/isBanned";
import { waitForReaction } from "knub/dist/helpers";
import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromArgs";
import { warnMember } from "../functions/warnMember";
import { TextChannel } from "eris";
import { actualMuteUserCmd } from "../functions/actualMuteUserCmd";
const opts = {

View file

@ -11,7 +11,6 @@ import { isBanned } from "../functions/isBanned";
import { waitForReaction } from "knub/dist/helpers";
import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromArgs";
import { warnMember } from "../functions/warnMember";
import { TextChannel } from "eris";
export const WarnCmd = modActionsCmd({
trigger: "warn",

View file

@ -1,7 +1,7 @@
import { IgnoredEventType, modActionsEvt } from "../types";
import { isEventIgnored } from "../functions/isEventIgnored";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { Constants as ErisConstants, User } from "eris";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { CaseTypes } from "../../../data/CaseTypes";
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";

View file

@ -1,7 +1,7 @@
import { IgnoredEventType, modActionsEvt } from "../types";
import { isEventIgnored } from "../functions/isEventIgnored";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { Constants as ErisConstants, User } from "eris";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { CaseTypes } from "../../../data/CaseTypes";
import { logger } from "../../../logger";

View file

@ -1,7 +1,7 @@
import { IgnoredEventType, modActionsEvt } from "../types";
import { isEventIgnored } from "../functions/isEventIgnored";
import { clearIgnoredEvents } from "../functions/clearIgnoredEvents";
import { Constants as ErisConstants, User } from "eris";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { CaseTypes } from "../../../data/CaseTypes";
import { safeFindRelevantAuditLogEntry } from "../../../utils/safeFindRelevantAuditLogEntry";

View file

@ -1,7 +1,7 @@
import { modActionsEvt } from "../types";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
import { Constants, TextChannel } from "eris";
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.get(alertChannelId);
const alertChannel = pluginData.guild.channels.cache.get(alertChannelId);
if (!alertChannel) {
logs.log(LogType.BOT_ALERT, {
body: `Unknown \`alert_channel\` configured for \`mod_actions\`: \`${alertChannelId}\``,
@ -37,8 +37,8 @@ export const PostAlertOnMemberJoinEvt = modActionsEvt({
return;
}
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user.id);
const botPerms = alertChannel.permissionsOf(botMember ?? pluginData.client.user.id);
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user!.id);
const botPerms = alertChannel.permissionsOf(botMember ?? pluginData.client.user!.id);
if (!hasDiscordPermissions(botPerms, Constants.Permissions.sendMessages)) {
logs.log(LogType.BOT_ALERT, {
body: `Missing "Send Messages" permissions for the \`alert_channel\` configured in \`mod_actions\`: \`${alertChannelId}\``,

View file

@ -1,4 +1,3 @@
import { Member, TextChannel } from "eris";
import { LogType } from "../../../data/LogType";
import { IgnoredEventType, ModActionsPluginType } from "../types";
import { errorMessage, resolveUser, resolveMember } from "../../../utils";

View file

@ -1,4 +1,3 @@
import { GuildTextableChannel, Member, Message, TextChannel, User } from "eris";
import { asSingleLine, isDiscordRESTError, UnknownUser } from "../../../utils";
import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { GuildPluginData } from "knub";

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { ModActionsPluginType } from "../types";
import { User, Message, Member } from "eris";
import { UnknownUser, asSingleLine } from "../../../utils";
import { sendErrorMessage, sendSuccessMessage, hasPermission } from "../../../pluginUtils";
import { formatReasonWithAttachments } from "./formatReasonWithAttachments";

View file

@ -8,7 +8,7 @@ import {
ucfirst,
UserNotificationResult,
} from "../../../utils";
import { DiscordRESTError, User } from "eris";
import { renderTemplate } from "../../../templateFormatter";
import { getDefaultContactMethods } from "./getDefaultContactMethods";
import { LogType } from "../../../data/LogType";
@ -99,7 +99,7 @@ export async function banUserId(
const existingTempban = await pluginData.state.tempbans.findExistingTempbanForUserId(user.id);
if (banTime && banTime > 0) {
const selfId = pluginData.client.user.id;
const selfId = pluginData.client.user!.id;
if (existingTempban) {
pluginData.state.tempbans.updateExpiryTime(user.id, banTime, banOptions.modId ?? selfId);
} else {
@ -108,7 +108,7 @@ export async function banUserId(
}
// Create a case for this action
const modId = banOptions.caseArgs?.modId || pluginData.client.user.id;
const modId = banOptions.caseArgs?.modId || pluginData.client.user!.id;
const casesPlugin = pluginData.getPlugin(CasesPlugin);
const noteDetails: string[] = [];

View file

@ -1,5 +1,3 @@
import { Attachment } from "eris";
export function formatReasonWithAttachments(reason: string, attachments: Attachment[]) {
const attachmentUrls = attachments.map(a => a.url);
return ((reason || "") + " " + attachmentUrls.join(" ")).trim();

View file

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

View file

@ -4,14 +4,13 @@ import { isDiscordHTTPError, isDiscordRESTError, SECONDS, sleep } from "../../..
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
import { Constants } from "eris";
export async function isBanned(
pluginData: GuildPluginData<ModActionsPluginType>,
userId: string,
timeout: number = 5 * SECONDS,
): Promise<boolean> {
const botMember = pluginData.guild.members.get(pluginData.client.user.id);
const botMember = pluginData.guild.members.cache.get(pluginData.client.user!.id);
if (botMember && !hasDiscordPermissions(botMember.permissions, Constants.Permissions.banMembers)) {
pluginData.getPlugin(LogsPlugin).log(LogType.BOT_ALERT, {
body: `Missing "Ban Members" permission to check for existing bans`,

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { IgnoredEventType, KickOptions, KickResult, ModActionsPluginType } from "../types";
import { Member } from "eris";
import {
createUserNotificationError,
notifyUser,
@ -63,7 +63,7 @@ export async function kickMember(
};
}
const modId = kickOptions.caseArgs?.modId || pluginData.client.user.id;
const modId = kickOptions.caseArgs?.modId || pluginData.client.user!.id;
// Create a case for this action
const casesPlugin = pluginData.getPlugin(CasesPlugin);

View file

@ -1,4 +1,3 @@
import { TextChannel } from "eris";
import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
export function readContactMethodsFromArgs(args: {

View file

@ -1,4 +1,3 @@
import { Message } from "eris";
import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case";
import { LogType } from "../../../data/LogType";

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { ModActionsPluginType, WarnOptions, WarnResult } from "../types";
import { Member } from "eris";
import { getDefaultContactMethods } from "./getDefaultContactMethods";
import {
createUserNotificationError,
@ -62,7 +62,7 @@ export async function warnMember(
}
}
const modId = warnOptions.caseArgs?.modId ?? pluginData.client.user.id;
const modId = warnOptions.caseArgs?.modId ?? pluginData.client.user!.id;
const casesPlugin = pluginData.getPlugin(CasesPlugin);
const createdCase = await casesPlugin.createCase({

View file

@ -6,7 +6,7 @@ import { GuildCases } from "../../data/GuildCases";
import { GuildLogs } from "../../data/GuildLogs";
import { Case } from "../../data/entities/Case";
import { CaseArgs } from "../Cases/types";
import { TextChannel } from "eris";
import { GuildTempbans } from "../../data/GuildTempbans";
import Timeout = NodeJS.Timeout;
import { EventEmitter } from "events";

View file

@ -13,7 +13,7 @@ import { ClearMutesWithoutRoleCmd } from "./commands/ClearMutesWithoutRoleCmd";
import { ClearMutesCmd } from "./commands/ClearMutesCmd";
import { muteUser } from "./functions/muteUser";
import { unmuteUser } from "./functions/unmuteUser";
import { Member } from "eris";
import { ClearActiveMuteOnMemberBanEvt } from "./events/ClearActiveMuteOnMemberBanEvt";
import { ReapplyActiveMuteOnJoinEvt } from "./events/ReapplyActiveMuteOnJoinEvt";
import { mapToPublicFn } from "../../pluginUtils";

View file

@ -1,5 +1,5 @@
import { mutesCmd } from "../types";
import { User } from "eris";
import { sendSuccessMessage } from "../../../pluginUtils";
export const ClearBannedMutesCmd = mutesCmd({

View file

@ -4,7 +4,6 @@ import { DBDateFormat, isFullMessage, MINUTES, noop, resolveMember } from "../..
import moment from "moment-timezone";
import { humanizeDurationShort } from "../../../humanizeDurationShort";
import { getBaseUrl } from "../../../pluginUtils";
import { Member } from "eris";
export const MutesCmd = mutesCmd({
trigger: "mutes",
@ -112,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.get(mute.user_id);
const user = pluginData.client.user!.get(mute.user_id);
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";

View file

@ -2,7 +2,7 @@ import { GuildPluginData } from "knub";
import { MutesPluginType } from "../types";
import { LogType } from "../../../data/LogType";
import { resolveMember, stripObjectToScalars, UnknownUser } from "../../../utils";
import { MemberOptions } from "eris";
import { memberRolesLock } from "../../../utils/lockNameHelpers";
export async function clearExpiredMutes(pluginData: GuildPluginData<MutesPluginType>) {

View file

@ -1,4 +1,3 @@
import { Member } from "eris";
import { GuildPluginData } from "knub";
import { MutesPluginType } from "../types";

View file

@ -12,7 +12,7 @@ import {
UserNotificationMethod,
} from "../../../utils";
import { renderTemplate } from "../../../templateFormatter";
import { MemberOptions, TextChannel, User } from "eris";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "../../../data/LogType";
@ -42,7 +42,7 @@ export async function muteUser(
// No mod specified -> mark Zeppelin as the mod
if (!muteOptions.caseArgs?.modId) {
muteOptions.caseArgs = muteOptions.caseArgs ?? {};
muteOptions.caseArgs.modId = pluginData.client.user.id;
muteOptions.caseArgs.modId = pluginData.client.user!.id;
}
const user = await resolveUser(pluginData.client, userId);
@ -99,7 +99,7 @@ export async function muteUser(
throw new RecoverablePluginError(ERRORS.INVALID_MUTE_ROLE_ID);
}
const zep = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user.id);
const zep = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user!.id);
const zepRoles = pluginData.guild.roles.filter(x => zep!.roles.includes(x.id));
// If we have roles and one of them is above the muted role, throw generic error
if (zepRoles.length >= 0 && zepRoles.some(zepRole => zepRole.position > actualMuteRole.position)) {
@ -172,7 +172,7 @@ export async function muteUser(
}
const useChannel = existingMute ? config.message_on_update : config.message_on_mute;
const channel = config.message_channel && pluginData.guild.channels.get(config.message_channel);
const channel = config.message_channel && pluginData.guild.channels.cache.get(config.message_channel);
if (useChannel && channel instanceof TextChannel) {
contactMethods.push({ type: "channel", channel });
}

View file

@ -7,7 +7,7 @@ import humanizeDuration from "humanize-duration";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "../../../data/LogType";
import { MemberOptions } from "eris";
import { memberRolesLock } from "../../../utils/lockNameHelpers";
export async function unmuteUser(
@ -19,7 +19,7 @@ export async function unmuteUser(
const existingMute = await pluginData.state.mutes.findExistingMuteForUserId(userId);
const user = await resolveUser(pluginData.client, userId);
const member = await resolveMember(pluginData.client, pluginData.guild, userId); // Grab the fresh member so we don't have stale role info
const modId = caseArgs.modId || pluginData.client.user.id;
const modId = caseArgs.modId || pluginData.client.user!.id;
if (!existingMute && member && !memberHasMutedRole(pluginData, member)) return null;
@ -85,7 +85,7 @@ export async function unmuteUser(
});
// Log the action
const mod = pluginData.client.users.get(modId);
const mod = pluginData.client.user!.get(modId);
if (unmuteTime) {
pluginData.state.serverLogs.log(LogType.MEMBER_TIMED_UNMUTE, {
mod: stripObjectToScalars(mod),

View file

@ -1,7 +1,7 @@
import * as t from "io-ts";
import { tNullable, UserNotificationMethod, UserNotificationResult } from "../../utils";
import { Mute } from "../../data/entities/Mute";
import { Member } from "eris";
import { Case } from "../../data/entities/Case";
import { BasePluginType, typedGuildCommand, typedGuildEventListener } from "knub";
import { GuildLogs } from "../../data/GuildLogs";

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