3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +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

@ -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";