26 lines
728 B
JavaScript
26 lines
728 B
JavaScript
/**
|
||
* 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;
|
||
} |