Advertisement
nonogamer9

CannyBOT Plus! Source Code

Jul 8th, 2023 (edited)
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.58 KB | None | 0 0
  1. const prefix = "ca!";
  2. const botname = "CannyBOT Plus! playing: ca!help";
  3. const version = "1.3 Rev 2";
  4. var help = "__CannyBOT Plus! Commands__\n ca!help, ca!joke, ca!fact, ca!image {IMAGE_URL}, ca!video {VIDEO_URL}, ca!crosscolor {CROSSCOLOR_URL}, ca!default, ca!incredibleroll, ca!weather {WEATHER_LOCATION}, ca!version, ca!roominfo";
  5. var botinfo = "CannyBOT Plus! " + version + ". Find CannyBOT at: https://pastebin.com/Sc5Cmbgt";
  6.  
  7. const incrediblerollPics = [
  8. "https://media.discordapp.net/attachments/1107412342960033832/1114622683460685854/dfa4skp-4ef45bab-b574-4b4d-aac2-12cf5b53b6c6.png?width=634&height=630",
  9. "https://media.discordapp.net/attachments/1114637956079173722/1114638247361003541/mr-incredible-becoming-uncanny-phase-1.png?width=722&height=630",
  10. "https://media.discordapp.net/attachments/1114637956079173722/1114638247642026025/latest.png",
  11. "https://media.discordapp.net/attachments/1114637956079173722/1114638247973355570/latest.png",
  12. "https://media.discordapp.net/attachments/1114637956079173722/1114638248258584627/images.png",
  13. "https://media.discordapp.net/attachments/1114637956079173722/1114638248501858444/images.png",
  14. "https://media.discordapp.net/attachments/1114637956079173722/1114638248824799332/latest.png",
  15. "https://media.discordapp.net/attachments/1114637956079173722/1114638486935449782/latest.png",
  16. "https://media.discordapp.net/attachments/1114637956079173722/1114638487237443584/latest.png",
  17. "https://media.discordapp.net/attachments/1114637956079173722/1114638487526854737/latest.png",
  18. "https://media.discordapp.net/attachments/1114637956079173722/1114638487849807872/350.png",
  19. "https://i1.sndcdn.com/artworks-JeZQh6Hbil2Er51B-U9rx3A-t500x500.jpg",
  20. "https://i1.sndcdn.com/avatars-RNXmlKLL2AHsRPaz-8LVOoA-t500x500.jpg",
  21. "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR8FcyNrd8y5BmEwp9xYLRjvYxDlheS4DjwgmLZIEvBO2yHIvCv",
  22. "https://pbs.twimg.com/media/FTHtsuDVUAIjUnO.jpg",
  23. "https://i.ytimg.com/vi/Zne8JgObXBc/maxresdefault.jpg",
  24. "https://i.ytimg.com/vi/BFFIS5r7Aj0/maxresdefault.jpg?sqp=-oaymwEmCIAKENAF8quKqQMa8AEB-AH-CYAC0AWKAgwIABABGH8gFSgTMA8=&rs=AOn4CLB0OOFdzym2aFPtk2jqd4beTm8baA",
  25. "https://i.ytimg.com/vi/TNpQGA762UU/mqdefault.jpg",
  26. "https://media.discordapp.net/attachments/1114860678000431254/1114864540321062952/latest.png?width=635&height=630",
  27. "https://media.discordapp.net/attachments/1114860678000431254/1114864540614660166/latest.png?width=635&height=630",
  28. "https://media.discordapp.net/attachments/1114860678000431254/1114864540899881030/latest.png?width=635&height=630",
  29. "https://media.discordapp.net/attachments/1114860678000431254/1114864541155725382/latest.png?width=635&height=630",
  30. "https://media.discordapp.net/attachments/1114860678000431254/1114864541617106985/latest.png?width=635&height=630",
  31. "https://media.discordapp.net/attachments/1114860678000431254/1114864541961035866/latest.png?width=646&height=630",
  32. "https://media.discordapp.net/attachments/1114860678000431254/1114864542409822298/latest.png?width=759&height=630",
  33. "https://media.discordapp.net/attachments/1114860678000431254/1127302563356741765/1000.png?width=630&height=630",
  34. "https://media.discordapp.net/attachments/1114860678000431254/1127302563713269851/1000.png?width=630&height=630",
  35. "https://media.discordapp.net/attachments/1114860678000431254/1127302564011069530/latest.png?width=747&height=630",
  36. "https://media.discordapp.net/attachments/1114860678000431254/1127302564430487613/1000.png?width=630&height=630",
  37. "https://media.discordapp.net/attachments/1114860678000431254/1127302564896067635/1000.png",
  38. "https://media.discordapp.net/attachments/1114860678000431254/1127302565260959744/latest.png",
  39. "https://media.discordapp.net/attachments/1114860678000431254/1127302701642956860/latest.png",
  40. "https://media.discordapp.net/attachments/1114860678000431254/1127302701974294699/1000.png?width=630&height=630",
  41. "https://media.discordapp.net/attachments/1114860678000431254/1127302702569902180/latest.png?width=761&height=630",
  42. "https://media.discordapp.net/attachments/1114860678000431254/1127302702288879797/1000.png?width=630&height=630",
  43. ];
  44.  
  45. function getRandomPic(picsArray) {
  46. const randomIndex = Math.floor(Math.random() * picsArray.length);
  47. return picsArray[randomIndex];
  48. }
  49.  
  50. function sendMsg(msg) {
  51. setTimeout(() => {
  52. socket.emit("talk", { text: msg });
  53. }, 1100);
  54. }
  55.  
  56. setTimeout(() => {
  57. socket.emit("command", { list: ["name", "CannyBOT Plus! playing: ca!help"] });
  58. }, 1000);
  59. setTimeout(() => {
  60. socket.emit("command", { list: ["color", "https://media.discordapp.net/attachments/1079083903433846836/1127298039825059970/i-tools.png"] });
  61. }, 2100);
  62. setTimeout(() => {
  63. sendMsg("CannyBOT Plus! is online. Type " + prefix + "help to see commands.");
  64. setInterval(() => {
  65. sendMsg("CannyBOT Plus! is online. Type " + prefix + "help to see commands.");
  66. }, 60000);
  67. }, 3200);
  68.  
  69. socket.on("talk", function (message) {
  70. if (message.text === prefix + "help") {
  71. sendMsg(help);
  72. } else if (message.text === prefix + "joke") {
  73. setTimeout(() => {
  74. socket.emit("command", { list: ["joke"] });
  75. }, 1100);
  76. } else if (message.text === prefix + "fact") {
  77. setTimeout(() => {
  78. socket.emit("command", { list: ["fact"] });
  79. }, 1100);
  80. } else if (message.text.startsWith(prefix + "image")) {
  81. const imageUrl = message.text.substring(prefix.length + 6);
  82. setTimeout(() => {
  83. socket.emit("command", { list: ["image", imageUrl] });
  84. }, 1100);
  85. } else if (message.text === prefix + "incredibleroll") {
  86. const randomPic = getRandomPic(incrediblerollPics);
  87. setTimeout(() => {
  88. socket.emit("command", { list: ["image", randomPic] });
  89. }, 1100);
  90. } else if (message.text.startsWith(prefix + "weather")) {
  91. const location = message.text.substring(prefix.length + 8);
  92. getWeather(location);
  93. } else if (message.text === prefix + "roominfo") {
  94. sendMsg("Amount of users in the room: " + window.usersAmt);
  95. } else if (message.text === prefix + "version") {
  96. sendMsg(botinfo);
  97. } else if (message.text.startsWith(prefix + "video")) {
  98. const videoUrl = message.text.substring(prefix.length + 6);
  99. setTimeout(() => {
  100. socket.emit("command", { list: ["video", videoUrl] });
  101. }, 1100);
  102. } else if (message.text.startsWith(prefix + "crosscolor")) {
  103. const crosscolorUrl = message.text.substring(prefix.length + 11);
  104. setTimeout(() => {
  105. socket.emit("command", { list: ["crosscolor", crosscolorUrl] });
  106. }, 1100);
  107. } else if (message.text === prefix + "default") {
  108. setTimeout(() => {
  109. socket.emit("command", { list: ["crosscolor", "https://media.discordapp.net/attachments/1079083903433846836/1127298039825059970/i-tools.png"] });
  110. }, 1100);
  111. }
  112. });
  113.  
  114. function getWeather(location) {
  115. const apiKey = "dcc6b2a3fa3d4fe58d9193316232905";
  116. const apiUrl = `https://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${encodeURIComponent(location)}`;
  117.  
  118. fetch(apiUrl)
  119. .then((response) => response.json())
  120. .then((data) => {
  121. if (data.error) {
  122. sendMsg("Unable to retrieve weather information. Please check the location.");
  123. } else {
  124. const weather = data.current;
  125. const weatherInfo = `Weather in ${data.location.name}, ${data.location.country}:\nCondition: ${weather.condition.text}\nTemperature: ${weather.temp_c}°C\nHumidity: ${weather.humidity}%\nWind Speed: ${weather.wind_kph} km/h\n`;
  126. sendMsg(weatherInfo);
  127. }
  128. })
  129. .catch((error) => {
  130. console.error("Error:", error);
  131. sendMsg("An error occurred while retrieving weather information.");
  132. });
  133. }
  134.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement