3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Add custom logger. Fix a bunch of errors. Optimize imports.

This commit is contained in:
Dragory 2020-07-22 22:56:21 +03:00
parent 0dae54745d
commit 1064a1ca46
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
89 changed files with 198 additions and 229 deletions

View file

@ -1,13 +1,13 @@
import { PluginOptions } from "knub";
import { LocateUserPluginType, ConfigSchema } from "./types";
import { ConfigSchema, LocateUserPluginType } from "./types";
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
import { GuildVCAlerts } from "src/data/GuildVCAlerts";
import { outdatedAlertsLoop } from "./utils/outdatedLoop";
import { fillActiveAlertsList } from "./utils/fillAlertsList";
import { WhereCmd } from "./commands/WhereCmd";
import { FollowCmd } from "./commands/FollowCmd";
import { ListFollowCmd, DeleteFollowCmd } from "./commands/ListFollowCmd";
import { ChannelJoinAlertsEvt, ChannelSwitchAlertsEvt, ChannelLeaveAlertsEvt } from "./events/SendAlertsEvts";
import { DeleteFollowCmd, ListFollowCmd } from "./commands/ListFollowCmd";
import { ChannelJoinAlertsEvt, ChannelLeaveAlertsEvt, ChannelSwitchAlertsEvt } from "./events/SendAlertsEvts";
import { GuildBanRemoveAlertsEvt } from "./events/BanRemoveAlertsEvt";
const defaultOptions: PluginOptions<LocateUserPluginType> = {
@ -40,9 +40,9 @@ export const LocateUserPlugin = zeppelinPlugin<LocateUserPluginType>()("locate_u
// prettier-ignore
events: [
ChannelJoinAlertsEvt,
ChannelSwitchAlertsEvt,
ChannelLeaveAlertsEvt,
ChannelJoinAlertsEvt,
ChannelSwitchAlertsEvt,
ChannelLeaveAlertsEvt,
GuildBanRemoveAlertsEvt
],

View file

@ -1,7 +1,7 @@
import { locateUserCommand } from "../types";
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sorter, createChunkedMessage } from "src/utils";
import { createChunkedMessage, sorter } from "src/utils";
export const ListFollowCmd = locateUserCommand({
trigger: ["follows", "fs"],

View file

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

View file

@ -9,7 +9,7 @@ export async function moveMember(
target: Member,
errorChannel: TextableChannel,
) {
const modMember: Member = await this.bot.getRESTGuildMember(pluginData.guild.id, toMoveID);
const modMember: Member = await pluginData.client.getRESTGuildMember(pluginData.guild.id, toMoveID);
if (modMember.voiceState.channelID != null) {
try {
await modMember.edit({

View file

@ -12,6 +12,6 @@ export async function outdatedAlertsLoop(pluginData) {
}
if (!pluginData.state.unloaded) {
pluginData.state.outdatedAlertsTimeout = setTimeout(() => this.outdatedAlertsLoop(pluginData), ALERT_LOOP_TIME);
pluginData.state.outdatedAlertsTimeout = setTimeout(() => outdatedAlertsLoop(pluginData), ALERT_LOOP_TIME);
}
}

View file

@ -12,7 +12,7 @@ export async function sendAlerts(pluginData: PluginData<LocateUserPluginType>, u
triggeredAlerts.forEach(alert => {
const prepend = `<@!${alert.requestor_id}>, an alert requested by you has triggered!\nReminder: \`${alert.body}\`\n`;
const txtChannel = pluginData.client.getChannel(alert.channel_id) as TextableChannel;
sendWhere.call(this, pluginData.guild, member, txtChannel, prepend);
sendWhere(pluginData, member, txtChannel, prepend);
if (alert.active) {
moveMember(pluginData, alert.requestor_id, member, txtChannel);
}

View file

@ -1,9 +1,17 @@
import { Guild, Member, TextableChannel, VoiceChannel } from "eris";
import { Member, TextableChannel, VoiceChannel } from "eris";
import { getInviteLink } from "knub/dist/helpers";
import { createOrReuseInvite } from "./createOrReuseInvite";
import { PluginData } from "knub";
import { LocateUserPluginType } from "../types";
import { sendErrorMessage } from "../../../pluginUtils";
export async function sendWhere(guild: Guild, member: Member, channel: TextableChannel, prepend: string) {
const voice = guild.channels.get(member.voiceState.channelID) as VoiceChannel;
export async function sendWhere(
pluginData: PluginData<LocateUserPluginType>,
member: Member,
channel: TextableChannel,
prepend: string,
) {
const voice = pluginData.guild.channels.get(member.voiceState.channelID) as VoiceChannel;
if (voice == null) {
channel.createMessage(prepend + "That user is not in a channel");
@ -12,7 +20,7 @@ export async function sendWhere(guild: Guild, member: Member, channel: TextableC
try {
invite = await createOrReuseInvite(voice);
} catch (e) {
this.sendErrorMessage(channel, "Cannot create an invite to that channel!");
sendErrorMessage(pluginData, channel, "Cannot create an invite to that channel!");
return;
}
channel.createMessage(