File size: 3,926 Bytes
9d1558c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | const fs = require("fs-extra");
const { utils } = global;
module.exports = {
config: {
name: "prefix",
version: "1.3",
author: "NTKhang",
countDown: 5,
role: 0,
shortDescription: "Thay đổi prefix của bot",
longDescription: "Thay đổi dấu lệnh của bot trong box chat của bạn hoặc cả hệ thống bot (chỉ admin bot)",
category: "config",
guide: {
vi: " {pn} <new prefix>: thay đổi prefix mới trong box chat của bạn"
+ "\n Ví dụ:"
+ "\n {pn} #"
+ "\n\n {pn} <new prefix> -g: thay đổi prefix mới trong hệ thống bot (chỉ admin bot)"
+ "\n Ví dụ:"
+ "\n {pn} # -g"
+ "\n\n {pn} reset: thay đổi prefix trong box chat của bạn về mặc định",
en: " {pn} <new prefix>: change new prefix in your box chat"
+ "\n Example:"
+ "\n {pn} #"
+ "\n\n {pn} <new prefix> -g: change new prefix in system bot (only admin bot)"
+ "\n Example:"
+ "\n {pn} # -g"
+ "\n\n {pn} reset: change prefix in your box chat to default"
}
},
langs: {
vi: {
reset: "Đã reset prefix của bạn về mặc định: %1",
onlyAdmin: "Chỉ admin mới có thể thay đổi prefix hệ thống bot",
confirmGlobal: "Vui lòng thả cảm xúc bất kỳ vào tin nhắn này để xác nhận thay đổi prefix của toàn bộ hệ thống bot",
confirmThisThread: "Vui lòng thả cảm xúc bất kỳ vào tin nhắn này để xác nhận thay đổi prefix trong nhóm chat của bạn",
successGlobal: "Đã thay đổi prefix hệ thống bot thành: %1",
successThisThread: "Đã thay đổi prefix trong nhóm chat của bạn thành: %1",
myPrefix: "🌐 Prefix của hệ thống: %1\n🛸 Prefix của nhóm bạn: %2"
},
en: {
reset: "Your prefix has been reset to default: %1",
onlyAdmin: "Only admin can change prefix of system bot",
confirmGlobal: "Please react to this message to confirm change prefix of system bot",
confirmThisThread: "Please react to this message to confirm change prefix in your box chat",
successGlobal: "Changed prefix of system bot to: %1",
successThisThread: "Changed prefix in your box chat to: %1",
myPrefix: "🌐 System prefix: %1\n🛸 Your box chat prefix: %2"
}
},
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
};
if (args[1] === "-g")
if (role < 2)
return message.reply(getLang("onlyAdmin"));
else
formSet.setGlobal = true;
else
formSet.setGlobal = false;
return message.reply(args[1] === "-g" ? getLang("confirmGlobal") : getLang("confirmThisThread"), (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));
}
else {
await threadsData.set(event.threadID, newPrefix, "data.prefix");
return message.reply(getLang("successThisThread", newPrefix));
}
},
onChat: async function ({ event, message, getLang }) {
if (event.body && event.body.toLowerCase() === "prefix")
return () => {
return message.reply(getLang("myPrefix", global.GoatBot.config.prefix, utils.getPrefix(event.threadID)));
};
}
}; |