Constructor

@:value({ _storage : null, _zlib : true, _etf : false, _shardInfo : null })new (_tkn:String, ?_shardInfo:WSShard, _etf:Bool = false, _zlib:Bool = true, ?_storage:DataCache)

Initialize the bot with your token. This should be the first thing you run in your program.

Parameters:

_tkn
  • Your BOT token. User tokens do not work!

Variables

isBot:Bool

Is the bot a bot account?

user:User

The bot user, this is you.

Methods

dynamic_onReady ():Void

@:value({ cb : null })createDMGroup (data:CreateGroupDM, ?cb:DMChannel ‑> ErrorReport ‑> Void):Void

Create a DM group.

Parameters:

data
  • A struct that contains the necessary arguments required to invite members.
cb
  • Returns the group dm channel, or an error.

createGuild (guild_data:GuildCreate, cb:Null<Guild ‑> ErrorReport ‑> Void>):Void

Create a new guild based on the data given

Parameters:

guild_data
  • The data to be changed, All fields are optional.
cb
  • Returns the new guild object, or an error.

@:value({ cb : null })deleteInvite (invite_code:String, ?cb:Invite ‑> ErrorReport ‑> Void):Void

Delete an invite based on it's invite code. Requires the MANAGE_CHANNELS permission in the guild the invite is from.

Parameters:

invite_code
  • The invite code of the invite to delete.
cb
  • Returns the Invite that was removed, or an error.

@:value({ cb : null })editUser (user_data:{username:String, avatar:String}, ?cb:User ‑> ErrorReport ‑> Void):Void

Edit the current user's settings.

Parameters:

user_data
  • The parameters to change, all fields are optional.
cb
  • Return the changed user, or an error.

getChannel (id:String, cb:Channel ‑> Void):Void

Get a channel from cache if it's there otherwise get from the API.

Parameters:

id
  • The id of the desired channel.
cb
  • The callback to return the channel to.

getChannelUnsafe (id:String):Null<Channel>

Unsafely get a channel from cache based on it's id. Throws an error if the channel could not be loaded.

Parameters:

id
  • The id of the desired channel.

@:value({ cb : null })getConnections (?cb:Array<Connection> ‑> ErrorReport ‑> Void):Void

Get a list of connections hooked up to the current account.

Parameters:

cb
  • Returns a list of connections, or an error.

getDMChannels (cb:Array<DMChannel> ‑> Void):Void

Get a list of all dm channels the bot is in.

Parameters:

cb
  • Callback to return the channels to.

getDMChannelsUnsafe ():Array<DMChannel>

Get a list of all DMChannels currently in cache

getGuild (id:String, cb:Guild ‑> Void):Void

Get a guild from cache if it's there otherwise load from API.

Parameters:

id
  • The id of the desired guild.
cb
  • The Callback to return the guild to.

getGuildUnsafe (id:String):Null<Guild>

Unsafely get a guild from cache based on it's id. Throws an error if the guild is not cached.

Parameters:

id
  • The id of the desired guild

@:value({ cb : null })getGuilds (filter:GetGuildFilter, ?cb:Array<Guild> ‑> ErrorReport ‑> Void):Void

Get a list of all guilds that the current user is in. Normal users do not need to use the filter and can leave it blank {}

Parameters:

filter
  • Filter the list depending on these parameters, Only one of BEFORE or AFTER can be specified.
cb
  • Returns the list of Guilds according to the filter specified, or an error.

@:value({ cb : null })getInvite (invite_code:String, ?cb:Bool):Void

Get information about an invite code.

Parameters:

invite_code
  • The invite code.
cb
  • Returns an Invite object, or an error.

@:value({ perms : 0 })getInviteLink (perms:Int = 0):String

Get the invite link of the bot.

Parameters:

perms=0
  • The permissions to put on the link.

getMessage (id:String, channel_id:String, cb:Message ‑> Void):Void

Get a message from cache if it is there otherwise load from api.

Parameters:

id
  • The id of the message.
channel_id
  • The id of the channel the message is from.
cb
  • The callback to return the message to.

getMessageUnsafe (id:String):Null<Message>

Unsafely get a message based on it's id from cache. Throws an error if the message could not be loaded.

Parameters:

id
  • The id of the desired message.

getUser (id:String, cb:User ‑> Void):Void

Get a user from cache if it's there otherwise get from API.

Parameters:

id
  • The id of the desired user.
cb
  • The callback to return the user to.

@:value({ partial : true })getUserUnsafe (id:String, partial:Bool = true):Null<User>

Unsafely get a user based on it's id from cache. Throws an error if the user could not be loaded.

Parameters:

id
  • The id of the desired user.

@:value({ cb : null })joinInvite (invite_code:String, ?cb:Invite ‑> ErrorReport ‑> Void):Void

(NOT AVAILABLE FOR BOTS) Accept an invite code and join the server.

Parameters:

invite_code
  • The invite code to join.
cb
  • Returns the invite that was joined, or an error.

listVoiceRegions (cb:Null<Array<VoiceRegion> ‑> ErrorReport ‑> Void>):Void

Get a list of voice regions.

Parameters:

cb
  • Returns a list of voice regions, or an error.

dynamiconChannelCreate (c:Channel):Void

Event hook for when a new channel is created.

Parameters:

c
  • The channel object.

dynamiconChannelDelete (channel_id:String):Void

Event hook for when a channel is deleted.

Parameters:

channel_id
  • The id of the deleted channel.

dynamiconChannelUpdate (c:Channel):Void

Event hook for when a channel is changed/updated.

Parameters:

c
  • The new channel object.

dynamiconGuildCreate (g:Guild):Void

Event hook for when a guild is created or joined by you, fired when bot is starting up as well.

Parameters:

g
  • The guild object.

dynamiconGuildDelete (guild_id:String):Void

Event hook for when a guild is deleted

Parameters:

guild_id
  • The id of the guild that was deleted.

dynamiconGuildEmojisUpdate (g:Guild, emojis:Array<Emoji>):Void

Event hook for when a guild updates it's emojis.

Parameters:

g
  • The guild the emojis were updated for.
emojis
  • The new list of emojis

dynamiconGuildJoin (g:Guild):Void

NON-API Event hook for when a guild has been joined by you.

Parameters:

g
  • The guild object.

dynamiconGuildLeave (g:Guild):Void

NON-API Event hook for when a guild has been joined by you.

Parameters:

g
  • The guild object.

dynamiconGuildUpdate (g:Guild):Void

Event hook for when a guild is updated or changed.

Parameters:

g
  • The new guild object.

dynamiconMemberBan (g:Guild, u:Null<User>):Void

Event hook for when a user is banned from a guild.

Parameters:

g
  • The guild the ban was from.
u
  • The user that was banned (May be null).

dynamiconMemberJoin (g:Guild, m:GuildMember):Void

Event hook for when a new user joins a guild.

Parameters:

g
  • The guild the user has joined.
m
  • The instanced member object of the user.

dynamiconMemberLeave (g:Guild, u:Null<User>):Void

Event hook for when a member leaves a guild.

Parameters:

g
  • The guild the member belonged to.
u
  • The user of the member (May be null).

dynamiconMemberUnban (g:Guild, u:Null<User>):Void

Event hook for when a user is unbanned from a guild.

Parameters:

g
  • The guild the ban was from.
u
  • The user that was unbanned (May be null).

dynamiconMemberUpdate (g:Guild, m:GuildMember):Void

Event hook for when a user is updated or changed.

Parameters:

g
  • The guild the user is in.
m
  • The instanced member object of the user.

dynamiconMessage (m:Message):Void

Event hook for when a message is sent.

Parameters:

m
  • The message.

dynamiconMessageDelete (message_id:String):Void

Event hook for when a message is deleted.

Parameters:

message_id
  • The id of the deleted message.

dynamiconMessageEdit (m:Message):Void

Event hook for when a message is edited.

Parameters:

m
  • The new message.

dynamiconRawEvent (e:String, d:Dynamic):Void

A raw event hook, for things that require a little more flexibility.

Parameters:

e
  • The event name as defined by API Docs.
d
  • The event data.

dynamiconReactionAdd (m:Message, u:User, e:Emoji):Void

Event hook for when a reaction is added.

Parameters:

m
  • The message the reaction is added to.
u
  • The user that added the reaction.
e
  • The emoji of the reaction.

dynamiconReactionPurge (m:Message):Void

Event hook for when reactions are purged from a message.

Parameters:

m
  • The message that was purged.

dynamiconReactionRemove (m:Message, u:Null<User>, e:Emoji):Void

Event hook for when reactions are removed.

Parameters:

m
  • The message the reaction was removed from.
u
  • The user that removed the reaction. (Do not rely on this for purges, may be null)
e
  • The emoji of the reaction.

dynamiconReady ():Void

Event hook for when the bot has connected, loaded cache, and is ready to go.

dynamiconRoleCreate (g:Guild, r:Role):Void

Event hook for when a role is created.

Parameters:

g
  • The guild it was created in.
r
  • The role.

dynamiconRoleDelete (g:Guild, role_id:String):Void

Event hook for when a role is deleted

Parameters:

g
  • The guild it was deleted from.
role_id
  • The id of the role that was deleted.

dynamiconRoleUpdate (g:Guild, r:Role):Void

Event hook for when a role is changed/updated

Parameters:

g
  • The guild it was updated in.
r
  • The new role.

dynamiconTypingStart (u:User, c:Channel, t:Int):Void

Event hook for when someone starts typing

Parameters:

u
  • The user who started typing
c
  • The channel they are typing in
t
  • Timestamp of when they started typing (in seconds)

@:value({ cb : null })sendMessage (channel_id:String, message:MessageCreate, ?cb:Message ‑> ErrorReport ‑> Void):Void

Send a message to a channel

Parameters:

channel_id
  • The channel to send to
message
  • Message data
cb
  • Return the message sent, or an error

setActivity (activity:Activity):Void

Set the activity of the bot

Parameters:

activity
  • The activity object to set

setStatus (status:Status):Void

Set the status of the bot

Parameters:

status
  • The status object to set, All fields are optional

@:value({ blocking : true })start (blocking:Bool = true):Void

This is basically just a while true loop to keep the main thread alive while the other threads work.

Parameters:

blocking=true
  • If you dont want to have the while loop activate, set this to false and make your own loop.

Static variables

@:value(6)staticgatewayVersion:Int = 6

The gateway version being used.

@:value("Haxicord")staticlibName:String = "Haxicord"

The name of the library

@:value("DiscordBot (https://github.com/RaidAndFade/Haxicord, 0.2.0)")staticuserAgent:String = "DiscordBot (https://github.com/RaidAndFade/Haxicord, 0.2.0)"

The library's useragent