class MyDiscord extends SqDiscord.Session | |
{ | |
function constructor() { | |
// Call the base constructor to intialize the connection | |
base.constructor(); | |
// Bind our events | |
base.Bind(SqDiscordEvent.Ready, this, onReady); | |
base.Bind(SqDiscordEvent.Message, this, onMessage); | |
} | |
// Event onReady (Very first event for doing discord related stuff) | |
function onReady() { | |
SqLog.Inf("Dicord bot connection established successfully."); | |
this.Message("channel ID", "message string"); //used to send a message to the specified channel | |
} | |
// Event onMessage is called when a message is recieved to an acessible channel to bot | |
function onMessage(channelID, author, authorNick, authorID, roles, message) { | |
SqLog.Inf("Channel: " + channelID); | |
SqLog.Inf("Author: " + author); | |
SqLog.Inf("Author Nick: " + authorNick); | |
SqLog.Inf("Author ID: " + authorID); | |
SqLog.Inf("Message: " + message); | |
foreach(role in roles) { | |
SqLog.Inf("Role: " + role); | |
SqLog.Inf("Role Name: " + this.GetRoleName("server ID", role)); | |
} | |
} | |
} | |
// Create an instance of our Session | |
myDiscord <- MyDiscord(); | |
// Makes connection to discord | |
myDiscord.Connect("token here"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment