Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const prefix = "gr!";
- const botname = "GensokyoRadioBOT (" + prefix + "help)";
- const version = "1.0";
- var help = "- __GensokyoRadioBOT Commands__\ngr!help, gr!genradio1, gr!genradio2, gr!genradio3, gr!radioskyrock gr!radiomaritima, gr!radioBBN, gr!snake"
- var botinfo = "GensokyoRadioBOT " + version + ". Find GensokyoRadioBOT at: https://pastebin.com/unfdr1YZ";
- function sendMsg(msg) {
- setTimeout(() => {
- socket.emit("talk", msg);
- }, 1100);
- }
- setTimeout(() => { socket.emit("command", { command: "name", param: botname }) }, 1000);
- setTimeout(() => { socket.emit("command", { command: "name", param: botname }) }, 2100);
- setTimeout(() => { socket.emit("command", { command: "color", param: "https://cdn.discordapp.com/attachments/1177634999873314878/1198925870404997150/i-tools.png" }) }, 3200);
- setTimeout(() => {
- sendMsg("GensokyoRadioBOT is online. Type " + prefix + "help To See Commands.");
- }, 4300);
- socket.on("talk", (message) => {
- if (message.text == prefix + "botinfo") {
- sendMsg(botinfo);
- }
- if (message.text == prefix + "help") {
- sendMsg(help);
- }
- // Handling specific radio commands
- if (message.text.startsWith(prefix + "genradio3")) {
- const imgUrl = message.text.substring(prefix.length + 10);
- setTimeout(() => { socket.emit("command", { command: "video", param: "https://stream.gensokyoradio.net/3" }) }, 1100);
- }
- if (message.text.startsWith(prefix + "genradio2")) {
- const imgUrl = message.text.substring(prefix.length + 10);
- setTimeout(() => { socket.emit("command", { command: "video", param: "https://stream.gensokyoradio.net/2" }) }, 1100);
- }
- if (message.text.startsWith(prefix + "genradio1")) {
- const imgUrl = message.text.substring(prefix.length + 10);
- setTimeout(() => { socket.emit("command", { command: "video", param: "https://stream.gensokyoradio.net/1" }) }, 1100);
- }
- if (message.text.startsWith(prefix + "radioskyrock")) {
- const imgUrl = message.text.substring(prefix.length + 12);
- setTimeout(() => { socket.emit("command", { command: "video", param: "https://icecast.skyrock.net/s/marseille_aac_96k" }) }, 1100);
- }
- if (message.text.startsWith(prefix + "radiomaritima")) {
- const imgUrl = message.text.substring(prefix.length + 14);
- setTimeout(() => { socket.emit("command", { command: "video", param: "https://maritima1072.ice.infomaniak.ch/maritima1072-128.mp3" }) }, 1100);
- }
- if (message.text.startsWith(prefix + "radioBBN")) {
- const imgUrl = message.text.substring(prefix.length + 9);
- setTimeout(() => { socket.emit("command", { command: "video", param: "https://audio-edge-ey5nr.ams.s.radiomast.io/a622d414-52a6-4426-b3b8-ed2a4dbb704b" }) }, 1100);
- }
- if (message.text.startsWith(prefix + "snake")) {
- const command = message.text.substring(prefix.length + 6).trim();
- handleSnakeCommand(command);
- }
- });
- function getCurrentTime() {
- const now = new Date();
- const timeString = now.toLocaleTimeString("en-US", { hour12: true });
- return "Current time is: " + timeString;
- }
- function handleSnakeCommand(command) {
- if (command === "play") {
- startSnakeGame();
- } else if (command === "up" || command === "down" || command === "left" || command === "right") {
- updateSnakeDirection(command);
- moveSnake();
- if (checkCollision()) {
- sendMsg("Game Over. You collided with the wall or yourself!");
- return;
- }
- checkFoodEaten();
- sendMsg(renderSnakeGame());
- } else {
- sendMsg("Invalid command. Use `" + prefix + "snake play` to start the game and `" + prefix + "snake up/down/left/right` to control.");
- }
- }
- // New snake game functions...
- let snake = [{ x: 0, y: 0 }]; // Snake's initial position (assuming the top-left corner as [0, 0])
- let food = { x: 5, y: 5 }; // Food's initial position
- let direction = "right"; // Initial direction of the snake
- function startSnakeGame() {
- // Initialize the snake game state
- snake = [{ x: 0, y: 0 }];
- food = { x: 5, y: 5 };
- direction = "right";
- sendMsg(renderSnakeGame());
- }
- function updateSnakeDirection(command) {
- // Update the snake's direction based on the command received
- if (command === "up" && direction !== "down") {
- direction = "up";
- } else if (command === "down" && direction !== "up") {
- direction = "down";
- } else if (command === "left" && direction !== "right") {
- direction = "left";
- } else if (command === "right" && direction !== "left") {
- direction = "right";
- }
- }
- function moveSnake() {
- // Move the snake in the current direction
- const head = { ...snake[0] };
- if (direction === "up") {
- head.y--;
- } else if (direction === "down") {
- head.y++;
- } else if (direction === "left") {
- head.x--;
- } else if (direction === "right") {
- head.x++;
- }
- // Add the new head to the snake
- snake.unshift(head);
- }
- function checkCollision() {
- // Check if the snake collides with the game boundaries or itself
- const head = snake[0];
- if (head.x < 0 || head.x >= 14 || head.y < 0 || head.y >= 6) {
- return true; // Collision with the game boundaries
- }
- for (let i = 1; i < snake.length; i++) {
- if (snake[i].x === head.x && snake[i].y === head.y) {
- return true; // Collision with itself
- }
- }
- return false;
- }
- function checkFoodEaten() {
- // Check if the snake eats the food
- const head = snake[0];
- if (head.x === food.x && head.y === food.y) {
- // Generate new food at a random position
- food = {
- x: Math.floor(Math.random() * 14),
- y: Math.floor(Math.random() * 6)
- };
- // Do not remove the tail, so the snake grows
- } else {
- // Remove the tail to maintain the snake's length
- snake.pop();
- }
- }
- function renderSnakeGame() {
- // Render the game as numbers
- let gameBoard = [];
- for (let y = 0; y < 6; y++) {
- gameBoard.push([]);
- for (let x = 0; x < 14; x++) {
- gameBoard[y].push(0); // Initialize with 0 (empty space)
- }
- }
- // Set snake segments
- for (const segment of snake) {
- const { x, y } = segment;
- gameBoard[y][x] = 1;
- }
- // Set food position
- gameBoard[food.y][food.x] = 2;
- return gameBoard.map(row => row.join(" ")).join("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement