Last active
November 29, 2022 05:06
-
-
Save hepteract/8d9199a6a154dd32a1c4ced97de76043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//META{"name":"SendEmbeds"}*// | |
function SendEmbeds() { | |
return; | |
} | |
SendEmbeds.prototype.load = function() {}; | |
SendEmbeds.prototype.unload = function() {}; | |
SendEmbeds.prototype.start = function() { | |
this.attachHandler(); | |
}; | |
SendEmbeds.prototype.onSwitch = function() { | |
this.attachHandler(); | |
}; | |
SendEmbeds.prototype.stop = function() { | |
var el = $('.channel-textarea textarea'); | |
if (el.length == 0) return; | |
// Remove handlers and injected script | |
el.unbind("click focus", this.focusHandler); | |
el[0].removeEventListener("keydown", this.handleKeypress); | |
}; | |
SendEmbeds.prototype.getName = function() { | |
return "Send Embeds"; | |
}; | |
SendEmbeds.prototype.getDescription = function() { | |
return "Allows you to create fancy embed text."; | |
}; | |
SendEmbeds.prototype.getVersion = function() { | |
return "0.1"; | |
}; | |
SendEmbeds.prototype.getAuthor = function() { | |
return "Septeract"; | |
}; | |
var token = "PUT YOUR TOKEN HERE"; // Have to do this because localStorage.token no longer works | |
let sendEmbed = function(title, text, color) { | |
var channelID = window.location.pathname.split('/').pop(); | |
var embed = { | |
type : "rich", | |
description : text | |
}; | |
if (color) { | |
embed.color = color; | |
} | |
if (title) { | |
embed.title = title; | |
} | |
var data = JSON.stringify({embed : embed}); | |
console.log(data); | |
$.ajax({ | |
type : "POST", | |
url : "https://discordapp.com/api/channels/" + channelID + "/messages", | |
headers : { | |
//"authorization": localStorage.token.slice(1, -1) | |
"authorization": token | |
}, | |
dataType : "json", | |
contentType : "application/json", | |
data: data, | |
error: (req, error, exception) => { | |
console.log(req.responseText); | |
} | |
}); | |
} | |
SendEmbeds.prototype.attachHandler = function() { | |
var el = $('.channel-textarea textarea'); | |
if (el.length == 0) return; | |
var self = this; | |
// Handler to catch key events | |
this.handleKeypress = function (e) { | |
var code = e.keyCode || e.which; | |
if (code !== 13) { | |
// console.log(`Ignored keypress: ${code}`); | |
return; | |
} | |
var text = $(this).val(); | |
if (!text.startsWith("/e")) { | |
// console.log(`Ignored text entry: ${text}`); | |
return; | |
} | |
e.preventDefault(); | |
e.stopPropagation(); | |
var color; | |
var msg; | |
if (text[3] == "#") { | |
color = parseInt(text.slice(4, 10), 16); | |
msg = text.substring(11); | |
} else { | |
msg = text.substring(3); | |
} | |
var title; | |
if (msg[0] == "\"") { | |
msg = msg.substring(1); | |
let index = msg.indexOf("\""); | |
title = msg.substring(0, index); | |
msg = msg.substring(index + 2); | |
} | |
sendEmbed(title, msg, color); | |
$(this).val(""); | |
} | |
// bind handlers | |
el[0].addEventListener("keydown", this.handleKeypress, false); | |
} |
i have found one that works(as of posting), also it grabs your Security Token for you 🥇
i have found one that works(as of posting), also it grabs your Security Token for you
doesnt work anymore
Here is a version I have fixed. If it doesn't work just create an issue and I will try my best to fix it.
https://github.com/Fraserbc/BetterDiscord-Embeds
I don't know why it doesn't work.
If i press enter it doesn't appear anything even if I use the example code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it still work normally? With me it does not work