Skip to content

Instantly share code, notes, and snippets.

@Luckshya
Created March 10, 2019 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luckshya/a6554f7e655a8b38d459e3f2482a1828 to your computer and use it in GitHub Desktop.
Save Luckshya/a6554f7e655a8b38d459e3f2482a1828 to your computer and use it in GitHub Desktop.
Example discord code for official squirrel plugin (sleepy-discord)
//open connection to discord
discordConn <- Discord_Open("token here");
//event onDiscord_Ready indicating that the bot has connected successfully
function onDiscord_Ready(discordHandle) {
//retrieve our connection ID
local connID = Discord_ConnID(discordHandle);
print("Discord bot at ID: " + connID + " is ready.");
//send a messsage
Discord_Message(discordConn, "channel ID", "message here"); //you can use discordHandle as well
}
//event onDiscord_Message when a message to recieved to an accessible channel to bot
function onDiscord_Message(discordHandle, channelID, authorID, authorNick, author, roles, message) {
//retrieve our connection ID
local connID = Discord_ConnID(discordHandle);
print("Discord bot at ID: " + connID + " has recieved a message.");
print("ChannelID: " + channelID);
print("Author: " + author);
print("Author Nick: " + authorNick);
print("Author ID: " + authorID);
print("Message: " + message);
foreach(role in roles) {
print("Role: " + role);
print("Role Name: " + Discord_GetRoleName(discordHandle, "server ID", role));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment