mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Update djs & knub (#395)
* update pkgs
Signed-off-by: GitHub <noreply@github.com>
* new knub typings
Signed-off-by: GitHub <noreply@github.com>
* more pkg updates
Signed-off-by: GitHub <noreply@github.com>
* more fixes
Signed-off-by: GitHub <noreply@github.com>
* channel typings
Signed-off-by: GitHub <noreply@github.com>
* more message utils typings fixes
Signed-off-by: GitHub <noreply@github.com>
* migrate permissions
Signed-off-by: GitHub <noreply@github.com>
* fix: InternalPoster webhookables
Signed-off-by: GitHub <noreply@github.com>
* djs typings: Attachment & Util
Signed-off-by: GitHub <noreply@github.com>
* more typings
Signed-off-by: GitHub <noreply@github.com>
* fix: rename permissionNames
Signed-off-by: GitHub <noreply@github.com>
* more fixes
Signed-off-by: GitHub <noreply@github.com>
* half the number of errors
* knub commands => messageCommands
Signed-off-by: GitHub <noreply@github.com>
* configPreprocessor => configParser
Signed-off-by: GitHub <noreply@github.com>
* fix channel.messages
Signed-off-by: GitHub <noreply@github.com>
* revert automod any typing
Signed-off-by: GitHub <noreply@github.com>
* more configParser typings
Signed-off-by: GitHub <noreply@github.com>
* revert
Signed-off-by: GitHub <noreply@github.com>
* remove knub type params
Signed-off-by: GitHub <noreply@github.com>
* fix more MessageEmbed / MessageOptions
Signed-off-by: GitHub <noreply@github.com>
* dumb commit for @almeidx to see why this is stupid
Signed-off-by: GitHub <noreply@github.com>
* temp disable custom_events
Signed-off-by: GitHub <noreply@github.com>
* more minor typings fixes - 23 err left
Signed-off-by: GitHub <noreply@github.com>
* update djs dep
* +debug build method (revert this)
Signed-off-by: GitHub <noreply@github.com>
* Revert "+debug build method (revert this)"
This reverts commit a80af1e729
.
* Redo +debug build (Revert this)
Signed-off-by: GitHub <noreply@github.com>
* uniform before/after Load shorthands
Signed-off-by: GitHub <noreply@github.com>
* remove unused imports & add prettier plugin
Signed-off-by: GitHub <noreply@github.com>
* env fixes for web platform hosting
Signed-off-by: GitHub <noreply@github.com>
* feat: knub v32-next; related fixes
* fix: allow legacy keys in change_perms action
* fix: request Message Content intent
* fix: use Knub's config validation logic in API
* fix(dashboard): fix error when there are no message and/or slash commands in a plugin
* fix(automod): start_thread action thread options
* fix(CustomEvents): message command types
* chore: remove unneeded type annotation
* feat: add forum channel icon; use thread icon for news threads
* chore: make tslint happy
* chore: fix formatting
---------
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: almeidx <almeidx@pm.me>
Co-authored-by: Dragory <2606411+Dragory@users.noreply.github.com>
This commit is contained in:
parent
293115af22
commit
06877e90cc
476 changed files with 2965 additions and 3251 deletions
|
@ -3,26 +3,26 @@ import { AllowedGuilds } from "../../data/AllowedGuilds";
|
|||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
import { Configs } from "../../data/Configs";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { sendSuccessMessage } from "../../pluginUtils";
|
||||
import { makeIoTsConfigParser, sendSuccessMessage } from "../../pluginUtils";
|
||||
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { getActiveReload, resetActiveReload } from "./activeReload";
|
||||
import { AddDashboardUserCmd } from "./commands/AddDashboardUserCmd";
|
||||
import { AddServerFromInviteCmd } from "./commands/AddServerFromInviteCmd";
|
||||
import { AllowServerCmd } from "./commands/AllowServerCmd";
|
||||
import { ChannelToServerCmd } from "./commands/ChannelToServerCmd";
|
||||
import { DisallowServerCmd } from "./commands/DisallowServerCmd";
|
||||
import { EligibleCmd } from "./commands/EligibleCmd";
|
||||
import { LeaveServerCmd } from "./commands/LeaveServerCmd";
|
||||
import { ListDashboardPermsCmd } from "./commands/ListDashboardPermsCmd";
|
||||
import { ListDashboardUsersCmd } from "./commands/ListDashboardUsersCmd";
|
||||
import { ProfilerDataCmd } from "./commands/ProfilerDataCmd";
|
||||
import { RateLimitPerformanceCmd } from "./commands/RateLimitPerformanceCmd";
|
||||
import { ReloadGlobalPluginsCmd } from "./commands/ReloadGlobalPluginsCmd";
|
||||
import { ReloadServerCmd } from "./commands/ReloadServerCmd";
|
||||
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
|
||||
import { RestPerformanceCmd } from "./commands/RestPerformanceCmd";
|
||||
import { ServersCmd } from "./commands/ServersCmd";
|
||||
import { BotControlPluginType, ConfigSchema } from "./types";
|
||||
import { ProfilerDataCmd } from "./commands/ProfilerDataCmd";
|
||||
import { AddServerFromInviteCmd } from "./commands/AddServerFromInviteCmd";
|
||||
import { ChannelToServerCmd } from "./commands/ChannelToServerCmd";
|
||||
import { RestPerformanceCmd } from "./commands/RestPerformanceCmd";
|
||||
import { RateLimitPerformanceCmd } from "./commands/RateLimitPerformanceCmd";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -37,11 +37,11 @@ const defaultOptions = {
|
|||
|
||||
export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
||||
name: "bot_control",
|
||||
configSchema: ConfigSchema,
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
commands: [
|
||||
messageCommands: [
|
||||
ReloadGlobalPluginsCmd,
|
||||
ServersCmd,
|
||||
LeaveServerCmd,
|
||||
|
@ -61,17 +61,19 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
|||
],
|
||||
|
||||
async afterLoad(pluginData) {
|
||||
pluginData.state.archives = new GuildArchives(0);
|
||||
pluginData.state.allowedGuilds = new AllowedGuilds();
|
||||
pluginData.state.configs = new Configs();
|
||||
pluginData.state.apiPermissionAssignments = new ApiPermissionAssignments();
|
||||
const { state, client } = pluginData;
|
||||
|
||||
state.archives = new GuildArchives(0);
|
||||
state.allowedGuilds = new AllowedGuilds();
|
||||
state.configs = new Configs();
|
||||
state.apiPermissionAssignments = new ApiPermissionAssignments();
|
||||
|
||||
const activeReload = getActiveReload();
|
||||
if (activeReload) {
|
||||
const [guildId, channelId] = activeReload;
|
||||
resetActiveReload();
|
||||
|
||||
const guild = await pluginData.client.guilds.fetch(guildId as Snowflake);
|
||||
const guild = await client.guilds.fetch(guildId as Snowflake);
|
||||
if (guild) {
|
||||
const channel = guild.channels.cache.get(channelId as Snowflake);
|
||||
if (channel instanceof TextChannel) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
@ -19,7 +18,7 @@ export const AddDashboardUserCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const guild = await pluginData.state.allowedGuilds.find(args.guildId);
|
||||
if (!guild) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Server is not using Zeppelin");
|
||||
sendErrorMessage(pluginData, msg.channel, "Server is not using Zeppelin");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,7 +37,7 @@ export const AddDashboardUserCmd = botControlCmd({
|
|||
const userNameList = args.users.map((user) => `<@!${user.id}> (**${user.tag}**, \`${user.id}\`)`);
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel as TextChannel,
|
||||
msg.channel,
|
||||
`The following users were given dashboard access for **${guild.name}**:\n\n${userNameList}`,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { DBDateFormat, isGuildInvite, isSnowflake, resolveInvite } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import moment from "moment-timezone";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { DBDateFormat, isGuildInvite, resolveInvite } from "../../../utils";
|
||||
import { isEligible } from "../functions/isEligible";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const AddServerFromInviteCmd = botControlCmd({
|
||||
trigger: ["add_server_from_invite", "allow_server_from_invite", "adv"],
|
||||
|
@ -19,23 +18,19 @@ export const AddServerFromInviteCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const invite = await resolveInvite(pluginData.client, args.inviteCode, true);
|
||||
if (!invite || !isGuildInvite(invite)) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Could not resolve invite"); // :D
|
||||
sendErrorMessage(pluginData, msg.channel, "Could not resolve invite"); // :D
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = await pluginData.state.allowedGuilds.find(invite.guild.id);
|
||||
if (existing) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Server is already allowed!");
|
||||
sendErrorMessage(pluginData, msg.channel, "Server is already allowed!");
|
||||
return;
|
||||
}
|
||||
|
||||
const { result, explanation } = await isEligible(pluginData, args.user, invite);
|
||||
if (!result) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel as TextChannel,
|
||||
`Could not add server because it's not eligible: ${explanation}`,
|
||||
);
|
||||
sendErrorMessage(pluginData, msg.channel, `Could not add server because it's not eligible: ${explanation}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,10 +51,6 @@ export const AddServerFromInviteCmd = botControlCmd({
|
|||
);
|
||||
}
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel as TextChannel,
|
||||
"Server was eligible and is now allowed to use Zeppelin!",
|
||||
);
|
||||
sendSuccessMessage(pluginData, msg.channel, "Server was eligible and is now allowed to use Zeppelin!");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { TextChannel } from "discord.js";
|
||||
import moment from "moment-timezone";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { DBDateFormat, isSnowflake } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import moment from "moment-timezone";
|
||||
|
||||
export const AllowServerCmd = botControlCmd({
|
||||
trigger: ["allow_server", "allowserver", "add_server", "addserver"],
|
||||
|
@ -21,17 +20,17 @@ export const AllowServerCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const existing = await pluginData.state.allowedGuilds.find(args.guildId);
|
||||
if (existing) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Server is already allowed!");
|
||||
sendErrorMessage(pluginData, msg.channel, "Server is already allowed!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isSnowflake(args.guildId)) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Invalid server ID!");
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid server ID!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.userId && !isSnowflake(args.userId)) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Invalid user ID!");
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid user ID!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,6 +51,6 @@ export const AllowServerCmd = botControlCmd({
|
|||
);
|
||||
}
|
||||
|
||||
sendSuccessMessage(pluginData, msg.channel as TextChannel, "Server is now allowed to use Zeppelin!");
|
||||
sendSuccessMessage(pluginData, msg.channel, "Server is now allowed to use Zeppelin!");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import { Guild, GuildChannel, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { GuildInvite, isGuildInvite, resolveInvite, verboseUserMention } from "../../../utils";
|
||||
import { isStaffPreFilter, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
import { isEligible } from "../functions/isEligible";
|
||||
|
||||
export const ChannelToServerCmd = botControlCmd({
|
||||
trigger: ["channel_to_server", "channel2server"],
|
||||
|
@ -19,13 +16,13 @@ export const ChannelToServerCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const channel = pluginData.client.channels.cache.get(args.channelId);
|
||||
if (!channel) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Channel not found in cache!");
|
||||
sendErrorMessage(pluginData, msg.channel, "Channel not found in cache!");
|
||||
return;
|
||||
}
|
||||
|
||||
const channelName = channel.isVoice() ? channel.name : `#${(channel as TextChannel).name}`;
|
||||
const channelName = channel.isVoiceBased() ? channel.name : `#${"name" in channel ? channel.name : channel.id}`;
|
||||
|
||||
const guild: Guild | null = (channel as GuildChannel).guild ?? null;
|
||||
const guild = "guild" in channel ? channel.guild : null;
|
||||
const guildInfo = guild ? `${guild.name} (\`${guild.id}\`)` : "Not a server";
|
||||
|
||||
msg.channel.send(`**Channel:** ${channelName} (\`${channel.type}\`) (<#${channel.id}>)\n**Server:** ${guildInfo}`);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { noop } from "../../../utils";
|
||||
|
@ -18,7 +18,7 @@ export const DisallowServerCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const existing = await pluginData.state.allowedGuilds.find(args.guildId);
|
||||
if (!existing) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "That server is not allowed in the first place!");
|
||||
sendErrorMessage(pluginData, msg.channel, "That server is not allowed in the first place!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,6 @@ export const DisallowServerCmd = botControlCmd({
|
|||
.get(args.guildId as Snowflake)
|
||||
?.leave()
|
||||
.catch(noop);
|
||||
sendSuccessMessage(pluginData, msg.channel as TextChannel, "Server removed!");
|
||||
sendSuccessMessage(pluginData, msg.channel, "Server removed!");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Guild, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { GuildInvite, isGuildInvite, resolveInvite, verboseUserMention } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import { isGuildInvite, resolveInvite } from "../../../utils";
|
||||
import { isEligible } from "../functions/isEligible";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const EligibleCmd = botControlCmd({
|
||||
trigger: ["eligible", "is_eligible", "iseligible"],
|
||||
|
@ -17,17 +16,17 @@ export const EligibleCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const invite = await resolveInvite(pluginData.client, args.inviteCode, true);
|
||||
if (!invite || !isGuildInvite(invite)) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Could not resolve invite");
|
||||
sendErrorMessage(pluginData, msg.channel, "Could not resolve invite");
|
||||
return;
|
||||
}
|
||||
|
||||
const { result, explanation } = await isEligible(pluginData, args.user, invite);
|
||||
|
||||
if (result) {
|
||||
sendSuccessMessage(pluginData, msg.channel as TextChannel, `Server is eligible: ${explanation}`);
|
||||
sendSuccessMessage(pluginData, msg.channel, `Server is eligible: ${explanation}`);
|
||||
return;
|
||||
}
|
||||
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, `Server is **NOT** eligible: ${explanation}`);
|
||||
sendErrorMessage(pluginData, msg.channel, `Server is **NOT** eligible: ${explanation}`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
@ -16,7 +16,7 @@ export const LeaveServerCmd = botControlCmd({
|
|||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
if (!pluginData.client.guilds.cache.has(args.guildId as Snowflake)) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "I am not in that guild");
|
||||
sendErrorMessage(pluginData, msg.channel, "I am not in that guild");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,10 @@ export const LeaveServerCmd = botControlCmd({
|
|||
try {
|
||||
await pluginData.client.guilds.cache.get(args.guildId as Snowflake)?.leave();
|
||||
} catch (e) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, `Failed to leave guild: ${e.message}`);
|
||||
sendErrorMessage(pluginData, msg.channel, `Failed to leave guild: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
sendSuccessMessage(pluginData, msg.channel as TextChannel, `Left guild **${guildName}**`);
|
||||
sendSuccessMessage(pluginData, msg.channel, `Left guild **${guildName}**`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { AllowedGuild } from "../../../data/entities/AllowedGuild";
|
||||
import { ApiPermissionAssignment } from "../../../data/entities/ApiPermissionAssignment";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -17,7 +16,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
if (!args.user && !args.guildId) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Must specify at least guildId, user, or both.");
|
||||
sendErrorMessage(pluginData, msg.channel, "Must specify at least guildId, user, or both.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,7 +24,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
if (args.guildId) {
|
||||
guild = await pluginData.state.allowedGuilds.find(args.guildId);
|
||||
if (!guild) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Server is not using Zeppelin");
|
||||
sendErrorMessage(pluginData, msg.channel, "Server is not using Zeppelin");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +33,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
if (args.user) {
|
||||
existingUserAssignment = await pluginData.state.apiPermissionAssignments.getByUserId(args.user.id);
|
||||
if (existingUserAssignment.length === 0) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "The user has no assigned permissions.");
|
||||
sendErrorMessage(pluginData, msg.channel, "The user has no assigned permissions.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +56,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
if (finalMessage === "") {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel as TextChannel,
|
||||
msg.channel,
|
||||
`The user ${userInfo} has no assigned permissions on the specified server.`,
|
||||
);
|
||||
return;
|
||||
|
@ -68,11 +67,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
|
||||
const existingGuildAssignment = await pluginData.state.apiPermissionAssignments.getByGuildId(guild.id);
|
||||
if (existingGuildAssignment.length === 0) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel as TextChannel,
|
||||
`The server ${guildInfo} has no assigned permissions.`,
|
||||
);
|
||||
sendErrorMessage(pluginData, msg.channel, `The server ${guildInfo} has no assigned permissions.`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,6 +78,6 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
}
|
||||
}
|
||||
|
||||
await sendSuccessMessage(pluginData, msg.channel as TextChannel, finalMessage.trim(), {});
|
||||
await sendSuccessMessage(pluginData, msg.channel, finalMessage.trim(), {});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -15,7 +14,7 @@ export const ListDashboardUsersCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const guild = await pluginData.state.allowedGuilds.find(args.guildId);
|
||||
if (!guild) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Server is not using Zeppelin");
|
||||
sendErrorMessage(pluginData, msg.channel, "Server is not using Zeppelin");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -33,7 +32,7 @@ export const ListDashboardUsersCmd = botControlCmd({
|
|||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel as TextChannel,
|
||||
msg.channel,
|
||||
`The following users have dashboard access for **${guild.name}**:\n\n${userNameList.join("\n")}`,
|
||||
{},
|
||||
);
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { createChunkedMessage, formatNumber, resolveInvite, sorter, verboseUserMention } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import { GuildArchives } from "../../../data/GuildArchives";
|
||||
import moment from "moment-timezone";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { GuildArchives } from "../../../data/GuildArchives";
|
||||
import { getBaseUrl } from "../../../pluginUtils";
|
||||
import { sorter } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
const sortProps = {
|
||||
totalTime: "TOTAL TIME",
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { botControlCmd } from "../types";
|
||||
import { getRateLimitStats } from "../../../rateLimitStats";
|
||||
import moment from "moment-timezone";
|
||||
import { GuildArchives } from "../../../data/GuildArchives";
|
||||
import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { getBaseUrl, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { getRateLimitStats } from "../../../rateLimitStats";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const RateLimitPerformanceCmd = botControlCmd({
|
||||
trigger: ["rate_limit_performance"],
|
||||
|
@ -14,7 +13,7 @@ export const RateLimitPerformanceCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const logItems = getRateLimitStats();
|
||||
if (logItems.length === 0) {
|
||||
sendSuccessMessage(pluginData, msg.channel as TextChannel, `No rate limits hit`);
|
||||
sendSuccessMessage(pluginData, msg.channel, `No rate limits hit`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,7 +24,7 @@ export const RateLimitPerformanceCmd = botControlCmd({
|
|||
if (item.data.global) items.push("GLOBAL");
|
||||
items.push(item.data.method.toUpperCase());
|
||||
items.push(item.data.route);
|
||||
items.push(`stalled for ${item.data.timeout}ms`);
|
||||
items.push(`stalled for ${item.data.timeToReset}ms`);
|
||||
items.push(`(max requests ${item.data.limit})`);
|
||||
return items.join(" ");
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage } from "../../../pluginUtils";
|
||||
import { getActiveReload, setActiveReload } from "../activeReload";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -13,7 +12,13 @@ export const ReloadGlobalPluginsCmd = botControlCmd({
|
|||
async run({ pluginData, message }) {
|
||||
if (getActiveReload()) return;
|
||||
|
||||
setActiveReload((message.channel as TextChannel).guild?.id, message.channel.id);
|
||||
const guildId = "guild" in message.channel ? message.channel.guild.id : null;
|
||||
if (!guildId) {
|
||||
sendErrorMessage(pluginData, message.channel, "This command can only be used in a server");
|
||||
return;
|
||||
}
|
||||
|
||||
setActiveReload(guildId, message.channel.id);
|
||||
await message.channel.send("Reloading global plugins...");
|
||||
|
||||
pluginData.getKnubInstance().reloadGlobalContext();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
@ -16,18 +16,18 @@ export const ReloadServerCmd = botControlCmd({
|
|||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
if (!pluginData.client.guilds.cache.has(args.guildId as Snowflake)) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "I am not in that guild");
|
||||
sendErrorMessage(pluginData, msg.channel, "I am not in that guild");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await pluginData.getKnubInstance().reloadGuild(args.guildId);
|
||||
} catch (e) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, `Failed to reload guild: ${e.message}`);
|
||||
sendErrorMessage(pluginData, msg.channel, `Failed to reload guild: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const guild = await pluginData.client.guilds.fetch(args.guildId as Snowflake);
|
||||
sendSuccessMessage(pluginData, msg.channel as TextChannel, `Reloaded guild **${guild?.name || "???"}**`);
|
||||
sendSuccessMessage(pluginData, msg.channel, `Reloaded guild **${guild?.name || "???"}**`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
@ -18,7 +17,7 @@ export const RemoveDashboardUserCmd = botControlCmd({
|
|||
async run({ pluginData, message: msg, args }) {
|
||||
const guild = await pluginData.state.allowedGuilds.find(args.guildId);
|
||||
if (!guild) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "Server is not using Zeppelin");
|
||||
sendErrorMessage(pluginData, msg.channel, "Server is not using Zeppelin");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,7 +36,7 @@ export const RemoveDashboardUserCmd = botControlCmd({
|
|||
const userNameList = args.users.map((user) => `<@!${user.id}> (**${user.tag}**, \`${user.id}\`)`);
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel as TextChannel,
|
||||
msg.channel,
|
||||
`The following users were removed from the dashboard for **${guild.name}**:\n\n${userNameList}`,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { createChunkedMessage, formatNumber, resolveInvite, sorter, verboseUserMention } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import { getTopRestCallStats } from "../../../restCallStats";
|
||||
import { createChunkedMessage } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
const leadingPathRegex = /(?<=\().+\/backend\//g;
|
||||
|
||||
|
@ -22,6 +20,6 @@ export const RestPerformanceCmd = botControlCmd({
|
|||
const cleanSource = callStats.source.replace(leadingPathRegex, "");
|
||||
return `**${callStats.count} calls**\n${callStats.method.toUpperCase()} ${callStats.path}\n${cleanSource}`;
|
||||
});
|
||||
createChunkedMessage(msg.channel as TextChannel, `Top rest calls:\n\n${formatted.join("\n")}`);
|
||||
createChunkedMessage(msg.channel, `Top rest calls:\n\n${formatted.join("\n")}`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import escapeStringRegexp from "escape-string-regexp";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||
|
@ -51,7 +50,7 @@ export const ServersCmd = botControlCmd({
|
|||
const owner = getUser(pluginData.client, g.ownerId);
|
||||
return `\`${paddedId}\` **${g.name}** (${g.memberCount} members) (owner **${owner.tag}** \`${owner.id}\`)`;
|
||||
});
|
||||
createChunkedMessage(msg.channel as TextChannel, lines.join("\n"));
|
||||
createChunkedMessage(msg.channel, lines.join("\n"));
|
||||
} else {
|
||||
msg.channel.send("No servers matched the filters");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { User } from "discord.js";
|
||||
import { BotControlPluginType } from "../types";
|
||||
import { GlobalPluginData } from "knub";
|
||||
import { GuildInvite } from "../../../utils";
|
||||
import { BotControlPluginType } from "../types";
|
||||
|
||||
const REQUIRED_MEMBER_COUNT = 5000;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, typedGlobalCommand, typedGlobalEventListener } from "knub";
|
||||
import { BasePluginType, globalPluginEventListener, globalPluginMessageCommand } from "knub";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
import { Configs } from "../../data/Configs";
|
||||
|
@ -26,5 +26,5 @@ export interface BotControlPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const botControlCmd = typedGlobalCommand<BotControlPluginType>();
|
||||
export const botControlEvt = typedGlobalEventListener<BotControlPluginType>();
|
||||
export const botControlCmd = globalPluginMessageCommand<BotControlPluginType>();
|
||||
export const botControlEvt = globalPluginEventListener<BotControlPluginType>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue