3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 00:05:01 +00:00

Merge branch '240811_application_commands_merge_2' into next

This commit is contained in:
Dragory 2024-08-11 22:28:41 +03:00
commit 43b8017985
No known key found for this signature in database
279 changed files with 6192 additions and 3044 deletions

View file

@ -1,6 +1,7 @@
import { PluginOptions, guildPlugin } from "knub";
import { onGuildEvent } from "../../data/GuildEvents.js";
import { GuildVCAlerts } from "../../data/GuildVCAlerts.js";
import { CommonPlugin } from "../Common/CommonPlugin.js";
import { FollowCmd } from "./commands/FollowCmd.js";
import { DeleteFollowCmd, ListFollowCmd } from "./commands/ListFollowCmd.js";
import { WhereCmd } from "./commands/WhereCmd.js";
@ -53,6 +54,10 @@ export const LocateUserPlugin = guildPlugin<LocateUserPluginType>()({
state.usersWithAlerts = [];
},
beforeStart(pluginData) {
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
},
afterLoad(pluginData) {
const { state, guild } = pluginData;

View file

@ -2,7 +2,6 @@ import humanizeDuration from "humanize-duration";
import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { registerExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { MINUTES, SECONDS } from "../../../utils.js";
import { locateUserCmd } from "../types.js";
@ -27,7 +26,7 @@ export const FollowCmd = locateUserCmd({
const active = args.active || false;
if (time < 30 * SECONDS) {
sendErrorMessage(pluginData, msg.channel, "Sorry, but the minimum duration for an alert is 30 seconds!");
void pluginData.state.common.sendErrorMessage(msg, "Sorry, but the minimum duration for an alert is 30 seconds!");
return;
}
@ -46,17 +45,15 @@ export const FollowCmd = locateUserCmd({
}
if (active) {
sendSuccessMessage(
pluginData,
msg.channel,
void pluginData.state.common.sendSuccessMessage(
msg,
`Every time <@${args.member.id}> joins or switches VC in the next ${humanizeDuration(
time,
)} i will notify and move you.\nPlease make sure to be in a voice channel, otherwise i cannot move you!`,
);
} else {
sendSuccessMessage(
pluginData,
msg.channel,
void pluginData.state.common.sendSuccessMessage(
msg,
`Every time <@${args.member.id}> joins or switches VC in the next ${humanizeDuration(time)} i will notify you`,
);
}

View file

@ -1,6 +1,5 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { clearExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { createChunkedMessage, sorter } from "../../../utils.js";
import { locateUserCmd } from "../types.js";
@ -13,7 +12,7 @@ export const ListFollowCmd = locateUserCmd({
async run({ message: msg, pluginData }) {
const alerts = await pluginData.state.alerts.getAlertsByRequestorId(msg.member.id);
if (alerts.length === 0) {
sendErrorMessage(pluginData, msg.channel, "You have no active alerts!");
void pluginData.state.common.sendErrorMessage(msg, "You have no active alerts!");
return;
}
@ -46,7 +45,7 @@ export const DeleteFollowCmd = locateUserCmd({
alerts.sort(sorter("expires_at"));
if (args.num > alerts.length || args.num <= 0) {
sendErrorMessage(pluginData, msg.channel, "Unknown alert!");
void pluginData.state.common.sendErrorMessage(msg, "Unknown alert!");
return;
}
@ -54,6 +53,6 @@ export const DeleteFollowCmd = locateUserCmd({
clearExpiringVCAlert(toDelete);
await pluginData.state.alerts.delete(toDelete.id);
sendSuccessMessage(pluginData, msg.channel, "Alert deleted");
void pluginData.state.common.sendSuccessMessage(msg, "Alert deleted");
},
});

View file

@ -1,6 +1,7 @@
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand, pluginUtils } from "knub";
import z from "zod";
import { GuildVCAlerts } from "../../data/GuildVCAlerts.js";
import { CommonPlugin } from "../Common/CommonPlugin.js";
export const zLocateUserConfig = z.strictObject({
can_where: z.boolean(),
@ -13,6 +14,7 @@ export interface LocateUserPluginType extends BasePluginType {
alerts: GuildVCAlerts;
usersWithAlerts: string[];
unregisterGuildEventListener: () => void;
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
};
}

View file

@ -1,6 +1,5 @@
import { GuildMember, GuildTextBasedChannel, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { LocateUserPluginType } from "../types.js";
export async function moveMember(
@ -16,10 +15,10 @@ export async function moveMember(
channel: target.voice.channelId,
});
} catch {
sendErrorMessage(pluginData, errorChannel, "Failed to move you. Are you in a voice channel?");
void pluginData.state.common.sendErrorMessage(errorChannel, "Failed to move you. Are you in a voice channel?");
return;
}
} else {
sendErrorMessage(pluginData, errorChannel, "Failed to move you. Are you in a voice channel?");
void pluginData.state.common.sendErrorMessage(errorChannel, "Failed to move you. Are you in a voice channel?");
}
}

View file

@ -1,7 +1,6 @@
import { GuildMember, GuildTextBasedChannel, Invite, VoiceChannel } from "discord.js";
import { GuildPluginData } from "knub";
import { getInviteLink } from "knub/helpers";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { LocateUserPluginType } from "../types.js";
import { createOrReuseInvite } from "./createOrReuseInvite.js";
@ -22,7 +21,7 @@ export async function sendWhere(
try {
invite = await createOrReuseInvite(voice);
} catch {
sendErrorMessage(pluginData, channel, "Cannot create an invite to that channel!");
void pluginData.state.common.sendErrorMessage(channel, "Cannot create an invite to that channel!");
return;
}
channel.send({