mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
refactor: use .env STAFF instead of global config owners for global commands
This commit is contained in:
parent
91f54424ed
commit
f7fede47bd
14 changed files with 27 additions and 23 deletions
|
@ -9,6 +9,9 @@ BOT_TOKEN=
|
|||
DASHBOARD_URL=https://localhost:3300
|
||||
API_URL=https://localhost:3300/api
|
||||
|
||||
# Comma-separated list of user IDs who should have access to the bot's global commands
|
||||
STAFF=
|
||||
|
||||
# When using the Docker-based development environment, this is only used internally. The API will be available at localhost:DOCKER_DEV_WEB_PORT/api.
|
||||
API_PORT=3000
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import { TZeppelinKnub } from "./types";
|
|||
import { deepKeyIntersect, errorMessage, successMessage, tDeepPartial, tNullable } from "./utils";
|
||||
import { Tail } from "./utils/typeUtils";
|
||||
import { decodeAndValidateStrict, StrictValidationError, validate } from "./validatorUtils";
|
||||
import { isStaff } from "./staff";
|
||||
|
||||
const { getMemberLevel } = helpers;
|
||||
|
||||
|
@ -242,8 +243,8 @@ export function isOwner(pluginData: AnyPluginData<any>, userId: string) {
|
|||
return owners.includes(userId);
|
||||
}
|
||||
|
||||
export const isOwnerPreFilter = (_, context: CommandContext<any>) => {
|
||||
return isOwner(context.pluginData, context.message.author.id);
|
||||
export const isStaffPreFilter = (_, context: CommandContext<any>) => {
|
||||
return isStaff(context.message.author.id);
|
||||
};
|
||||
|
||||
type AnyFn = (...args: any[]) => any;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const AddDashboardUserCmd = botControlCmd({
|
||||
trigger: ["add_dashboard_user"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { DBDateFormat, isGuildInvite, isSnowflake, resolveInvite } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import moment from "moment-timezone";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ApiPermissions } from "@shared/apiPermissions";
|
||||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { DBDateFormat, isSnowflake } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import moment from "moment-timezone";
|
||||
|
@ -10,7 +10,7 @@ export const AllowServerCmd = botControlCmd({
|
|||
trigger: ["allow_server", "allowserver", "add_server", "addserver"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Guild, GuildChannel, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { GuildInvite, isGuildInvite, resolveInvite, verboseUserMention } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
import { isEligible } from "../functions/isEligible";
|
||||
|
@ -9,7 +9,7 @@ export const ChannelToServerCmd = botControlCmd({
|
|||
trigger: ["channel_to_server", "channel2server"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { noop } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -8,7 +8,7 @@ export const DisallowServerCmd = botControlCmd({
|
|||
trigger: ["disallow_server", "disallowserver", "remove_server", "removeserver"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const LeaveServerCmd = botControlCmd({
|
||||
trigger: ["leave_server", "leave_guild"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
|
@ -2,7 +2,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 { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { resolveUser } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { isOwnerPreFilter } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||
import { getActiveReload, setActiveReload } from "../activeReload";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -7,7 +7,7 @@ export const ReloadGlobalPluginsCmd = botControlCmd({
|
|||
trigger: "bot_reload_global_plugins",
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
async run({ pluginData, message }) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const ReloadServerCmd = botControlCmd({
|
||||
trigger: ["reload_server", "reload_guild"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
export const RemoveDashboardUserCmd = botControlCmd({
|
||||
trigger: ["remove_dashboard_user"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { TextChannel } from "discord.js";
|
||||
import escapeStringRegexp from "escape-string-regexp";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { isOwnerPreFilter } from "../../../pluginUtils";
|
||||
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||
import { createChunkedMessage, getUser, sorter } from "../../../utils";
|
||||
import { botControlCmd } from "../types";
|
||||
|
||||
|
@ -9,7 +9,7 @@ export const ServersCmd = botControlCmd({
|
|||
trigger: ["servers", "guilds"],
|
||||
permission: null,
|
||||
config: {
|
||||
preFilters: [isOwnerPreFilter],
|
||||
preFilters: [isStaffPreFilter],
|
||||
},
|
||||
|
||||
signature: {
|
||||
|
|
Loading…
Add table
Reference in a new issue