Skip to content

Instantly share code, notes, and snippets.

@dipto-008
Created July 10, 2025 04:20
Show Gist options
  • Save dipto-008/8e3d8ba9c4cdec1ef838fb46d6210ef8 to your computer and use it in GitHub Desktop.
Save dipto-008/8e3d8ba9c4cdec1ef838fb46d6210ef8 to your computer and use it in GitHub Desktop.
Hey noob ๐Ÿ‘‹๐Ÿ‘‹
const fs = require("fs-extra");
const { utils } = global;
module.exports = {
config: {
name: "prefix",
version: "1.5",
author: "Ew'r Saim",
countDown: 5,
role: 0,
description: "Change the bot prefix in this chat or globally (admin only)",
category: "system",
guide: {
en:
"โ•ญโ”€ใ€Ž โœจ PREFIX COMMAND โœจ ใ€\n" +
"โ”‚\n" +
"โ”‚ ๐Ÿ”น {pn} <newPrefix>\n" +
"โ”‚ โžฅ Set a new prefix for this chat only\n" +
"โ”‚ โžค Example: {pn} $\n" +
"โ”‚\n" +
"โ”‚ ๐Ÿ”น {pn} <newPrefix> -g\n" +
"โ”‚ โžฅ Set a new global prefix (admin only)\n" +
"โ”‚ โžค Example: {pn} ! -g\n" +
"โ”‚\n" +
"โ”‚ โ™ป๏ธ {pn} reset\n" +
"โ”‚ โžฅ Reset to default prefix from config\n" +
"โ”‚\n" +
"โ”‚ ๐Ÿ“Œ Just type: prefix\n" +
"โ”‚ โžฅ Shows current prefix info\n" +
"โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€"
}
},
langs: {
en: {
reset: "โœ… Reset to default prefix: %1",
onlyAdmin: "โ›” Only bot admins can change global prefix!",
confirmGlobal: "โš™๏ธ React to confirm global prefix update.",
confirmThisThread: "โš™๏ธ React to confirm this chat's prefix update.",
successGlobal: "โœ… Global prefix updated: %1",
successThisThread: "โœ… Chat prefix updated: %1"
}
},
onStart: async function ({ message, role, args, commandName, event, threadsData, getLang }) {
if (!args[0]) return message.SyntaxError();
if (args[0] === "reset") {
await threadsData.set(event.threadID, null, "data.prefix");
return message.reply(getLang("reset", global.GoatBot.config.prefix));
}
const newPrefix = args[0];
const formSet = {
commandName,
author: event.senderID,
newPrefix,
setGlobal: args[1] === "-g"
};
if (formSet.setGlobal && role < 2) {
return message.reply(getLang("onlyAdmin"));
}
const confirmMessage = formSet.setGlobal ? getLang("confirmGlobal") : getLang("confirmThisThread");
return message.reply(confirmMessage, (err, info) => {
formSet.messageID = info.messageID;
global.GoatBot.onReaction.set(info.messageID, formSet);
});
},
onReaction: async function ({ message, threadsData, event, Reaction, getLang }) {
const { author, newPrefix, setGlobal } = Reaction;
if (event.userID !== author) return;
if (setGlobal) {
global.GoatBot.config.prefix = newPrefix;
fs.writeFileSync(global.client.dirConfig, JSON.stringify(global.GoatBot.config, null, 2));
return message.reply(getLang("successGlobal", newPrefix));
}
await threadsData.set(event.threadID, newPrefix, "data.prefix");
return message.reply(getLang("successThisThread", newPrefix));
},
onChat: async function ({ event, message, threadsData, usersData }) {
const globalPrefix = global.GoatBot.config.prefix;
const threadPrefix = await threadsData.get(event.threadID, "data.prefix") || globalPrefix;
if (event.body && event.body.toLowerCase() === "prefix") {
const userName = await usersData.getName(event.senderID);
return message.reply(
`๐Ÿ‘‹ ๐‡๐ž๐ฒ ${userName}, ๐๐ข๐ ๐ฒ๐จ๐ฎ ๐š๐ฌ๐ค ๐Ÿ๐จ๐ซ ๐ฆ๐ฒ ๐ฉ๐ซ๐ž๐Ÿ๐ข๐ฑ?\n` +
`โžฅ ๐ŸŒ ๐†๐ฅ๐จ๐›๐š๐ฅ: ${globalPrefix}\n` +
`โžฅ ๐Ÿ’ฌ ๐“๐ก๐ข๐ฌ ๐‚๐ก๐š๐ญ: ${threadPrefix}\n` +
`๐ˆ'๐ฆ , ๐™Ž๐˜ผ๐™†๐™๐™๐˜ผ_๐‘ฏ๐˜ผ๐™๐™๐™†๐˜ผ ๐ง๐ข๐œ๐ž ๐ญ๐จ ๐ฆ๐ž๐ž๐ญ ๐ฒ๐จ๐ฎ! `
);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment