smoothretro1982

diamond26's diamondbot v7.14.4.2 edited by DG_ (\cleararea (quiet mode))

Apr 4th, 2026 (edited)
78
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 74.18 KB | None | 0 0
  1. !async function() {
  2. "use strict";
  3. if ("undefined" == typeof w) console.error("TextWall API (w) not found! Make sure you're on tw.2s4.me");
  4. else {
  5. const o = {
  6. save: function(e, s) {
  7. try {
  8. return localStorage.setItem("diamondbot_" + e, JSON.stringify(s)), !0
  9. } catch (e) {
  10. return console.error("Failed to save to storage:", e), !1
  11. }
  12. },
  13. load: function(e, s = null) {
  14. try {
  15. var t = localStorage.getItem("diamondbot_" + e);
  16. return t ? JSON.parse(t) : s
  17. } catch (e) {
  18. return console.error("Failed to load from storage:", e), s
  19. }
  20. },
  21. remove: function(e) {
  22. try {
  23. return localStorage.removeItem("diamondbot_" + e), !0
  24. } catch (e) {
  25. return console.error("Failed to remove from storage:", e), !1
  26. }
  27. }
  28. },
  29. a = {
  30. version: "7.14.4.2",
  31. username: "diamondbot",
  32. color: 0,
  33. prefix: "\\",
  34. authorizedUsers: o.load("authorizedUsers", ["dominoguy_", "Diamond26", "KiwiTest"]),
  35. defaultAuthorities: o.load("defaultAuthorities", ["Diamond26", "KiwiTest"]),
  36. bannedUsers: o.load("bannedUsers", []),
  37. bannedIds: o.load("bannedIds", []),
  38. messageDelay: 150,
  39. position: {
  40. x: 0,
  41. y: 0
  42. },
  43. heightSafetyEnabled: !0,
  44. lastAuthorityMessage: "",
  45. authorityEchoEnabled: !1,
  46. echoColorEnabled: !1
  47. },
  48. s = {
  49. wall: "",
  50. subwall: "",
  51. perms: 0,
  52. isRegistered: !1,
  53. isAdmin: !1,
  54. readonly: !1,
  55. hidecursors: !1,
  56. disablechat: !1,
  57. disablecolor: !1,
  58. disablebraille: !1,
  59. members: [],
  60. walllist: [],
  61. activeTimers: new Map,
  62. activeCounts: new Map,
  63. commandCooldowns: new Map,
  64. messageQueue: [],
  65. isProcessingQueue: !1,
  66. lastMessageTime: 0,
  67. cursors: new Map,
  68. adminUsers: new Set,
  69. processedMessages: new Set,
  70. lastSayUser: null,
  71. userPositions: new Map,
  72. userIds: new Map,
  73. isShuttingDown: !1,
  74. isTyping: !1,
  75. countdownActive: !1,
  76. clearingArea: !1
  77. },
  78. r = {
  79. "#000000": 0,
  80. "#ffffff": 1,
  81. "#ff0000": 2,
  82. "#00ff00": 3,
  83. "#0000ff": 4,
  84. "#ffff00": 5,
  85. "#ff00ff": 6,
  86. "#00ffff": 7,
  87. "#808080": 8,
  88. "#ff8800": 9,
  89. "#8800ff": 10,
  90. "#0088ff": 11,
  91. "#88ff00": 12,
  92. "#ff0088": 13,
  93. "#884400": 14,
  94. "#448800": 15
  95. },
  96. n = ["to", "tp", "colorid", "addauth", "removeauth", "disablehs", "echoauth", "echocolor", "csay", "ban", "unban", "banid", "unbanid", "type", "cleararea", "wallwarp"],
  97. i = [{
  98. version: "7.14.4.2",
  99. changes: "Fixed \cleararea outputs all messages to console. (quiet mode)"
  100. }],
  101. h = {
  102. 1: [{
  103. cmd: "help",
  104. desc: "Show command pages",
  105. auth: !1
  106. },
  107. {
  108. cmd: "thelp",
  109. desc: "Type help on wall",
  110. auth: !1
  111. },
  112. {
  113. cmd: "fullcmd",
  114. desc: "Get full command list location",
  115. auth: !1
  116. },
  117. {
  118. cmd: "info",
  119. desc: "Show bot information",
  120. auth: !1
  121. },
  122. {
  123. cmd: "chl",
  124. desc: "Show changelog",
  125. auth: !1
  126. }
  127. ],
  128. 2: [{
  129. cmd: "ping",
  130. desc: "Responds with Pong!",
  131. auth: !1
  132. },
  133. {
  134. cmd: "rate",
  135. desc: "Rate something out of 10",
  136. auth: !0
  137. },
  138. {
  139. cmd: "calculate",
  140. desc: "Calculate p1^p2",
  141. auth: !1
  142. },
  143. {
  144. cmd: "calc2",
  145. desc: "Calculate p1^^p2 (tetration)",
  146. auth: !1
  147. },
  148. {
  149. cmd: "rng",
  150. desc: "Random number between min and max",
  151. auth: !1
  152. }
  153. ],
  154. 3: [{
  155. cmd: "say",
  156. desc: "Make bot say something",
  157. auth: !1
  158. },
  159. {
  160. cmd: "timer",
  161. desc: "Set a timer (h m s)",
  162. auth: !1
  163. },
  164. {
  165. cmd: "count",
  166. desc: "Count from 1 to n with cooldown",
  167. auth: !1
  168. },
  169. {
  170. cmd: "tcountdown",
  171. desc: "Type countdown with progress bar",
  172. auth: !1
  173. },
  174. {
  175. cmd: "status",
  176. desc: "Show bot status",
  177. auth: !1
  178. }
  179. ],
  180. 4: [{
  181. cmd: "pos",
  182. desc: "Show cursor position (x,y coordinates)",
  183. auth: !1
  184. },
  185. {
  186. cmd: "type",
  187. desc: "Type characters on wall (Authority)",
  188. auth: !0
  189. },
  190. {
  191. cmd: "page",
  192. desc: "Show detailed page info",
  193. auth: !1
  194. },
  195. {
  196. cmd: "members",
  197. desc: "List wall members",
  198. auth: !1
  199. },
  200. {
  201. cmd: "walls",
  202. desc: "List available subwalls",
  203. auth: !1
  204. }
  205. ],
  206. 5: [{
  207. cmd: "authlist",
  208. desc: "Show authorized users",
  209. auth: !1
  210. },
  211. {
  212. cmd: "userlist",
  213. desc: "Show all online users in wall",
  214. auth: !1
  215. },
  216. {
  217. cmd: "to",
  218. desc: "Teleport bot to X Y (Authority)",
  219. auth: !0
  220. },
  221. {
  222. cmd: "tp",
  223. desc: "Teleport to X Y using w.tp (Authority)",
  224. auth: !0
  225. },
  226. {
  227. cmd: "colorid",
  228. desc: "Change bot color (Authority)",
  229. auth: !0
  230. }
  231. ],
  232. 6: [{
  233. cmd: "cleararea",
  234. desc: "Clear non-space chars (Authority)",
  235. auth: !0
  236. },
  237. {
  238. cmd: "csay",
  239. desc: "Say colored text (Authority)",
  240. auth: !0
  241. },
  242. {
  243. cmd: "addauth",
  244. desc: "Add user to authority list (Authority)",
  245. auth: !0
  246. },
  247. {
  248. cmd: "removeauth",
  249. desc: "Remove user from authority (Authority)",
  250. auth: !0
  251. },
  252. {
  253. cmd: "ban",
  254. desc: "Ban user from using bot (Authority)",
  255. auth: !0
  256. }
  257. ],
  258. 7: [{
  259. cmd: "unban",
  260. desc: "Unban user/ID (Authority)",
  261. auth: !0
  262. },
  263. {
  264. cmd: "banid",
  265. desc: "Ban user by ID (Authority)",
  266. auth: !0
  267. },
  268. {
  269. cmd: "unbanid",
  270. desc: "Unban user by ID (Authority)",
  271. auth: !0
  272. },
  273. {
  274. cmd: "banlist",
  275. desc: "Show banned users (Authority)",
  276. auth: !0
  277. },
  278. {
  279. cmd: "disableHS",
  280. desc: "Toggle height safety (Authority)",
  281. auth: !0
  282. }
  283. ],
  284. 8: [{
  285. cmd: "echoauth",
  286. desc: "Toggle authority echo (Authority)",
  287. auth: !0
  288. },
  289. {
  290. cmd: "echocolor",
  291. desc: "Toggle color echo (Authority)",
  292. auth: !0
  293. },
  294. {
  295. cmd: "wallwarp",
  296. desc: "Warp to wall/subwall (Authority)",
  297. auth: !0
  298. }
  299. ]
  300. };
  301.  
  302. class t {
  303. constructor(e) {
  304. this.config = e;
  305. this.state = s;
  306. this.eventHandlers = {};
  307. this.running = !0;
  308. }
  309.  
  310. async init() {
  311. console.log("===================================");
  312. console.log(` TextWall Bot v${this.config.version} Initializing `);
  313. console.log("===================================");
  314. await e();
  315. this.setupEventListeners();
  316. this.setUsername(this.config.username);
  317. this.setColor(this.config.color);
  318. this.teleportCursor(0, 0);
  319. setTimeout(() => {
  320. this.sendMessage(`${this.config.username} v${this.config.version} online! Type ${this.config.prefix}help for commands`);
  321. }, 2e3);
  322. console.log("[OK] Bot initialized successfully!");
  323. console.log("[OK] Prefix: " + this.config.prefix);
  324. console.log("[OK] Authorized users: " + this.config.authorizedUsers.join(", "));
  325. console.log("[OK] Default authorities: " + this.config.defaultAuthorities.join(", "));
  326. console.log("[OK] Banned users: " + this.config.bannedUsers.length);
  327. console.log("[OK] Banned IDs: " + this.config.bannedIds.length);
  328. console.log("[OK] Type window.showCommands() to see all commands in console");
  329. console.log("[OK] Color syntax: <start #HEXCOLOR>text<end>");
  330. console.log("[OK] Y coordinates are flipped (negated)");
  331. console.log("===================================");
  332. }
  333.  
  334. setupEventListeners() {
  335. this.eventHandlers = {
  336. join: e => this.onJoin(e),
  337. alert: e => this.onAlert(e),
  338. msg: e => this.onMessage(e),
  339. edit: e => this.onEdit(e),
  340. protect: e => this.onProtect(e),
  341. clear: e => this.onClear(e),
  342. cursor: e => this.onCursor(e),
  343. cursorleft: e => this.onCursorLeft(e),
  344. perms: e => this.onPerms(e),
  345. memberadded: e => this.onMemberAdded(e),
  346. memberlist: e => this.onMemberList(e),
  347. walllist: e => this.onWallList(e),
  348. readonly: e => this.onReadonly(e),
  349. hidecursors: e => this.onHideCursors(e),
  350. disablechat: e => this.onDisableChat(e),
  351. disablecolor: e => this.onDisableColor(e),
  352. disablebraille: e => this.onDisableBraille(e),
  353. nametaken: () => this.onNameTaken(),
  354. passfail: () => this.onPassFail(),
  355. tokenfail: () => this.onTokenFail(),
  356. regclosed: () => this.onRegClosed(),
  357. namechanged: e => this.onNameChanged(e),
  358. accountdeleted: () => this.onAccountDeleted(),
  359. pong: e => this.onPong(e)
  360. };
  361. for (var [e, s] of Object.entries(this.eventHandlers)) w && w.on && w.on(e, s);
  362. console.log(`[OK] Registered ${Object.keys(this.eventHandlers).length} event listeners`);
  363. }
  364.  
  365. cleanup() {
  366. this.running = !1;
  367. this.state.countdownActive = !1;
  368. this.state.clearingArea = !1;
  369. for (var [e, s] of Object.entries(this.eventHandlers)) w && w.off && w.off(e, s);
  370. this.state.activeTimers.forEach(e => {
  371. clearTimeout(e.timeout);
  372. e.intervalId && clearInterval(e.intervalId);
  373. });
  374. this.state.activeCounts.forEach(e => {
  375. e.intervalId && clearInterval(e.intervalId);
  376. });
  377. console.log("[OK] Bot cleaned up");
  378. }
  379.  
  380. isAuthorized(e, s) {
  381. return s ? (this.state.adminUsers.add(e), !0) : this.config.authorizedUsers.includes(e);
  382. }
  383. isBanned(e) {
  384. return this.config.bannedUsers.includes(e);
  385. }
  386. isIdBanned(e) {
  387. return this.config.bannedIds.includes(e);
  388. }
  389.  
  390. getUserId(e) {
  391. for (var [s, t] of this.state.cursors.entries())
  392. if (t.name === e) return s;
  393. return this.state.userIds.get(e) || null;
  394. }
  395.  
  396. getCursorPosition(s) {
  397. if (this.state.userPositions.has(s)) return this.state.userPositions.get(s);
  398. try {
  399. if ("undefined" != typeof w && w.cursors)
  400. for (let e = 0; e < Array.from(w.cursors).length; e++) {
  401. var t = Array.from(w.cursors)[e][1];
  402. if (t && t.n === s && t.l) return [t.l[0], -t.l[1]];
  403. }
  404. } catch (e) {
  405. console.error("[CURSOR POS ERROR]", e);
  406. }
  407. for (var e of this.state.cursors.values())
  408. if (e.name === s) return e.location;
  409. return null;
  410. }
  411.  
  412. containsAuthorityCommand(e) {
  413. var s, t = e.toLowerCase();
  414. for (s of n)
  415. if (t.includes("" + this.config.prefix + s)) return !0;
  416. return !1;
  417. }
  418.  
  419. hasColorSyntax(e) {
  420. return /<start\s+#[0-9a-fA-F]{6}>([^<]*)<end>/i.test(e);
  421. }
  422.  
  423. parseColoredMessage(e) {
  424. var s, t = /<start\s+(#[0-9a-fA-F]{6})>([^<]*)<end>/gi,
  425. o = [];
  426. let n = 0;
  427. for (; null !== (s = t.exec(e));) {
  428. s.index > n && o.push({
  429. text: e.substring(n, s.index),
  430. color: null
  431. });
  432. var i = s[1].toLowerCase(),
  433. a = s[2],
  434. i = r[i];
  435. o.push({
  436. text: a,
  437. color: void 0 !== i ? i : null
  438. });
  439. n = s.index + s[0].length;
  440. }
  441. return n < e.length && o.push({
  442. text: e.substring(n),
  443. color: null
  444. }), 0 === o.length ? [{
  445. text: e,
  446. color: null
  447. }] : o;
  448. }
  449.  
  450. onJoin(e) {
  451. this.state.wall = e.wall || "";
  452. this.state.subwall = e.subwall || "";
  453. console.log(`[JOINED] ${this.state.wall}/` + this.state.subwall);
  454. }
  455. onAlert(e) {
  456. console.log("[ALERT] " + e.message);
  457. }
  458.  
  459. onMessage(e) {
  460. var s, t, o, n;
  461. e && e.msg && (e.nick === this.config.username || (s = e.msg.trim(), t = e.nick || "Unknown", o = e.isAdmin || !1, (n = e.id || null) && t && this.state.userIds.set(t, n), n = t + `-${s}-` + Date.now(), this.state.processedMessages.has(n)) || (this.state.processedMessages.add(n), 100 < this.state.processedMessages.size && (n = Array.from(this.state.processedMessages)).slice(0, n.length - 100).forEach(e => {
  462. this.state.processedMessages.delete(e);
  463. }), o && this.state.adminUsers.add(t), this.isAuthorized(t, o) ? (console.log(`[AUTHORITY] ${t} ~ ` + s), this.config.echoColorEnabled && !s.startsWith(this.config.prefix) && !s.includes("[AUTHORITY COLOR]") && this.hasColorSyntax(s) ? this.sendMessage(`[AUTHORITY COLOR] ${t} ~ ` + s) : !this.config.authorityEchoEnabled || s.startsWith(this.config.prefix) || s.includes("[AUTHORITY]") || this.hasColorSyntax(s) || this.config.lastAuthorityMessage === t + ":" + s || (this.config.lastAuthorityMessage = t + ":" + s, this.sendMessage(`[AUTHORITY] ${t} ~ ` + s))) : console.log(`[MSG] ${t}${e.isRegistered ? " (R)" : ""}: ` + s), s.startsWith(this.config.prefix) && this.handleCommand(s, t, e)));
  464. }
  465.  
  466. onEdit(e) {
  467. e.edits && 0 < e.edits.length && console.log(`[EDIT] ${e.edits.length} edit(s) made`);
  468. }
  469. onProtect(e) {
  470. console.log(`[PROTECT] Chunk ${e.cell} protection: ` + (e.protect ? "ON" : "OFF"));
  471. }
  472. onClear(e) {
  473. console.log(`[CLEAR] Area cleared: (${e.x1},${e.y1}) to (${e.x2},${e.y2})`);
  474. }
  475.  
  476. onCursor(e) {
  477. var s;
  478. e.id && (s = e.l ? [e.l[0], -e.l[1]] : [0, 0], this.state.cursors.set(e.id, {
  479. name: e.n || "",
  480. location: s,
  481. color: e.c || 0
  482. }), e.n && (this.state.userPositions.set(e.n, s), this.state.userIds.set(e.n, e.id)), e.n === this.config.username) && e.l && (this.config.position.x = e.l[0], this.config.position.y = -e.l[1]);
  483. }
  484.  
  485. onCursorLeft(e) {
  486. var s = this.state.cursors.get(e);
  487. s && s.name && this.state.userPositions.delete(s.name);
  488. this.state.cursors.delete(e);
  489. }
  490. onPerms(e) {
  491. this.state.perms = e;
  492. console.log(`[PERMS] ${["User", "Member", "Owner"][e] || "Unknown"} (${e})`);
  493. }
  494. onMemberAdded(e) {
  495. console.log("[MEMBER+] " + e);
  496. this.state.members.includes(e) || this.state.members.push(e);
  497. }
  498. onMemberList(e) {
  499. this.state.members = e || [];
  500. console.log("[MEMBERS] " + (this.state.members.join(", ") || "None"));
  501. }
  502. onWallList(e) {
  503. this.state.walllist = e || [];
  504. console.log(`[WALLS] ${e.length / 2} wall(s) available`);
  505. }
  506. onReadonly(e) {
  507. (this.state.readonly = e) && console.log("[STATE] Wall is now READONLY");
  508. }
  509. onHideCursors(e) {
  510. (this.state.hidecursors = e) && console.log("[STATE] Cursors are now HIDDEN");
  511. }
  512. onDisableChat(e) {
  513. (this.state.disablechat = e) && console.log("[STATE] Chat is DISABLED");
  514. }
  515. onDisableColor(e) {
  516. (this.state.disablecolor = e) && console.log("[STATE] Colors are DISABLED");
  517. }
  518. onDisableBraille(e) {
  519. (this.state.disablebraille = e) && console.log("[STATE] Braille is DISABLED");
  520. }
  521. onNameTaken() {
  522. console.log("[ERROR] Name is already taken!");
  523. }
  524. onPassFail() {
  525. console.log("[ERROR] Invalid password!");
  526. }
  527. onTokenFail() {
  528. console.log("[ERROR] Invalid token!");
  529. }
  530. onRegClosed() {
  531. console.log("[ERROR] Registration is closed!");
  532. }
  533. onNameChanged(e) {
  534. console.log("[OK] Name changed to: " + e);
  535. this.config.username = e;
  536. }
  537. onAccountDeleted() {
  538. console.log("[ERROR] Account has been deleted!");
  539. }
  540. onPong(e) {}
  541.  
  542. handleCommand(e, s, t) {
  543. var o, n, i, a, r = t.id || this.getUserId(s);
  544. r && this.isIdBanned(r) ? this.sendMessage("ERR: your id banned from using bot.") : this.isBanned(s) ? this.sendMessage("You're banned.") : ([r, ...e] = e.slice(this.config.prefix.length).split(/\s+/), o = (r = r.toLowerCase()) + "-" + (this.state.lastSayUser = s), n = this.state.commandCooldowns.get(o) || 0, i = Date.now(), a = this.isAuthorized(s, t.isAdmin), i - n < 2e3 && !a || (this.state.commandCooldowns.set(o, i), this.executeCommand(r, e, s, t)));
  545. }
  546.  
  547. executeCommand(e, s, t, o) {
  548. const n = this.isAuthorized(t, o.isAdmin);
  549. e = {
  550. ping: () => this.cmdPing(),
  551. rate: () => this.cmdRate(s),
  552. help: () => this.cmdHelp(s),
  553. thelp: () => this.cmdTypeHelp(s),
  554. fullcmd: () => this.cmdFullcmd(),
  555. info: () => this.cmdInfo(),
  556. chl: () => this.cmdChangelog(s),
  557. calculate: () => this.cmdCalculate(s),
  558. calc2: () => this.cmdTetration(s),
  559. rng: () => this.cmdRandom(s),
  560. timer: () => this.cmdTimer(s),
  561. say: () => this.cmdSay(s, t, o.isAdmin),
  562. count: () => this.cmdCount(s),
  563. tcountdown: () => this.cmdTypeCountdown(s),
  564. status: () => this.cmdStatus(),
  565. pos: () => this.cmdPosition(s, t),
  566. page: () => this.cmdPage(s),
  567. members: () => this.cmdMembers(),
  568. walls: () => this.cmdWalls(),
  569. authlist: () => this.cmdAuthList(),
  570. userlist: () => this.cmdUserList(),
  571. to: () => n ? this.cmdTeleport(s) : this.sendMessage("Permission invalid - Authority required"),
  572. tp: () => n ? this.cmdTp(s) : this.sendMessage("Permission invalid - Authority required"),
  573. type: () => n ? this.cmdType(s) : this.sendMessage("Permission invalid - Authority required"),
  574. colorid: () => n ? this.cmdColor(s) : this.sendMessage("Permission invalid"),
  575. cleararea: () => n ? this.cmdClearArea(s) : this.sendMessage("Permission invalid - Authority required"),
  576. csay: () => n ? this.cmdColoredSay(s) : this.sendMessage("Permission invalid - Authority required"),
  577. addauth: () => n ? this.cmdAddAuth(s) : this.sendMessage("Permission invalid - Authority required"),
  578. removeauth: () => n ? this.cmdRemoveAuth(s) : this.sendMessage("Permission invalid - Authority required"),
  579. ban: () => n ? this.cmdBan(s) : this.sendMessage("Permission invalid - Authority required"),
  580. unban: () => n ? this.cmdUnban(s) : this.sendMessage("Permission invalid - Authority required"),
  581. banid: () => n ? this.cmdBanId(s) : this.sendMessage("Permission invalid - Authority required"),
  582. unbanid: () => n ? this.cmdUnbanId(s) : this.sendMessage("Permission invalid - Authority required"),
  583. banlist: () => n ? this.cmdBanList() : this.sendMessage("Permission invalid - Authority required"),
  584. disablehs: () => n ? this.cmdDisableHeightSafety() : this.sendMessage("Permission invalid - Authority required"),
  585. echoauth: () => n ? this.cmdToggleEcho() : this.sendMessage("Permission invalid - Authority required"),
  586. echocolor: () => n ? this.cmdToggleEchoColor() : this.sendMessage("Permission invalid - Authority required"),
  587. wallwarp: () => n ? this.cmdWallWarp(s) : this.sendMessage("Permission invalid - Authority required")
  588. } [e];
  589. e && e();
  590. }
  591.  
  592. cmdPing() {
  593. this.sendMessage("Pong!");
  594. }
  595. cmdRate(s) {
  596. if (s.length === 0) return this.sendMessage("Usage: \\rate [something]");
  597. const percentage = Math.floor(Math.random() * 101);
  598. this.sendMessage(`I rate ${s.join(" ")} as ${percentage}%`);
  599. }
  600.  
  601.  
  602. cmdHelp(e) {
  603. var s, e = e[0];
  604. // Check if the page number is valid
  605. if (void 0 === e || !isNaN(e) && Number.isInteger(Number(e))) {
  606. e = parseInt(e) || 1;
  607. s = Object.keys(h).length;
  608. if (e < 1 || s < e) {
  609. this.sendMessage(`Invalid number. Use ${this.config.prefix}help 1-` + s);
  610. } else {
  611. // Suppress header and show only commands separated by commas or new lines
  612. let commandList = h[e].map(cmdObj => `${this.config.prefix}${cmdObj.cmd}${cmdObj.auth ? " [A]" : ""}`).join(", ");
  613. this.sendMessage(commandList);
  614. }
  615. } else {
  616. this.sendMessage("Invalid number.");
  617. }
  618. }
  619.  
  620. cmdChangelog(e) {
  621. var s, t, o, e = e[0];
  622. void 0 === e || !isNaN(e) && Number.isInteger(Number(e)) ? (s = Math.ceil(i.length / 5), (e = parseInt(e) || 1) < 1 || s < e ? this.sendMessage(`Invalid number. Use ${this.config.prefix}chl 1-` + s) : (o = 5 * (e - 1), t = Math.min(5 + o, i.length), o = i.slice(o, t), this.sendMessage(`Changelog Page ${e}/${s}:`), o.forEach((e, s) => {
  623. setTimeout(() => {
  624. this.sendMessage(`v${e.version}: ` + e.changes);
  625. }, 700 * (s + 1));
  626. }))) : this.sendMessage("Invalid number.");
  627. }
  628.  
  629. cmdTypeCountdown(e) {
  630. if (0 < e.length && "stop" === e[0].toLowerCase()) return this.state.countdownActive ? (this.state.countdownActive = !1, this.sendMessage("Countdown stopped."), void console.log("[TCOUNTDOWN] Countdown stopped by user")) : void this.sendMessage("No countdown is currently active.");
  631. if (this.state.countdownActive) this.sendMessage("Countdown already active! Use \\tcountdown stop to stop it.");
  632. else if (e.length < 1) this.sendMessage(`Usage: ${this.config.prefix}tcountdown [seconds] or ${this.config.prefix}tcountdown stop`);
  633. else {
  634. e = parseInt(e[0]);
  635. if (isNaN(e) || e <= 0) this.sendMessage("Error: seconds must be a positive integer");
  636. else if (86400 < e) this.sendMessage("Error: seconds cannot exceed 86400 (24 hours)");
  637. else if ("function" != typeof w.tp || "function" != typeof w.typeChar) this.sendMessage("Error: w.tp or w.typeChar function not available");
  638. else {
  639. this.state.countdownActive = !0;
  640. const r = e;
  641. let a = e;
  642. const l = 6,
  643. h = -4,
  644. c = 14,
  645. d = (this.sendMessage(`Starting countdown from ${e}s at (0, -5)...`), setInterval(() => {
  646. if (!this.running || !this.state.countdownActive || a < 0) clearInterval(d), this.state.countdownActive = !1, a < 0 && this.sendMessage("Countdown complete!");
  647. else {
  648. try {
  649. w.tp(0, -5);
  650. var s, t = Math.floor(a / 3600),
  651. o = Math.floor(a % 3600 / 60),
  652. n = a % 60;
  653. let e = "";
  654. 0 < t && (e += t + "h "), 0 < o && (e += o + "m "), (0 < n || "" === e) && (e += n + "s");
  655. for (s of e = e.trim()) w.typeChar(s, 1);
  656. var i = 25 - e.length;
  657. for (let e = 0; e < i; e++) w.typeChar(" ", 1);
  658. ((e, s) => {
  659. var t = e / s * c;
  660. let o = "";
  661. for (let e = 0; e < c; e++) {
  662. var n = t - e;
  663. o += 1 <= n ? "█" : .75 <= n ? "▓" : .5 <= n ? "▒" : .25 <= n ? "░" : "•";
  664. }
  665. try {
  666. w.tp(l, h);
  667. for (var i of o) w.typeChar(i, 1);
  668. } catch (e) {
  669. console.error("[TCOUNTDOWN] Failed to update progress bar:", e);
  670. }
  671. })(r - a, r);
  672. console.log(`[TCOUNTDOWN] Typed "${e}" at (0, -5)`);
  673. } catch (e) {
  674. return console.error("[TCOUNTDOWN ERROR] Failed to type countdown:", e), clearInterval(d), void(this.state.countdownActive = !1);
  675. }
  676. a--;
  677. }
  678. }, 1e3));
  679. }
  680. }
  681. }
  682.  
  683. async cmdClearArea(args) {
  684. // 1. Initial State & Guard Clauses
  685. if (this.state.clearingArea) {
  686. return console.log("[CLEARAREA] Already clearing area! Please wait.");
  687. }
  688.  
  689. if (args.length !== 2 && args.length !== 4) {
  690. return console.log(`[CLEARAREA] Usage: ${this.config.prefix}cleararea x y OR x1 y1 x2 y2`);
  691. }
  692.  
  693. if (typeof w.tp !== "function" || typeof w.typeChar !== "function" || typeof getCharInfoXY !== "function") {
  694. return console.log("[CLEARAREA] Error: Required TextWall API functions (w.tp, w.typeChar, getCharInfoXY) are missing.");
  695. }
  696.  
  697. this.state.clearingArea = true;
  698.  
  699. try {
  700. let xStart, yStart, xEnd, yEnd;
  701.  
  702. // 2. Parse Coordinates
  703. if (args.length === 2) {
  704. xStart = xEnd = parseInt(args[0]);
  705. // TextWall's internal Y is often inverted relative to user-facing coordinates
  706. yStart = yEnd = -parseInt(args[1]);
  707. } else {
  708. const x1 = parseInt(args[0]);
  709. const y1 = -parseInt(args[1]);
  710. const x2 = parseInt(args[2]);
  711. const y2 = -parseInt(args[3]);
  712.  
  713. // Ensure we always loop from lower to higher values
  714. xStart = Math.min(x1, x2);
  715. xEnd = Math.max(x1, x2);
  716. yStart = Math.min(y1, y2);
  717. yEnd = Math.max(y1, y2);
  718. }
  719.  
  720. if ([xStart, yStart, xEnd, yEnd].some(isNaN)) {
  721. throw new Error("Invalid coordinates provided. Please use integers.");
  722. }
  723.  
  724. // 3. Size Validation
  725. const width = xEnd - xStart + 1;
  726. const height = yEnd - yStart + 1;
  727. const totalArea = width * height;
  728.  
  729. if (totalArea > 1000000) {
  730. throw new Error(`Area too large: ${totalArea} units (max 1,000,000)`);
  731. }
  732.  
  733. console.log(`[CLEARAREA] Clearing ${totalArea} units from (${xStart}, ${-yStart}) to (${xEnd}, ${-yEnd})...`);
  734.  
  735. // 4. Execution Loop
  736. let charsCleared = 0;
  737. for (let currY = yStart; currY <= yEnd; currY++) {
  738. for (let currX = xStart; currX <= xEnd; currX++) {
  739. // Check if bot was stopped or clearing was cancelled mid-loop
  740. if (!this.running || !this.state.clearingArea) break;
  741.  
  742. const info = getCharInfoXY(currX, currY);
  743.  
  744. // Only act if the tile isn't already empty/space
  745. if (info && info.char && info.char !== " ") {
  746. w.tp(currX, currY);
  747. w.typeChar(" ", 1);
  748. charsCleared++;
  749.  
  750. // Small delay to prevent socket flooding/rate limiting
  751. await new Promise(resolve => setTimeout(resolve, 10));
  752. }
  753. }
  754. }
  755.  
  756. console.log(`[CLEARAREA] Task complete. Cleared ${charsCleared} characters.`);
  757.  
  758. } catch (err) {
  759. console.log(`[CLEARAREA] Stopped: ${err.message}`);
  760. } finally {
  761. this.state.clearingArea = false;
  762. }
  763. }
  764.  
  765. cmdWallWarp(e) {
  766. if (2 !== e.length) this.sendMessage(`Usage: ${this.config.prefix}wallwarp wall subwall`);
  767. else if ("function" != typeof w.goto) this.sendMessage("Error: w.goto function not available");
  768. else {
  769. var s = e[0],
  770. e = e[1];
  771. try {
  772. w.goto(s, e);
  773. this.sendMessage(`Warping to ${s}/${e}...`);
  774. console.log(`[WALLWARP] Warping to ${s}/` + e);
  775. } catch (e) {
  776. this.sendMessage("Error warping to wall: " + (e.message || "Unknown error"));
  777. console.error("[WALLWARP ERROR]", e);
  778. }
  779. }
  780. }
  781.  
  782. cmdUserList() {
  783. var s = [];
  784. try {
  785. if ("undefined" != typeof w && w.cursors)
  786. for (let e = 0; e < Array.from(w.cursors).length; e++) s.push(Array.from(w.cursors)[e][1].n);
  787. else
  788. for (var e of this.state.cursors.values()) e.name && !s.includes(e.name) && s.push(e.name);
  789. } catch (e) {
  790. console.error("[USERLIST ERROR]", e);
  791. for (var t of this.state.cursors.values()) t.name && !s.includes(t.name) && s.push(t.name);
  792. }
  793. s.sort();
  794. 0 === s.length ? this.sendMessage("Online Users: None") : this.sendMessage("Online Users: " + s.join(", "));
  795. console.log("Userlist: " + s.join(", "));
  796. }
  797.  
  798. cmdTypeHelp(e) {
  799. if (this.state.isTyping) this.sendMessage("Bot is already typing. Please wait.");
  800. else {
  801. e = e[0];
  802. if (e && !isNaN(e) && Number.isInteger(Number(e))) {
  803. const i = parseInt(e);
  804. e = Object.keys(h).length;
  805. if (i < 1 || i > e) this.sendMessage(`Invalid page. Use ${this.config.prefix}thelp 1-` + e);
  806. else if ("function" != typeof w.typeChar) this.sendMessage("Error: typeChar function not available");
  807. else {
  808. e = h[i];
  809. const a = [`Commands [PAGE: ${i}]`],
  810. r = (e.forEach(e => {
  811. a.push("" + this.config.prefix + e.cmd + (e.auth ? " [A]" : "") + " - " + e.desc);
  812. }), this.state.isTyping = !0, this.config.position.x);
  813. let t = this.config.position.y,
  814. o = 0,
  815. n = 0;
  816. this.sendMessage(`Typing help page ${i} on wall...`);
  817. const l = () => {
  818. if (this.running && this.state.isTyping)
  819. if (o >= a.length) this.state.isTyping = !1, console.log("[THELP] Finished typing help page " + i);
  820. else {
  821. var e = a[o];
  822. if (n >= e.length) this.teleportCursor(r, t + 1), t++, o++, n = 0, o < a.length ? setTimeout(l, 100) : (this.state.isTyping = !1, console.log("[THELP] Finished typing help page " + i));
  823. else try {
  824. var s = e[n];
  825. w.typeChar(s, 1);
  826. n++;
  827. setTimeout(l, 30);
  828. } catch (e) {
  829. console.error("[THELP ERROR] Failed to type character:", e);
  830. this.state.isTyping = !1;
  831. }
  832. }
  833. else this.state.isTyping = !1;
  834. };
  835. this.teleportCursor(r, t);
  836. l();
  837. }
  838. } else this.sendMessage(`Usage: ${this.config.prefix}thelp [page number]`);
  839. }
  840. }
  841.  
  842. cmdFullcmd() {
  843. this.sendMessage("if you wanna see all the commands, head to ~KiwiTest/diamondbot");
  844. }
  845. cmdInfo() {
  846. this.sendMessage("This bot was made by KiwiTest, version " + this.config.version);
  847. }
  848.  
  849. cmdPage(e) {
  850. var e = parseInt(e[0]) || 1,
  851. s = Object.keys(h).length;
  852. e < 1 || s < e ? this.sendMessage("Invalid page. Pages: 1-" + s) : (this.sendMessage(`Page ${e} Detailed Info:`), h[e].forEach((e, s) => {
  853. setTimeout(() => {
  854. this.sendMessage(`${s + 1}. ${this.config.prefix}\u200B${e.cmd} - ` + e.desc);
  855. }, 700 * (s + 1));
  856. }));
  857. }
  858.  
  859. cmdSay(e, s, t) {
  860. if (e.length < 1) this.sendMessage(`Usage: ${this.config.prefix}say [message]`);
  861. else {
  862. e = e.join(" ");
  863. if (this.containsAuthorityCommand(e))
  864. if (!this.isAuthorized(s, t)) return this.sendMessage("ERR: trying to bypass authority!"), void console.log(`[SECURITY] User ${s} attempted to bypass authority with say command!`);
  865. this.sendMessage(e);
  866. }
  867. }
  868.  
  869. cmdType(e) {
  870. if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}type text step (step can be number or 'all')`);
  871. else {
  872. var t = e.slice(0, -1).join(" "),
  873. e = e[e.length - 1].toLowerCase();
  874. if (0 === t.length) this.sendMessage("Error: No text provided");
  875. else if ("function" != typeof w.typeChar) this.sendMessage("Error: typeChar function not available");
  876. else if ("all" === e) {
  877. let e = 0;
  878. for (let s = 0; s < t.length; s++) {
  879. const n = t[s];
  880. setTimeout(() => {
  881. try {
  882. w.typeChar(n, s);
  883. console.log(`[TYPE] Typed '${n}' at step ` + s);
  884. } catch (e) {
  885. console.error(`[TYPE ERROR] Failed to type '${n}' at step ${s}:`, e);
  886. }
  887. }, e);
  888. e += 50;
  889. }
  890. void this.sendMessage(`Typing "${t}" across ${t.length} steps`);
  891. } else {
  892. var s = parseInt(e);
  893. if (isNaN(s)) this.sendMessage("Error: Step must be a number or 'all'");
  894. else if (s < 0) this.sendMessage("Error: Step must be non-negative");
  895. else try {
  896. for (var o of t) w.typeChar(o, s);
  897. this.sendMessage(`Typed "${t}" at step ` + s);
  898. console.log(`[TYPE] Typed "${t}" at step ` + s);
  899. } catch (e) {
  900. this.sendMessage("Error typing text: " + (e.message || "Unknown error"));
  901. console.error("[TYPE ERROR]", e);
  902. }
  903. }
  904. }
  905. }
  906.  
  907. cmdCount(s) {
  908. if (s.length < 2) this.sendMessage(`Usage: ${this.config.prefix}count n cooldown`);
  909. else {
  910. const t = parseInt(s[0]);
  911. s = parseInt(s[1]);
  912. if (isNaN(t) || !Number.isInteger(t) || t <= 0) this.sendMessage("Error: n must be a positive integer");
  913. else if (isNaN(s) || !Number.isInteger(s) || s < 100) this.sendMessage("Error: cooldown must be an integer >= 100 (milliseconds)");
  914. else if (100 < t) this.sendMessage("Error: n cannot exceed 100");
  915. else {
  916. const o = Date.now();
  917. let e = 1;
  918. this.sendMessage(`Starting count to ${t} with ${s}ms delay...`);
  919. const n = setInterval(() => {
  920. e > t || !this.running ? (clearInterval(n), this.state.activeCounts.delete(o), e > t && this.sendMessage("Count complete!")) : (this.sendMessage(e.toString()), e++);
  921. }, s);
  922. this.state.activeCounts.set(o, {
  923. intervalId: n,
  924. max: t
  925. });
  926. }
  927. }
  928. }
  929.  
  930. cmdColoredSay(s) {
  931. if (s.length < 2) this.sendMessage(`Usage: ${this.config.prefix}csay [colorid] [text]`);
  932. else {
  933. var t = s[0].toLowerCase();
  934. let e;
  935. if (isNaN(t)) {
  936. if (!t.startsWith("#")) return void this.sendMessage("Invalid colorid");
  937. if (void 0 === (e = r[t])) return void this.sendMessage("Invalid colorid");
  938. } else if ((e = parseInt(t)) < 0 || 15 < e) return void this.sendMessage("Invalid colorid");
  939. const o = s.slice(1).join(" ");
  940. if (o && 0 !== o.trim().length) {
  941. const n = this.config.color;
  942. this.setColor(e);
  943. setTimeout(() => {
  944. this.sendMessage(o);
  945. setTimeout(() => {
  946. this.setColor(n);
  947. }, 100);
  948. }, 100);
  949. } else this.sendMessage("Invalid text characters");
  950. }
  951. }
  952.  
  953. cmdCalculate(e) {
  954. if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}calculate base exponent`);
  955. else try {
  956. var s = e[0],
  957. t = e[1],
  958. o = window.Decimal.pow(new window.Decimal(s), new window.Decimal(t));
  959. this.sendMessage(s + `^${t} = ` + o.toString());
  960. } catch (e) {
  961. this.sendMessage("Error: Invalid input for calculation");
  962. }
  963. }
  964.  
  965. cmdTetration(e) {
  966. if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}calc2 base height`);
  967. else try {
  968. var s, t = e[0],
  969. o = parseInt(e[1]);
  970. o < 0 || !Number.isInteger(o) ? this.sendMessage("Height must be a non-negative integer") : this.config.heightSafetyEnabled && 5 < o ? this.sendMessage("Height too large! Maximum is 5 (Height Safety ON)") : (s = window.Decimal.tetrate(new window.Decimal(t), o), this.sendMessage(t + `^^${o} = ` + s.toString()));
  971. } catch (e) {
  972. this.sendMessage("Error: Invalid input for tetration");
  973. }
  974. }
  975.  
  976. cmdRandom(e) {
  977. var s, t;
  978. e.length < 2 ? this.sendMessage(`Usage: ${this.config.prefix}rng min max`) : (s = parseFloat(e[0]), e = parseFloat(e[1]), isNaN(s) || isNaN(e) ? this.sendMessage("Invalid input. Please provide valid numbers.") : e < s ? this.sendMessage("Min must be less than or equal to max.") : (t = Math.random() * (e - s) + s, this.sendMessage(`Random number between ${s} and ${e}: ` + t.toFixed(2))));
  979. }
  980.  
  981. cmdTimer(s) {
  982. if (s.length < 3) this.sendMessage(`Usage: ${this.config.prefix}timer hours minutes seconds (use 0 to skip)`);
  983. else {
  984. var t = Math.max(0, parseInt(s[0]) || 0),
  985. o = Math.max(0, parseInt(s[1]) || 0),
  986. s = Math.max(0, parseInt(s[2]) || 0);
  987. if (0 === t && 0 === o && 0 === s) this.sendMessage("Timer must have at least one non-zero value");
  988. else if (24 < t) this.sendMessage("Maximum timer is 24 hours");
  989. else {
  990. var i = 1e3 * (3600 * t + 60 * o + s);
  991. let e = [];
  992. 0 < t && e.push(t + "h"), 0 < o && e.push(o + "m"), 0 < s && e.push(s + "s");
  993. const a = Date.now();
  994. this.sendMessage(`Timer set for ${e.join(" ")} (ID: ${a})`);
  995. t = setTimeout(() => {
  996. this.sendMessage(`TIMER COMPLETE! ${e.join(" ")} has elapsed (ID: ${a})`);
  997. this.state.activeTimers.delete(a);
  998. }, i);
  999. if (this.state.activeTimers.set(a, {
  1000. timeout: t,
  1001. duration: e.join(" "),
  1002. startTime: Date.now(),
  1003. endTime: Date.now() + i
  1004. }), 6e4 < i) {
  1005. let n = 0;
  1006. o = Math.max(3e4, i / 4);
  1007. const r = setInterval(() => {
  1008. var e, s, t, o = this.state.activeTimers.get(a);
  1009. !o || 3 <= n ? clearInterval(r) : 1e3 < (o = o.endTime - Date.now()) && (e = Math.floor(o / 36e5), s = Math.floor(o % 36e5 / 6e4), o = Math.floor(o % 6e4 / 1e3), t = [], 0 < e && t.push(e + "h"), 0 < s && t.push(s + "m"), 0 < o && t.push(o + "s"), this.sendMessage(`Timer ${a}: ${t.join(" ")} remaining`), n++);
  1010. }, o);
  1011. this.state.activeTimers.get(a).intervalId = r;
  1012. }
  1013. }
  1014. }
  1015. }
  1016.  
  1017. cmdStatus() {
  1018. var e = [
  1019. `Wall: ${this.state.wall}/` + this.state.subwall,
  1020. "Perms: " + ["User", "Member", "Owner"][this.state.perms],
  1021. `Pos: (${this.config.position.x}, ${this.config.position.y})`,
  1022. "Timers: " + this.state.activeTimers.size,
  1023. "Color: " + this.config.color,
  1024. "HS: " + (this.config.heightSafetyEnabled ? "ON" : "OFF"),
  1025. "Echo: " + (this.config.authorityEchoEnabled ? "ON" : "OFF"),
  1026. "EchoColor: " + (this.config.echoColorEnabled ? "ON" : "OFF"),
  1027. "Auth: " + this.config.authorizedUsers.length,
  1028. `Banned: ${this.config.bannedUsers.length}/` + this.config.bannedIds.length
  1029. ];
  1030. this.sendMessage(e.join(" | "));
  1031. }
  1032.  
  1033. cmdPosition(e, s) {
  1034. if (0 === e.length) {
  1035. const t = this.getCursorPosition(s);
  1036. void(t ? this.sendMessage(`Cursor position of ${s}: (${t[0]}, ${t[1]})`) : this.sendMessage(`Cursor position of ${s}: Not found in wall`));
  1037. } else {
  1038. s = e[0];
  1039. const t = this.getCursorPosition(s);
  1040. t ? this.sendMessage(`Cursor position of ${s}: (${t[0]}, ${t[1]})`) : this.sendMessage(`Cursor position of ${s}: Not found in wall`);
  1041. }
  1042. }
  1043.  
  1044. cmdMembers() {
  1045. 0 === this.state.members.length ? this.sendMessage("No members in this wall") : this.sendMessage("Members: " + this.state.members.join(", "));
  1046. }
  1047.  
  1048. cmdWalls() {
  1049. if (0 === this.state.walllist.length) this.sendMessage("No subwalls available");
  1050. else {
  1051. var s = [];
  1052. for (let e = 0; e < this.state.walllist.length; e += 2) {
  1053. var t = this.state.walllist[e],
  1054. o = this.state.walllist[e + 1];
  1055. s.push(t + (o ? " (private)" : ""));
  1056. }
  1057. this.sendMessage("Subwalls: " + s.join(", "));
  1058. }
  1059. }
  1060.  
  1061. cmdTeleport(e) {
  1062. var s;
  1063. e.length < 2 ? this.sendMessage(`Usage: ${this.config.prefix}to X Y`) : (s = parseInt(e[0]), e = parseInt(e[1]), isNaN(s) || isNaN(e) ? this.sendMessage("Invalid coordinates. Please provide integers.") : 1e4 < Math.abs(s) || 1e4 < Math.abs(e) ? this.sendMessage("Coordinates out of range (max +-10000)") : (this.teleportCursor(s, e), this.sendMessage(`Teleported to (${s}, ${e})`)));
  1064. }
  1065.  
  1066. cmdTp(e) {
  1067. if (e.length < 2) this.sendMessage(`Usage: ${this.config.prefix}tp X Y`);
  1068. else {
  1069. var s = parseInt(e[0]),
  1070. e = parseInt(e[1]);
  1071. if (isNaN(s) || isNaN(e)) this.sendMessage("Invalid coordinates. Please provide integers.");
  1072. else if (1e4 < Math.abs(s) || 1e4 < Math.abs(e)) this.sendMessage("Coordinates out of range (max +-10000)");
  1073. else if ("function" != typeof w.tp) this.sendMessage("Error: w.tp function not available");
  1074. else try {
  1075. w.tp(s, e);
  1076. this.config.position.x = s;
  1077. this.config.position.y = e;
  1078. this.sendMessage(`Teleported to (${s}, ${e}) using w.tp`);
  1079. console.log(`[TP] Teleported to (${s}, ${e}) using w.tp`);
  1080. } catch (e) {
  1081. this.sendMessage("Error using w.tp: " + (e.message || "Unknown error"));
  1082. console.error("[TP ERROR]", e);
  1083. }
  1084. }
  1085. }
  1086.  
  1087. cmdColor(s) {
  1088. if (s.length < 1) this.sendMessage(`Usage: ${this.config.prefix}colorid #hex or 0-15`);
  1089. else {
  1090. s = s[0].toLowerCase();
  1091. let e;
  1092. if (isNaN(s)) {
  1093. if (!s.startsWith("#")) return void this.sendMessage("Invalid colot");
  1094. if (void 0 === (e = r[s])) return void this.sendMessage("Invalid colot");
  1095. } else if ((e = parseInt(s)) < 0 || 15 < e) return void this.sendMessage("Invalid colot");
  1096. this.setColor(e);
  1097. this.sendMessage("Color changed to " + e);
  1098. }
  1099. }
  1100.  
  1101. cmdBan(e) {
  1102. e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}ban username`) : this.config.authorizedUsers.includes(e = e[0]) ? this.sendMessage("Cannot ban authority user " + e) : this.config.bannedUsers.includes(e) ? this.sendMessage(e + " is already banned") : (this.config.bannedUsers.push(e), o.save("bannedUsers", this.config.bannedUsers), this.sendMessage(`Banned ${e} from using bot`), console.log(`[BAN] ${e} has been banned`));
  1103. }
  1104.  
  1105. cmdUnban(e) {
  1106. var s, t;
  1107. e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}unban username or ID`) : (e = e[0], isNaN(e) ? -1 === (s = this.config.bannedUsers.indexOf(t = e)) ? this.sendMessage(`Error: ${t} is not banned`) : (this.config.bannedUsers.splice(s, 1), o.save("bannedUsers", this.config.bannedUsers), this.sendMessage("Unbanned " + t), console.log(`[UNBAN] ${t} has been unbanned`)) : -1 === (t = this.config.bannedIds.indexOf(s = e)) ? this.sendMessage(`Error: ID ${s} is not banned`) : (this.config.bannedIds.splice(t, 1), o.save("bannedIds", this.config.bannedIds), this.sendMessage("Unbanned ID " + s), console.log(`[UNBAN] ID ${s} has been unbanned`)));
  1108. }
  1109.  
  1110. cmdBanId(e) {
  1111. var s;
  1112. e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}banid username`) : (s = this.getUserId(e = e[0])) ? this.config.authorizedUsers.includes(e) ? this.sendMessage("Cannot ban authority user " + e) : this.config.bannedIds.includes(s) ? this.sendMessage(`User ID ${s} is already banned`) : (this.config.bannedIds.push(s), o.save("bannedIds", this.config.bannedIds), this.sendMessage(`Banned user ID for ${e} (ID: ${s})`), console.log(`[BANID] ${e} (ID: ${s}) has been banned`)) : this.sendMessage(`Cannot find user ID for ${e}. User must be in wall.`);
  1113. }
  1114.  
  1115. cmdUnbanId(e) {
  1116. var s;
  1117. e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}unbanid userid`) : -1 === (s = this.config.bannedIds.indexOf(e = e[0])) ? this.sendMessage(`ID ${e} is not banned`) : (this.config.bannedIds.splice(s, 1), o.save("bannedIds", this.config.bannedIds), this.sendMessage("Unbanned ID " + e), console.log(`[UNBANID] ID ${e} has been unbanned`));
  1118. }
  1119.  
  1120. cmdBanList() {
  1121. var e = 0 === this.config.bannedUsers.length ? "None" : this.config.bannedUsers.join(", "),
  1122. s = 0 === this.config.bannedIds.length ? "None" : this.config.bannedIds.length + " IDs";
  1123. this.sendMessage(`Banned users: ${e} | Banned IDs: ` + s);
  1124. }
  1125.  
  1126. cmdAddAuth(e) {
  1127. var s;
  1128. e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}addauth username`) : this.config.authorizedUsers.includes(e = e[0]) ? this.sendMessage(e + " already has authority") : (-1 !== (s = this.config.bannedUsers.indexOf(e)) && (this.config.bannedUsers.splice(s, 1), o.save("bannedUsers", this.config.bannedUsers)), this.config.authorizedUsers.push(e), o.save("authorizedUsers", this.config.authorizedUsers), this.sendMessage(`Added ${e} to authority list`), console.log("[AUTH+] Authority granted to: " + e));
  1129. }
  1130.  
  1131. cmdRemoveAuth(e) {
  1132. var s;
  1133. e.length < 1 ? this.sendMessage(`Usage: ${this.config.prefix}removeauth username`) : this.config.defaultAuthorities.includes(e = e[0]) ? this.sendMessage("Cannot remove default authority from " + e) : -1 === (s = this.config.authorizedUsers.indexOf(e)) ? this.sendMessage(e + " doesn't have authority") : (this.config.authorizedUsers.splice(s, 1), o.save("authorizedUsers", this.config.authorizedUsers), this.sendMessage(`Removed ${e} from authority list`), console.log("[AUTH-] Authority revoked from: " + e));
  1134. }
  1135.  
  1136. cmdDisableHeightSafety() {
  1137. this.config.heightSafetyEnabled = !this.config.heightSafetyEnabled;
  1138. var e = this.config.heightSafetyEnabled ? "ENABLED" : "DISABLED",
  1139. s = this.config.heightSafetyEnabled ? "(Max height: 5)" : "(No height limit)";
  1140. this.sendMessage(`Height safety is now ${e} ` + s);
  1141. console.log("Height safety: " + e);
  1142. }
  1143.  
  1144. cmdToggleEcho() {
  1145. this.config.authorityEchoEnabled ? (this.config.authorityEchoEnabled = !1, this.sendMessage("Authority echo is now DISABLED")) : (this.config.authorityEchoEnabled = !0, this.sendMessage("Authority echo is now ENABLED (with recursion protection)"));
  1146. console.log("Authority echo: " + (this.config.authorityEchoEnabled ? "ENABLED" : "DISABLED"));
  1147. }
  1148.  
  1149. cmdToggleEchoColor() {
  1150. this.config.echoColorEnabled ? (this.config.echoColorEnabled = !1, this.sendMessage("Color echo is now DISABLED")) : (this.config.echoColorEnabled = !0, this.sendMessage("Color echo is now ENABLED (echoes authority messages with color syntax)"));
  1151. console.log("Color echo: " + (this.config.echoColorEnabled ? "ENABLED" : "DISABLED"));
  1152. }
  1153.  
  1154. cmdAuthList() {
  1155. var e = [...this.config.authorizedUsers],
  1156. s = Array.from(this.state.adminUsers),
  1157. e = [...new Set([...e, ...s])];
  1158. this.sendMessage(`Authorized users (${e.length}): ` + e.join(", "));
  1159. }
  1160.  
  1161. setUsername(e) {
  1162. "undefined" != typeof api && api.nick ? api.nick(e) : "function" == typeof setNick ? setNick(e) : "function" == typeof changeNick && changeNick(e);
  1163. console.log("[USERNAME] " + e);
  1164. }
  1165.  
  1166. setColor(e) {
  1167. "undefined" != typeof api && api.color ? api.color(e) : "function" == typeof setColor && setColor(e);
  1168. this.config.color = e;
  1169. console.log("[COLOR] Set to: " + e);
  1170. }
  1171.  
  1172. teleportCursor(e, s) {
  1173. "undefined" != typeof api && api.cursor ? api.cursor(e, s) : "function" == typeof moveCursor ? moveCursor(e, s) : "object" == typeof cursor && cursor.move && cursor.move(e, s);
  1174. this.config.position.x = e;
  1175. this.config.position.y = s;
  1176. }
  1177.  
  1178. sendMessage(e) {
  1179. if (this.state.disablechat && !this.state.isShuttingDown) console.log("Chat is disabled, cannot send message");
  1180. else {
  1181. const o = this.parseColoredMessage(e);
  1182. if (1 < o.length || 1 === o.length && null !== o[0].color) {
  1183. const n = this.config.color;
  1184. let t = 0;
  1185. void o.forEach((e, s) => {
  1186. setTimeout(() => {
  1187. null !== e.color ? this.setColor(e.color) : 0 < s && this.setColor(n);
  1188. setTimeout(() => {
  1189. this.state.messageQueue.push(e.text);
  1190. this.state.isProcessingQueue || this.processMessageQueue();
  1191. s === o.length - 1 && setTimeout(() => {
  1192. this.setColor(n);
  1193. }, 100);
  1194. }, 50);
  1195. }, t);
  1196. t += 200;
  1197. });
  1198. } else {
  1199. this.state.messageQueue.push(e);
  1200. this.state.isProcessingQueue || this.processMessageQueue();
  1201. }
  1202. }
  1203. }
  1204.  
  1205. async processMessageQueue() {
  1206. if (0 === this.state.messageQueue.length || !this.running && !this.state.isShuttingDown) this.state.isProcessingQueue = !1;
  1207. else {
  1208. this.state.isProcessingQueue = !0;
  1209. var e = this.state.messageQueue.shift();
  1210. const s = Date.now() - this.state.lastMessageTime;
  1211. s < this.config.messageDelay && await new Promise(e => setTimeout(e, this.config.messageDelay - s));
  1212. this.state.lastMessageTime = Date.now();
  1213. try {
  1214. w && w.chat && w.chat.send ? (w.chat.send(e), console.log("[SENT] " + e)) : "function" == typeof sendChat ? sendChat(e) : "undefined" != typeof api && api.chat ? api.chat(e) : console.error("No chat send method available!");
  1215. } catch (e) {
  1216. console.error("Failed to send message:", e);
  1217. }
  1218. setTimeout(() => this.processMessageQueue(), this.config.messageDelay);
  1219. }
  1220. }
  1221. }
  1222.  
  1223. console.clear();
  1224. console.log(`Starting TextWall Bot v${a.version}...`);
  1225. const l = new t(a);
  1226.  
  1227. async function e() {
  1228. if (void 0 !== window.Decimal) console.log("[OK] Break Eternity already loaded");
  1229. else {
  1230. var s;
  1231. for (s of ["https://cdn.jsdelivr.net/npm/break_eternity.js@latest/break_eternity.min.js", "https://unpkg.com/break_eternity.js@latest/dist/break_eternity.min.js", "https://cdnjs.cloudflare.com/ajax/libs/break_eternity.js/1.3.0/break_eternity.min.js"]) try {
  1232. if (await
  1233. function(o) {
  1234. return new Promise((e, s) => {
  1235. var t = document.createElement("script");
  1236. t.src = o;
  1237. t.onload = e;
  1238. t.onerror = s;
  1239. document.head.appendChild(t);
  1240. });
  1241. }(s), void 0 !== window.Decimal) return console.log("[OK] Break Eternity loaded from: " + s), !0;
  1242. } catch (e) {
  1243. console.warn("Failed to load from " + s);
  1244. }
  1245. window.Decimal = class i {
  1246. constructor(e) {
  1247. this.value = "string" == typeof e || "number" == typeof e ? parseFloat(e) || 0 : e?.value || 0;
  1248. }
  1249. static pow(e, s) {
  1250. e = e instanceof i ? e.value : parseFloat(e);
  1251. s = s instanceof i ? s.value : parseFloat(s);
  1252. if (0 === s) return new i(1);
  1253. if (0 === e) return new i(0);
  1254. let t;
  1255. return t = 308 < Math.abs(s) ? 0 < s ? 1 / 0 : 0 : Math.pow(e, s), new i(t);
  1256. }
  1257. static tetrate(e, s) {
  1258. var t = e instanceof i ? e.value : parseFloat(e),
  1259. o = parseInt(s);
  1260. if (0 === o) return new i(1);
  1261. if (1 === o) return new i(t);
  1262. if (0 === t) return new i(0);
  1263. if (!a.heightSafetyEnabled) {
  1264. let s = t;
  1265. for (let e = 1; e < o && (s = Math.pow(t, s), isFinite(s)); e++);
  1266. return new i(s);
  1267. }
  1268. let n = t;
  1269. for (let e = 1; e < o && e < 5 && (n = Math.pow(t, n), isFinite(n)); e++);
  1270. return new i(n);
  1271. }
  1272. toString() {
  1273. return isFinite(this.value) ? Math.abs(this.value) < 1e-6 ? "0" : Math.abs(this.value) < 1e6 && .001 < Math.abs(this.value) ? this.value.toString() : this.value.toExponential(2) : 0 < this.value ? "Infinity" : "-Infinity";
  1274. }
  1275. };
  1276. console.log("[OK] Using fallback Decimal implementation");
  1277. }
  1278. return !0;
  1279. }
  1280.  
  1281. await l.init();
  1282.  
  1283. window.diamondBot = l;
  1284.  
  1285. window.sendMessage = function(e) {
  1286. e ? (l.sendMessage("[SYSTEM]: " + e), console.log("[SYSTEM MESSAGE SENT]: " + e)) : console.error("Error: No message provided. Usage: sendMessage('your message')");
  1287. };
  1288.  
  1289. window.unbanName = function(e) {
  1290. var s;
  1291. e ? -1 === (s = l.config.bannedUsers.indexOf(e)) ? console.error(`Error: ${e} is not in the ban list`) : (l.config.bannedUsers.splice(s, 1), o.save("bannedUsers", l.config.bannedUsers), console.log(`[CONSOLE UNBAN] ${e} has been unbanned from the ban list`), console.log("Current banned users: " + (0 < l.config.bannedUsers.length ? l.config.bannedUsers.join(", ") : "None"))) : console.error("Error: No username provided. Usage: unbanName('username')");
  1292. };
  1293.  
  1294. window.addDefaultAuth = function(e) {
  1295. if (!e) return void console.error("Error: No username provided. Usage: addDefaultAuth('username')");
  1296. if (l.config.defaultAuthorities.includes(e)) return void console.error(`Error: ${e} is already a default authority`);
  1297. l.config.defaultAuthorities.push(e);
  1298. o.save("defaultAuthorities", l.config.defaultAuthorities);
  1299. if (!l.config.authorizedUsers.includes(e)) {
  1300. l.config.authorizedUsers.push(e);
  1301. o.save("authorizedUsers", l.config.authorizedUsers);
  1302. }
  1303. var s = l.config.bannedUsers.indexOf(e); -
  1304. 1 !== s && (l.config.bannedUsers.splice(s, 1), o.save("bannedUsers", l.config.bannedUsers));
  1305. console.log(`[DEFAULT AUTH+] ${e} has been added as a default authority`);
  1306. console.log("Default authorities: " + l.config.defaultAuthorities.join(", "));
  1307. console.log("Authorized users: " + l.config.authorizedUsers.join(", "));
  1308. };
  1309.  
  1310. window.addAuth = function(e) {
  1311. if (!e) return void console.error("Error: No username provided. Usage: addAuth('username')");
  1312. if (l.config.authorizedUsers.includes(e)) return void console.error(`Error: ${e} already has authority`);
  1313. l.config.authorizedUsers.push(e);
  1314. o.save("authorizedUsers", l.config.authorizedUsers);
  1315. var s = l.config.bannedUsers.indexOf(e); -
  1316. 1 !== s && (l.config.bannedUsers.splice(s, 1), o.save("bannedUsers", l.config.bannedUsers));
  1317. console.log(`[AUTH+] ${e} has been added to the authority list`);
  1318. console.log("Authorized users: " + l.config.authorizedUsers.join(", "));
  1319. };
  1320.  
  1321. window.stopBot = async function() {
  1322. console.log("Initiating shutdown sequence...");
  1323. l.state.isShuttingDown = !0;
  1324. l.state.isTyping = !1;
  1325. l.state.countdownActive = !1;
  1326. l.state.clearingArea = !1;
  1327. l.sendMessage("Closing bot..");
  1328. await new Promise(e => setTimeout(e, 500));
  1329. l.running = !1;
  1330. l.state.activeTimers.forEach(e => {
  1331. clearTimeout(e.timeout);
  1332. e.intervalId && clearInterval(e.intervalId);
  1333. });
  1334. l.state.activeCounts.forEach(e => {
  1335. e.intervalId && clearInterval(e.intervalId);
  1336. });
  1337. for (var [e, s] of Object.entries(l.eventHandlers)) w && w.off && w.off(e, s);
  1338. l.sendMessage("Bot successfully shutdown.");
  1339. await new Promise(e => setTimeout(e, 500));
  1340. l.state.isProcessingQueue = !1;
  1341. l.state.messageQueue = [];
  1342. console.log("[OK] Bot stopped completely");
  1343. };
  1344.  
  1345. window.restartBot = async function() {
  1346. console.log("Restarting bot...");
  1347. await window.stopBot();
  1348. await new Promise(e => setTimeout(e, 1e3));
  1349. var e = new t(a);
  1350. await e.init();
  1351. window.diamondBot = e;
  1352. console.log("[OK] Bot restarted");
  1353. };
  1354.  
  1355. window.botStatus = function() {
  1356. console.table({
  1357. Username: l.config.username,
  1358. Version: l.config.version,
  1359. Prefix: l.config.prefix,
  1360. Wall: l.state.wall + "/" + l.state.subwall,
  1361. Position: `(${l.config.position.x}, ${l.config.position.y})`,
  1362. Color: l.config.color,
  1363. Permissions: ["User", "Member", "Owner"][l.state.perms] || "Unknown",
  1364. "Active Timers": l.state.activeTimers.size,
  1365. "Active Counts": l.state.activeCounts.size,
  1366. "Countdown Active": l.state.countdownActive ? "YES" : "NO",
  1367. "Clearing Area": l.state.clearingArea ? "YES" : "NO",
  1368. "Authorized Users": l.config.authorizedUsers.length,
  1369. "Default Authorities": l.config.defaultAuthorities.length,
  1370. "Banned Users": l.config.bannedUsers.length,
  1371. "Banned IDs": l.config.bannedIds.length,
  1372. "Height Safety": l.config.heightSafetyEnabled ? "ON" : "OFF",
  1373. "Authority Echo": l.config.authorityEchoEnabled ? "ON" : "OFF",
  1374. "Color Echo": l.config.echoColorEnabled ? "ON" : "OFF",
  1375. "Is Typing": l.state.isTyping ? "YES" : "NO",
  1376. "Queue Size": l.state.messageQueue.length
  1377. });
  1378. };
  1379.  
  1380. window.showCommands = function() {
  1381. for (var e in console.log("\n===================================="), console.log(` ALL BOT COMMANDS (v${a.version}) `), console.log("====================================\n"), h)
  1382. console.log(`\nPAGE ${e}:`), console.log("-".repeat(50)), h[e].forEach(e => {
  1383. var s = e.auth ? "[A]" : " ",
  1384. t = ("\\" + e.cmd).padEnd(15);
  1385. console.log(s + ` ${t} - ` + e.desc);
  1386. });
  1387. console.log("\n" + "=".repeat(50));
  1388. console.log("[A] = Authority Required");
  1389. console.log("Default Authorities: " + l.config.defaultAuthorities.join(", "));
  1390. console.log("Admins (ADMIN tag) have automatic authority");
  1391. console.log("\nCONSOLE COMMANDS:");
  1392. console.log(" addDefaultAuth('username') - Add default authority");
  1393. console.log(" addAuth('username') - Add authority");
  1394. console.log(" unbanName('username') - Unban user from ban list");
  1395. console.log("=".repeat(50) + "\n");
  1396. };
  1397.  
  1398. window.showColors = function() {
  1399. console.log("\n====================================");
  1400. console.log(" COLOR SYNTAX GUIDE (v7.14.4) ");
  1401. console.log("====================================\n");
  1402. console.log("Use: <start #HEXCOLOR>text<end>");
  1403. console.log("Example: <start #ff0000>Hello<end> World\n");
  1404. console.log("Available colors (HEX only):");
  1405. console.log("-".repeat(50));
  1406. console.log(" 0 - #000000 (black)");
  1407. console.log(" 1 - #ffffff (white)");
  1408. console.log(" 2 - #ff0000 (red)");
  1409. console.log(" 3 - #00ff00 (green)");
  1410. console.log(" 4 - #0000ff (blue)");
  1411. console.log(" 5 - #ffff00 (yellow)");
  1412. console.log(" 6 - #ff00ff (magenta)");
  1413. console.log(" 7 - #00ffff (cyan)");
  1414. console.log(" 8 - #808080 (gray)");
  1415. console.log(" 9 - #ff8800 (orange)");
  1416. console.log(" 10 - #8800ff (purple)");
  1417. console.log(" 11 - #0088ff (light blue)");
  1418. console.log(" 12 - #88ff00 (lime)");
  1419. console.log(" 13 - #ff0088 (pink)");
  1420. console.log(" 14 - #884400 (brown)");
  1421. console.log(" 15 - #448800 (dark green)");
  1422. console.log("=".repeat(50) + "\n");
  1423. };
  1424.  
  1425. window.botHelp = function() {
  1426. console.log("====================================");
  1427. console.log(` TextWall Bot v${a.version} - Help `);
  1428. console.log("====================================");
  1429. console.log(" PREFIX: \\ ");
  1430. console.log(" ");
  1431. console.log(" NEW IN v7.14.2: ");
  1432. console.log(" - \\cleararea outputs all messages");
  1433. console.log(" to console. ");
  1434. console.log(" ");
  1435. console.log(" CONSOLE COMMANDS: ");
  1436. console.log(" window.showCommands() - List cmds ");
  1437. console.log(" window.showColors() - Color list");
  1438. console.log(" window.sendMessage(msg) - System ");
  1439. console.log(" window.addDefaultAuth(n) - DefAuth");
  1440. console.log(" window.addAuth(name) - Add auth ");
  1441. console.log(" window.unbanName(name) - Unban ");
  1442. console.log(" window.stopBot() - Stop bot ");
  1443. console.log(" window.restartBot() - Restart ");
  1444. console.log(" window.botStatus() - Status ");
  1445. console.log(" window.botHelp() - This help ");
  1446. console.log("====================================");
  1447. };
  1448.  
  1449. window.botHelp();
  1450. }
  1451. }();
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment