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:
parent
8f7a6510eb
commit
52839cc9f3
181 changed files with 352 additions and 343 deletions
|
@ -25,7 +25,7 @@ export const SlowmodeClearCmd = slowmodeCmd({
|
|||
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, args.channel, BOT_SLOWMODE_CLEAR_PERMISSIONS);
|
||||
if (missingPermissions) {
|
||||
sendErrorMessage(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { slowmodeCmd } from "../types";
|
||||
import { TextChannel } from "eris";
|
||||
|
||||
import humanizeDuration from "humanize-duration";
|
||||
|
||||
export const SlowmodeGetCmd = slowmodeCmd({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { slowmodeCmd } from "../types";
|
||||
import { GuildChannel, TextChannel } from "eris";
|
||||
|
||||
import { createChunkedMessage } from "knub/dist/helpers";
|
||||
import { errorMessage } from "../../../utils";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { slowmodeCmd } from "../types";
|
||||
import { TextChannel } from "eris";
|
||||
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { asSingleLine, DAYS, disableInlineCode, HOURS, MINUTES } from "../../../utils";
|
||||
|
@ -84,7 +84,7 @@ export const SlowmodeSetCmd = slowmodeCmd({
|
|||
}
|
||||
|
||||
// Verify permissions
|
||||
const channelPermissions = channel.permissionsOf(pluginData.client.user.id);
|
||||
const channelPermissions = channel.permissionsOf(pluginData.client.user!.id);
|
||||
|
||||
if (mode === "native") {
|
||||
const missingPermissions = getMissingPermissions(channelPermissions, NATIVE_SLOWMODE_PERMISSIONS);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Constants } from "eris";
|
||||
|
||||
const p = Constants.Permissions;
|
||||
|
||||
export const NATIVE_SLOWMODE_PERMISSIONS = p.readMessages | p.manageChannels;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Message } from "eris";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { disableBotSlowmodeForChannel } from "./disableBotSlowmodeForChannel";
|
||||
import { noop } from "../../../utils";
|
||||
|
@ -15,7 +14,7 @@ export async function actualDisableSlowmodeCmd(msg: Message, args, pluginData) {
|
|||
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, args.channel, BOT_SLOWMODE_DISABLE_PERMISSIONS);
|
||||
if (missingPermissions) {
|
||||
sendErrorMessage(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { SlowmodePluginType } from "../types";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { Constants, GuildChannel, TextChannel } from "eris";
|
||||
|
||||
import { isDiscordRESTError, stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
@ -18,7 +18,7 @@ export async function applyBotSlowmodeToUserId(
|
|||
try {
|
||||
await channel.editPermission(userId, newAllowedPermissions, newDeniedPermissions, "member");
|
||||
} catch (e) {
|
||||
const user = pluginData.client.users.get(userId) || new UnknownUser({ id: userId });
|
||||
const user = pluginData.client.user!.get(userId) || new UnknownUser({ id: userId });
|
||||
|
||||
if (isDiscordRESTError(e) && e.code === 50013) {
|
||||
logger.warn(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
import { GuildChannel, TextChannel } from "eris";
|
||||
|
||||
export async function clearBotSlowmodeFromUserId(
|
||||
pluginData: GuildPluginData<SlowmodePluginType>,
|
||||
|
|
|
@ -2,14 +2,14 @@ import { GuildPluginData } from "knub";
|
|||
import { SlowmodePluginType } from "../types";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
import { GuildChannel, TextChannel } from "eris";
|
||||
|
||||
import { stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
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.get(user.channel_id);
|
||||
const channel = pluginData.guild.channels.cache.get(user.channel_id);
|
||||
if (!channel) {
|
||||
await pluginData.state.slowmodes.clearSlowmodeUser(user.channel_id, user.user_id);
|
||||
continue;
|
||||
|
@ -20,7 +20,7 @@ export async function clearExpiredSlowmodes(pluginData: GuildPluginData<Slowmode
|
|||
} catch (e) {
|
||||
logger.error(e);
|
||||
|
||||
const realUser = pluginData.client.users.get(user.user_id) || new UnknownUser({ id: user.user_id });
|
||||
const realUser = pluginData.client.user!.get(user.user_id) || 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,3 @@
|
|||
import { GuildChannel, TextChannel } from "eris";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
import { clearBotSlowmodeFromUserId } from "./clearBotSlowmodeFromUserId";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { TextChannel } from "eris";
|
||||
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
import { resolveMember } from "../../../utils";
|
||||
|
@ -15,7 +15,7 @@ import { messageLock } from "../../../utils/lockNameHelpers";
|
|||
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
|
||||
if (msg.is_bot) return;
|
||||
|
||||
const channel = pluginData.guild.channels.get(msg.channel_id) as TextChannel;
|
||||
const channel = pluginData.guild.channels.cache.get(msg.channel_id) as TextChannel;
|
||||
if (!channel) return;
|
||||
|
||||
// Don't apply slowmode if the lock was interrupted earlier (e.g. the message was caught by word filters)
|
||||
|
@ -36,7 +36,7 @@ export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePlugin
|
|||
if (!isAffected) return thisMsgLock.unlock();
|
||||
|
||||
// Make sure we have the appropriate permissions to manage this slowmode
|
||||
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, channel, BOT_SLOWMODE_PERMISSIONS);
|
||||
if (missingPermissions) {
|
||||
const logs = pluginData.getPlugin(LogsPlugin);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue