Advertisement
spotowy

the jokersignal

Mar 14th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. // ==UserScript==
  2. // @name The Jokersignal
  3. // @description A plugin that sends a desktop notification and a message link when the word "joker" is mentioned in a specific channel of a specific server
  4. // @version 1.0
  5. // @author Your Name
  6. // @namespace https://yournamespace.com/
  7. // @homepageURL https://yourhomepage.com/
  8. // @supportURL https://yoursupporturl.com/
  9. // @license MIT
  10. // @match https://discord.com/*
  11. // @grant GM_notification
  12. // ==/UserScript==
  13.  
  14. const targetServerId = "YOUR_SERVER_ID";
  15. const targetChannelId = "YOUR_CHANNEL_ID";
  16. const targetWord = "joker";
  17.  
  18. const targetServer = findServerById(targetServerId);
  19. const targetChannel = findChannelById(targetChannelId);
  20.  
  21. function findServerById(serverId) {
  22. return BdApi.findModuleByProps("getGuilds").getGuilds().find(server => server.id === serverId);
  23. }
  24.  
  25. function findChannelById(channelId) {
  26. return BdApi.findModuleByProps("getChannels").getChannels(targetServer.id).find(channel => channel.id === channelId);
  27. }
  28.  
  29. BdApi.injectCSS("the-jokersignal", `
  30. /* Add any custom CSS for your plugin here */
  31. `);
  32.  
  33. function sendNotification(message) {
  34. const notificationOptions = {
  35. title: "The Jokersignal",
  36. text: message.content,
  37. image: message.author.avatarURL,
  38. onclick: function () {
  39. jumpToMessage(message.id);
  40. }
  41. };
  42. GM_notification(notificationOptions);
  43. }
  44.  
  45. function jumpToMessage(messageId) {
  46. const link = `https://discord.com/channels/${targetServerId}/${targetChannelId}/${messageId}`;
  47. window.location.href = link;
  48. }
  49.  
  50. function onMessageReceived(message) {
  51. if (message.guild.id === targetServerId && message.channel.id === targetChannelId && message.content.includes(targetWord)) {
  52. sendNotification(message);
  53. }
  54. }
  55.  
  56. const TheJokersignal = class {
  57. getName() {
  58. return "The Jokersignal";
  59. }
  60.  
  61. getDescription() {
  62. return "A plugin that sends a desktop notification and a message link when the word 'joker' is mentioned in a specific channel of a specific server";
  63. }
  64.  
  65. getVersion() {
  66. return "1.0.0";
  67. }
  68.  
  69. getAuthor() {
  70. return "Your Name";
  71. }
  72.  
  73. start() {
  74. BdApi.findModuleByProps("Dispatcher").subscribe("MESSAGE_CREATE", onMessageReceived);
  75. }
  76.  
  77. stop() {
  78. BdApi.findModuleByProps("Dispatcher").unsubscribe("MESSAGE_CREATE", onMessageReceived);
  79. }
  80. };
  81.  
  82. window.TheJokersignal = TheJokersignal;
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement