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

@ -1,6 +1,7 @@
import { utilityCmd } from "../types";
import { EmbedWith, multiSorter, resolveMember, sorter } from "../../../utils";
import { GuildChannel, MessageContent, Role } from "eris";
import { getCurrentUptime } from "../../../uptime";
import humanizeDuration from "humanize-duration";
import LCL from "last-commit-log";
@ -66,7 +67,7 @@ export const AboutCmd = utilityCmd({
const aboutContent: MessageContent & { embed: EmbedWith<"title" | "fields"> } = {
embed: {
title: `About ${pluginData.client.user.username}`,
title: `About ${pluginData.client.user!.username}`,
fields: [
{
name: "Status",
@ -100,7 +101,7 @@ export const AboutCmd = utilityCmd({
}
// For the embed color, find the highest colored role the bot has - this is their color on the server as well
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user.id);
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user!.id);
let botRoles = botMember?.roles.map(r => (msg.channel as GuildChannel).guild.roles.get(r)!) || [];
botRoles = botRoles.filter(r => !!r); // Drop any unknown roles
botRoles = botRoles.filter(r => r.color); // Filter to those with a color
@ -110,8 +111,8 @@ export const AboutCmd = utilityCmd({
}
// Use the bot avatar as the embed image
if (pluginData.client.user.avatarURL) {
aboutContent.embed.thumbnail = { url: pluginData.client.user.avatarURL };
if (pluginData.client.user!avatarURL) {
aboutContent.embed.thumbnail = { url: pluginData.client.user!.avatarURL };
}
msg.channel.createMessage(aboutContent);

View file

@ -2,7 +2,6 @@ import { utilityCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { UnknownUser } from "../../../utils";
import { sendErrorMessage } from "../../../pluginUtils";
import { EmbedOptions } from "eris";
export const AvatarCmd = utilityCmd({
trigger: ["avatar", "av"],

View file

@ -2,7 +2,7 @@ import { utilityCmd, UtilityPluginType } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { DAYS, getInviteCodesInString, noop, SECONDS, stripObjectToScalars } from "../../../utils";
import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { Message, TextChannel, User } from "eris";
import moment from "moment-timezone";
import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage";
@ -87,7 +87,7 @@ export const CleanCmd = utilityCmd({
return;
}
const targetChannel = args.channel ? pluginData.guild.channels.get(args.channel) : msg.channel;
const targetChannel = args.channel ? pluginData.guild.channels.cache.get(args.channel) : msg.channel;
if (!targetChannel || !(targetChannel instanceof TextChannel)) {
sendErrorMessage(pluginData, msg.channel, `Invalid channel specified`);
return;

View file

@ -2,7 +2,7 @@ import { utilityCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { messageLink } from "../../../utils";
import { sendErrorMessage } from "../../../pluginUtils";
import { TextChannel } from "eris";
import { canReadChannel } from "../../../utils/canReadChannel";
export const ContextCmd = utilityCmd({

View file

@ -38,7 +38,7 @@ export const InfoCmd = utilityCmd({
// 1. Channel
if (userCfg.can_channelinfo) {
const channelId = getChannelId(value);
const channel = channelId && pluginData.guild.channels.get(channelId);
const channel = channelId && pluginData.guild.channels.cache.get(channelId);
if (channel) {
const embed = await getChannelInfoEmbed(pluginData, channelId!, message.author.id);
if (embed) {
@ -121,7 +121,7 @@ export const InfoCmd = utilityCmd({
// 7. Role
if (userCfg.can_roleinfo) {
const roleId = getRoleId(value);
const role = roleId && pluginData.guild.roles.get(roleId);
const role = roleId && pluginData.guild.roles.cache.get(roleId);
if (role) {
const embed = await getRoleInfoEmbed(pluginData, role, message.author.id);
message.channel.createMessage({ embed });

View file

@ -1,6 +1,5 @@
import { utilityCmd } from "../types";
import { noop, trimLines } from "../../../utils";
import { Message } from "eris";
const { performance } = require("perf_hooks");

View file

@ -1,5 +1,5 @@
import { utilityCmd } from "../types";
import { TextChannel } from "eris";
import { activeReloads } from "../guildReloads";
export const ReloadGuildCmd = utilityCmd({

View file

@ -1,6 +1,6 @@
import { utilityCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { Role, TextChannel } from "eris";
import { chunkArray, sorter, trimLines } from "../../../utils";
import { refreshMembersIfNeeded } from "../refreshMembers";
import { sendErrorMessage } from "../../../pluginUtils";

View file

@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { errorMessage } from "../../../utils";
import { getBaseUrl, sendErrorMessage } from "../../../pluginUtils";
import moment from "moment-timezone";
import { Constants, TextChannel } from "eris";
import { canReadChannel } from "../../../utils/canReadChannel";
export const SourceCmd = utilityCmd({

View file

@ -8,7 +8,7 @@ import {
stripObjectToScalars,
} from "../../../utils";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { VoiceChannel } from "eris";
import { LogType } from "../../../data/LogType";
import { resolveChannel } from "knub/dist/helpers";

View file

@ -9,7 +9,7 @@ import {
stripObjectToScalars,
} from "../../../utils";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { Member, VoiceChannel } from "eris";
import { LogType } from "../../../data/LogType";
export const VcmoveCmd = utilityCmd({
@ -28,7 +28,7 @@ export const VcmoveCmd = utilityCmd({
if (isSnowflake(args.channel)) {
// Snowflake -> resolve channel directly
const potentialChannel = pluginData.guild.channels.get(args.channel);
const potentialChannel = pluginData.guild.channels.cache.get(args.channel);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
return;
@ -38,7 +38,7 @@ export const VcmoveCmd = utilityCmd({
} else if (channelMentionRegex.test(args.channel)) {
// Channel mention -> parse channel id and resolve channel from that
const channelId = args.channel.match(channelMentionRegex)![1];
const potentialChannel = pluginData.guild.channels.get(channelId);
const potentialChannel = pluginData.guild.channels.cache.get(channelId);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
return;
@ -69,7 +69,7 @@ export const VcmoveCmd = utilityCmd({
return;
}
const oldVoiceChannel = pluginData.guild.channels.get(args.member.voiceState.channelID);
const oldVoiceChannel = pluginData.guild.channels.cache.get(args.member.voiceState.channelID);
try {
await args.member.edit({
@ -111,7 +111,7 @@ export const VcmoveAllCmd = utilityCmd({
if (isSnowflake(args.channel)) {
// Snowflake -> resolve channel directly
const potentialChannel = pluginData.guild.channels.get(args.channel);
const potentialChannel = pluginData.guild.channels.cache.get(args.channel);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
return;
@ -121,7 +121,7 @@ export const VcmoveAllCmd = utilityCmd({
} else if (channelMentionRegex.test(args.channel)) {
// Channel mention -> parse channel id and resolve channel from that
const channelId = args.channel.match(channelMentionRegex)![1];
const potentialChannel = pluginData.guild.channels.get(channelId);
const potentialChannel = pluginData.guild.channels.cache.get(channelId);
if (!potentialChannel || !(potentialChannel instanceof VoiceChannel)) {
sendErrorMessage(pluginData, msg.channel, "Unknown or non-voice channel");
return;

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { UtilityPluginType } from "../types";
import { Constants, EmbedOptions } from "eris";
import moment from "moment-timezone";
import humanizeDuration from "humanize-duration";
import { EmbedWith, formatNumber, preEmbedPadding, trimLines } from "../../../utils";
@ -20,7 +20,7 @@ export async function getChannelInfoEmbed(
channelId: string,
requestMemberId?: string,
): Promise<EmbedOptions | null> {
const channel = pluginData.guild.channels.get(channelId);
const channel = pluginData.guild.channels.cache.get(channelId);
if (!channel) {
return null;
}

View file

@ -1,4 +1,3 @@
import { EmbedOptions } from "eris";
import { GuildPluginData } from "knub";
import { UtilityPluginType } from "../types";
import { trimLines, preEmbedPadding, EmbedWith } from "../../../utils";

View file

@ -1,4 +1,3 @@
import { Client, GuildPreview } from "eris";
import { memoize, MINUTES } from "../../../utils";
/**

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { UtilityPluginType } from "../types";
import { Constants, EmbedOptions } from "eris";
import { snowflakeToTimestamp } from "../../../utils/snowflakeToTimestamp";
import moment from "moment-timezone";
import humanizeDuration from "humanize-duration";

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub";
import { UtilityPluginType } from "../types";
import { Constants, EmbedOptions } from "eris";
import moment from "moment-timezone";
import humanizeDuration from "humanize-duration";
import { chunkMessageLines, EmbedWith, messageLink, preEmbedPadding, trimEmptyLines, trimLines } from "../../../utils";

View file

@ -1,4 +1,3 @@
import { EmbedOptions, Role } from "eris";
import { GuildPluginData } from "knub";
import { UtilityPluginType } from "../types";
import { trimLines, preEmbedPadding, EmbedWith } from "../../../utils";

View file

@ -12,7 +12,7 @@ import {
resolveUser,
trimLines,
} from "../../../utils";
import { CategoryChannel, EmbedOptions, Guild, TextChannel, VoiceChannel } from "eris";
import moment from "moment-timezone";
import humanizeDuration from "humanize-duration";
import { getGuildPreview } from "./getGuildPreview";

View file

@ -1,4 +1,3 @@
import { Message, GuildTextableChannel, EmbedOptions } from "eris";
import { GuildPluginData } from "knub";
import { UtilityPluginType } from "../types";
import {

View file

@ -1,4 +1,3 @@
import { Message, GuildTextableChannel, EmbedOptions, Role } from "eris";
import { GuildPluginData } from "knub";
import { UtilityPluginType } from "../types";
import {
@ -102,7 +101,7 @@ export async function getUserInfoEmbed(
largest: 2,
round: true,
});
const roles = member.roles.map(id => pluginData.guild.roles.get(id)).filter(r => r != null) as Role[];
const roles = member.roles.map(id => pluginData.guild.roles.cache.get(id)).filter(r => r != null) as Role[];
roles.sort(sorter("position", "DESC"));
embed.fields.push({
@ -114,7 +113,7 @@ export async function getUserInfoEmbed(
});
const voiceChannel = member.voiceState.channelID
? pluginData.guild.channels.get(member.voiceState.channelID)
? pluginData.guild.channels.cache.get(member.voiceState.channelID)
: null;
if (voiceChannel || member.voiceState.mute || member.voiceState.deaf) {
embed.fields.push({

View file

@ -1,3 +1 @@
import { TextChannel } from "eris";
export const activeReloads: Map<string, TextChannel> = new Map();

View file

@ -1,4 +1,3 @@
import { Guild } from "eris";
import { HOURS, noop } from "../../utils";
const MEMBER_REFRESH_FREQUENCY = 1 * HOURS; // How often to do a full member refresh when using commands that need it

View file

@ -1,4 +1,3 @@
import { Constants, Member, Message, User } from "eris";
import moment from "moment-timezone";
import escapeStringRegexp from "escape-string-regexp";
import { isFullMessage, MINUTES, multiSorter, noop, sorter, trimLines } from "../../utils";
@ -396,7 +395,7 @@ async function performBanSearch(
page = 1,
perPage = SEARCH_RESULTS_PER_PAGE,
): Promise<{ results: User[]; totalResults: number; page: number; lastPage: number; from: number; to: number }> {
const member = pluginData.guild.members.get(pluginData.client.user.id);
const member = pluginData.guild.members.cache.get(pluginData.client.user!.id);
if (member && !hasDiscordPermissions(member.permissions, Constants.Permissions.banMembers)) {
throw new SearchError(`Unable to search bans: missing "Ban Members" permission`);
}