smoothretro82

basic bot template for tw.2s4.me

Nov 11th, 2025
40
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. // Functionality remains the same but with minor improvements and a crucial 'break' fix.
  2.  
  3. w.on("join", (data) => {
  4. // Send a welcome message to the channel upon joining
  5. w.chat.send("DominoBot Version 0.2 - Type --help for commands");
  6. });
  7.  
  8.  
  9. w.on("msg", (data) => {
  10. // data object likely contains properties like 'msg' (message content) and 'nick' (sender nickname)
  11.  
  12. // Filter: Ignore messages that don't start with the command prefix "--"
  13. if (!data.msg.startsWith("--")) {
  14. return; // Exit the function early if it's not a command
  15. }
  16.  
  17. // Extract the command name: remove leading "--" and trim whitespace
  18. const command = data.msg.slice(2).trim();
  19.  
  20. // Handle specific commands using a switch statement
  21. switch (command) {
  22. case "test":
  23. // Respond to the "test" command with a specific message
  24. w.chat.send(`${data.nick}, *Thanks for testing*`);
  25. // CRITICAL FIX: Add 'break' to prevent execution of the 'default' case
  26. break;
  27.  
  28. // You can add more cases here for other commands:
  29. // case "help":
  30. // w.chat.send("Available commands: --test");
  31. // break;
  32.  
  33. default:
  34. // Default case handles any command starting with "--" that wasn't matched above
  35. // It currently does nothing, which is fine, but you could add a "command not found" message here
  36. break;
  37. }
  38. });
  39.  
Advertisement
Comments
  • smoothretro82
    262 days
    # text 0.11 KB | 0 0
    1. Use this bot script as a example to make your own bot from, Originally made by AdjectiveNounNumber, modified by DG_
Add Comment
Please, Sign In to add comment