mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +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
|
DASHBOARD_URL=https://localhost:3300
|
||||||
API_URL=https://localhost:3300/api
|
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.
|
# 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
|
API_PORT=3000
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { TZeppelinKnub } from "./types";
|
||||||
import { deepKeyIntersect, errorMessage, successMessage, tDeepPartial, tNullable } from "./utils";
|
import { deepKeyIntersect, errorMessage, successMessage, tDeepPartial, tNullable } from "./utils";
|
||||||
import { Tail } from "./utils/typeUtils";
|
import { Tail } from "./utils/typeUtils";
|
||||||
import { decodeAndValidateStrict, StrictValidationError, validate } from "./validatorUtils";
|
import { decodeAndValidateStrict, StrictValidationError, validate } from "./validatorUtils";
|
||||||
|
import { isStaff } from "./staff";
|
||||||
|
|
||||||
const { getMemberLevel } = helpers;
|
const { getMemberLevel } = helpers;
|
||||||
|
|
||||||
|
@ -242,8 +243,8 @@ export function isOwner(pluginData: AnyPluginData<any>, userId: string) {
|
||||||
return owners.includes(userId);
|
return owners.includes(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isOwnerPreFilter = (_, context: CommandContext<any>) => {
|
export const isStaffPreFilter = (_, context: CommandContext<any>) => {
|
||||||
return isOwner(context.pluginData, context.message.author.id);
|
return isStaff(context.message.author.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
type AnyFn = (...args: any[]) => any;
|
type AnyFn = (...args: any[]) => any;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { ApiPermissions } from "@shared/apiPermissions";
|
import { ApiPermissions } from "@shared/apiPermissions";
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
export const AddDashboardUserCmd = botControlCmd({
|
export const AddDashboardUserCmd = botControlCmd({
|
||||||
trigger: ["add_dashboard_user"],
|
trigger: ["add_dashboard_user"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ApiPermissions } from "@shared/apiPermissions";
|
import { ApiPermissions } from "@shared/apiPermissions";
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
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 { DBDateFormat, isGuildInvite, isSnowflake, resolveInvite } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ApiPermissions } from "@shared/apiPermissions";
|
import { ApiPermissions } from "@shared/apiPermissions";
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { DBDateFormat, isSnowflake } from "../../../utils";
|
import { DBDateFormat, isSnowflake } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
@ -10,7 +10,7 @@ export const AllowServerCmd = botControlCmd({
|
||||||
trigger: ["allow_server", "allowserver", "add_server", "addserver"],
|
trigger: ["allow_server", "allowserver", "add_server", "addserver"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Guild, GuildChannel, TextChannel } from "discord.js";
|
import { Guild, GuildChannel, TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
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 { GuildInvite, isGuildInvite, resolveInvite, verboseUserMention } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
import { isEligible } from "../functions/isEligible";
|
import { isEligible } from "../functions/isEligible";
|
||||||
|
@ -9,7 +9,7 @@ export const ChannelToServerCmd = botControlCmd({
|
||||||
trigger: ["channel_to_server", "channel2server"],
|
trigger: ["channel_to_server", "channel2server"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Snowflake, TextChannel } from "discord.js";
|
import { Snowflake, TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { noop } from "../../../utils";
|
import { noop } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ export const DisallowServerCmd = botControlCmd({
|
||||||
trigger: ["disallow_server", "disallowserver", "remove_server", "removeserver"],
|
trigger: ["disallow_server", "disallowserver", "remove_server", "removeserver"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { Snowflake, TextChannel } from "discord.js";
|
import { Snowflake, TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
export const LeaveServerCmd = botControlCmd({
|
export const LeaveServerCmd = botControlCmd({
|
||||||
trigger: ["leave_server", "leave_guild"],
|
trigger: ["leave_server", "leave_guild"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { AllowedGuild } from "../../../data/entities/AllowedGuild";
|
import { AllowedGuild } from "../../../data/entities/AllowedGuild";
|
||||||
import { ApiPermissionAssignment } from "../../../data/entities/ApiPermissionAssignment";
|
import { ApiPermissionAssignment } from "../../../data/entities/ApiPermissionAssignment";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { resolveUser } from "../../../utils";
|
import { resolveUser } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { resolveUser } from "../../../utils";
|
import { resolveUser } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import { isOwnerPreFilter } from "../../../pluginUtils";
|
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||||
import { getActiveReload, setActiveReload } from "../activeReload";
|
import { getActiveReload, setActiveReload } from "../activeReload";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ export const ReloadGlobalPluginsCmd = botControlCmd({
|
||||||
trigger: "bot_reload_global_plugins",
|
trigger: "bot_reload_global_plugins",
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
async run({ pluginData, message }) {
|
async run({ pluginData, message }) {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { Snowflake, TextChannel } from "discord.js";
|
import { Snowflake, TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
export const ReloadServerCmd = botControlCmd({
|
export const ReloadServerCmd = botControlCmd({
|
||||||
trigger: ["reload_server", "reload_guild"],
|
trigger: ["reload_server", "reload_guild"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
import { isStaffPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
export const RemoveDashboardUserCmd = botControlCmd({
|
export const RemoveDashboardUserCmd = botControlCmd({
|
||||||
trigger: ["remove_dashboard_user"],
|
trigger: ["remove_dashboard_user"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { TextChannel } from "discord.js";
|
import { TextChannel } from "discord.js";
|
||||||
import escapeStringRegexp from "escape-string-regexp";
|
import escapeStringRegexp from "escape-string-regexp";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { isOwnerPreFilter } from "../../../pluginUtils";
|
import { isStaffPreFilter } from "../../../pluginUtils";
|
||||||
import { createChunkedMessage, getUser, sorter } from "../../../utils";
|
import { createChunkedMessage, getUser, sorter } from "../../../utils";
|
||||||
import { botControlCmd } from "../types";
|
import { botControlCmd } from "../types";
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ export const ServersCmd = botControlCmd({
|
||||||
trigger: ["servers", "guilds"],
|
trigger: ["servers", "guilds"],
|
||||||
permission: null,
|
permission: null,
|
||||||
config: {
|
config: {
|
||||||
preFilters: [isOwnerPreFilter],
|
preFilters: [isStaffPreFilter],
|
||||||
},
|
},
|
||||||
|
|
||||||
signature: {
|
signature: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue