Update from Git Manager GUI
This commit is contained in:
26
util/ownerOnly.js
Normal file
26
util/ownerOnly.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user