Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Functionality remains the same but with minor improvements and a crucial 'break' fix.
- w.on("join", (data) => {
- // Send a welcome message to the channel upon joining
- w.chat.send("DominoBot Version 0.2 - Type --help for commands");
- });
- w.on("msg", (data) => {
- // data object likely contains properties like 'msg' (message content) and 'nick' (sender nickname)
- // Filter: Ignore messages that don't start with the command prefix "--"
- if (!data.msg.startsWith("--")) {
- return; // Exit the function early if it's not a command
- }
- // Extract the command name: remove leading "--" and trim whitespace
- const command = data.msg.slice(2).trim();
- // Handle specific commands using a switch statement
- switch (command) {
- case "test":
- // Respond to the "test" command with a specific message
- w.chat.send(`${data.nick}, *Thanks for testing*`);
- // CRITICAL FIX: Add 'break' to prevent execution of the 'default' case
- break;
- // You can add more cases here for other commands:
- // case "help":
- // w.chat.send("Available commands: --test");
- // break;
- default:
- // Default case handles any command starting with "--" that wasn't matched above
- // It currently does nothing, which is fine, but you could add a "command not found" message here
- break;
- }
- });
Advertisement
Comments
-
- 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