Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name The Jokersignal
- // @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
- // @version 1.0
- // @author Your Name
- // @namespace https://yournamespace.com/
- // @homepageURL https://yourhomepage.com/
- // @supportURL https://yoursupporturl.com/
- // @license MIT
- // @match https://discord.com/*
- // @grant GM_notification
- // ==/UserScript==
- const targetServerId = "YOUR_SERVER_ID";
- const targetChannelId = "YOUR_CHANNEL_ID";
- const targetWord = "joker";
- const targetServer = findServerById(targetServerId);
- const targetChannel = findChannelById(targetChannelId);
- function findServerById(serverId) {
- return BdApi.findModuleByProps("getGuilds").getGuilds().find(server => server.id === serverId);
- }
- function findChannelById(channelId) {
- return BdApi.findModuleByProps("getChannels").getChannels(targetServer.id).find(channel => channel.id === channelId);
- }
- BdApi.injectCSS("the-jokersignal", `
- /* Add any custom CSS for your plugin here */
- `);
- function sendNotification(message) {
- const notificationOptions = {
- title: "The Jokersignal",
- text: message.content,
- image: message.author.avatarURL,
- onclick: function () {
- jumpToMessage(message.id);
- }
- };
- GM_notification(notificationOptions);
- }
- function jumpToMessage(messageId) {
- const link = `https://discord.com/channels/${targetServerId}/${targetChannelId}/${messageId}`;
- window.location.href = link;
- }
- function onMessageReceived(message) {
- if (message.guild.id === targetServerId && message.channel.id === targetChannelId && message.content.includes(targetWord)) {
- sendNotification(message);
- }
- }
- const TheJokersignal = class {
- getName() {
- return "The Jokersignal";
- }
- getDescription() {
- 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";
- }
- getVersion() {
- return "1.0.0";
- }
- getAuthor() {
- return "Your Name";
- }
- start() {
- BdApi.findModuleByProps("Dispatcher").subscribe("MESSAGE_CREATE", onMessageReceived);
- }
- stop() {
- BdApi.findModuleByProps("Dispatcher").unsubscribe("MESSAGE_CREATE", onMessageReceived);
- }
- };
- window.TheJokersignal = TheJokersignal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement