Files
SpigotWatch/util/ownerOnly.js
2026-02-25 18:51:13 +01:00

26 lines
728 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* util/ownerOnly.js
* Hilfsfunktion um Owner-only Befehle zu schützen.
*/
import { t } from "./i18n.js";
/**
* Gibt true zurück wenn der Nutzer der Bot-Owner ist.
* @param {Object} client
* @param {Object} ctx message oder slash ctx
* @param {string} lang
*/
export function isOwner(client, ctx) {
const userID = ctx.isSlash ? ctx.interaction.user.id : ctx.author.id;
return userID === client.config.ownerID;
}
/**
* Prüft ob Owner wenn nicht, antwortet mit Fehlermeldung und gibt false zurück.
*/
export async function requireOwner(client, ctx, lang = "de") {
if (isOwner(client, ctx)) return true;
await ctx.reply({ content: t(lang, "error.onlyOwner"), ephemeral: true });
return false;
}