mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 13:55:03 +00:00
Merge branch 'master' of github.com:ZeppelinBot/Zeppelin into feat/application-commands
This commit is contained in:
commit
2c0e4b37ca
235 changed files with 3464 additions and 4799 deletions
|
@ -3,7 +3,6 @@ import { AllowedGuilds } from "../../data/AllowedGuilds";
|
|||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
import { Configs } from "../../data/Configs";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { makeIoTsConfigParser } from "../../pluginUtils";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin";
|
||||
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { getActiveReload, resetActiveReload } from "./activeReload";
|
||||
|
@ -23,7 +22,7 @@ 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 { BotControlPluginType, zBotControlConfig } from "./types";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -38,7 +37,7 @@ const defaultOptions = {
|
|||
|
||||
export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
||||
name: "bot_control",
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
configParser: (input) => zBotControlConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||
import { renderUserUsername } from "../../../utils";
|
||||
import { renderUsername } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -36,7 +36,8 @@ export const AddDashboardUserCmd = botControlCmd({
|
|||
await pluginData.state.apiPermissionAssignments.addUser(args.guildId, user.id, [ApiPermissions.EditConfig]);
|
||||
}
|
||||
|
||||
const userNameList = args.users.map((user) => `<@!${user.id}> (**${renderUserUsername(user)}**, \`${user.id}\`)`);
|
||||
const userNameList = args.users.map((user) => `<@!${user.id}> (**${renderUsername(user)}**, \`${user.id}\`)`);
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { AllowedGuild } from "../../../data/entities/AllowedGuild";
|
||||
import { ApiPermissionAssignment } from "../../../data/entities/ApiPermissionAssignment";
|
||||
import { renderUserUsername, resolveUser } from "../../../utils";
|
||||
import { renderUsername, resolveUser } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -42,7 +42,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
|
||||
// If we have user, always display which guilds they have permissions in (or only specified guild permissions)
|
||||
if (args.user) {
|
||||
const userInfo = `**${renderUserUsername(args.user)}** (\`${args.user.id}\`)`;
|
||||
const userInfo = `**${renderUsername(args.user)}** (\`${args.user.id}\`)`;
|
||||
|
||||
for (const assignment of existingUserAssignment!) {
|
||||
if (guild != null && assignment.guild_id !== args.guildId) continue;
|
||||
|
@ -74,7 +74,7 @@ export const ListDashboardPermsCmd = botControlCmd({
|
|||
finalMessage += `The server ${guildInfo} has the following assigned permissions:\n`; // Double \n for consistency with AddDashboardUserCmd
|
||||
for (const assignment of existingGuildAssignment) {
|
||||
const user = await resolveUser(pluginData.client, assignment.target_id);
|
||||
finalMessage += `\n**${renderUserUsername(user)}**, \`${assignment.target_id}\`: ${assignment.permissions.join(
|
||||
finalMessage += `\n**${renderUsername(user)}**, \`${assignment.target_id}\`: ${assignment.permissions.join(
|
||||
", ",
|
||||
)}`;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { renderUserUsername, resolveUser } from "../../../utils";
|
||||
import { renderUsername, resolveUser } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -27,7 +27,7 @@ export const ListDashboardUsersCmd = botControlCmd({
|
|||
);
|
||||
const userNameList = users.map(
|
||||
({ user, permission }) =>
|
||||
`<@!${user.id}> (**${renderUserUsername(user)}**, \`${user.id}\`): ${permission.permissions.join(", ")}`,
|
||||
`<@!${user.id}> (**${renderUsername(user)}**, \`${user.id}\`): ${permission.permissions.join(", ")}`,
|
||||
);
|
||||
|
||||
pluginData
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||
import { renderUserUsername } from "../../../utils";
|
||||
import { renderUsername } from "../../../utils";
|
||||
import { CommonPlugin } from "../../Common/CommonPlugin";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -35,7 +35,8 @@ export const RemoveDashboardUserCmd = botControlCmd({
|
|||
await pluginData.state.apiPermissionAssignments.removeUser(args.guildId, user.id);
|
||||
}
|
||||
|
||||
const userNameList = args.users.map((user) => `<@!${user.id}> (**${renderUserUsername(user)}**, \`${user.id}\`)`);
|
||||
const userNameList = args.users.map((user) => `<@!${user.id}> (**${renderUsername(user)}**, \`${user.id}\`)`);
|
||||
|
||||
pluginData
|
||||
.getPlugin(CommonPlugin)
|
||||
.sendSuccessMessage(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import escapeStringRegexp from "escape-string-regexp";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||
import { createChunkedMessage, getUser, sorter } from "../../../utils";
|
||||
import { createChunkedMessage, getUser, renderUsername, sorter } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const ServersCmd = botControlCmd({
|
||||
|
@ -48,7 +48,9 @@ export const ServersCmd = botControlCmd({
|
|||
const lines = filteredGuilds.map((g) => {
|
||||
const paddedId = g.id.padEnd(longestId, " ");
|
||||
const owner = getUser(pluginData.client, g.ownerId);
|
||||
return `\`${paddedId}\` **${g.name}** (${g.memberCount} members) (owner **${owner.tag}** \`${owner.id}\`)`;
|
||||
return `\`${paddedId}\` **${g.name}** (${g.memberCount} members) (owner **${renderUsername(owner)}** \`${
|
||||
owner.id
|
||||
}\`)`;
|
||||
});
|
||||
createChunkedMessage(msg.channel, lines.join("\n"));
|
||||
} else {
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, globalPluginEventListener, globalPluginMessageCommand } from "knub";
|
||||
import z from "zod";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
import { Configs } from "../../data/Configs";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { tNullable } from "../../utils";
|
||||
import { zBoundedCharacters } from "../../utils";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
can_use: t.boolean,
|
||||
can_eligible: t.boolean,
|
||||
can_performance: t.boolean,
|
||||
can_add_server_from_invite: t.boolean,
|
||||
can_list_dashboard_perms: t.boolean,
|
||||
update_cmd: tNullable(t.string),
|
||||
export const zBotControlConfig = z.strictObject({
|
||||
can_use: z.boolean(),
|
||||
can_eligible: z.boolean(),
|
||||
can_performance: z.boolean(),
|
||||
can_add_server_from_invite: z.boolean(),
|
||||
can_list_dashboard_perms: z.boolean(),
|
||||
update_cmd: zBoundedCharacters(0, 2000).nullable(),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export interface BotControlPluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
config: z.output<typeof zBotControlConfig>;
|
||||
state: {
|
||||
archives: GuildArchives;
|
||||
allowedGuilds: AllowedGuilds;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue