API Reference

Events

BrainPywer Events Implementation Some implementation details taken from discord.py written by Danny/Rapptz at https://github.com/Rapptz/discord.py

class brainpywer.events.Events[source]
add(func)[source]

This is the decorator version of adding events

Parameters:func (function) – The function we’re registering as an event
Returns:func
dispatch(message)[source]

This function takes a message received from the Dispatcher and sends it to the proper handler. If no handler is defined, we call the default handler which should always be defined.

Parameters:message (tuple (event name, relevant data)) – The message to be dispatched.
Returns:Nothing
has_handler(event)[source]

Do we have a handler defined for this event?

Parameters:event (str) – The event name to handle
Returns:True if we have a handler defined
Returns:False if no handler is defined for the event
register(func)[source]

This is a method for programatically adding new events

Parameters:func (function) – The function we’re registering as an event
Returns:func
unregister(func)[source]

This is a method for programatically removing events

Parameters:func (str) – The name of the event to unregister
Returns:False if we failed to find the function to remove
Returns:True if we removed the function

Dispatcher

Http-thingamabob

BrainPywer Gateway testing implementation

class brainpywer.http.HttpClient(token: str)[source]

HttpClient Class for things

API_BASE = 'https://discordapp.com/api/v6'[source]
BASE_URL = 'https://discordapp.com'[source]
CHANNELS = 'https://discordapp.com/api/v6/channels'[source]
GATEWAY = 'https://discordapp.com/api/v6/gateway/bot'[source]
GUILDS = 'https://discordapp.com/api/v6/guilds'[source]
USERS = 'https://discordapp.com/api/v6/users'[source]
del_channel(channel: str)[source]
Parameters:channel
Returns:
delete_message(channel: str, message: str)[source]
Parameters:
  • channel
  • message
Returns:

edit_message(channel: str, message: str)[source]
Parameters:
  • channel
  • message
Returns:

get_channel(channel: str)[source]

Get a channel by ID. Returns a guild channel or dm channel object.

Parameters:channel (str) – channel id to get
Returns:
get_channel_message(channel: str, message: str)[source]
Parameters:
  • channel
  • message
Returns:

get_channel_messages(channel: str)[source]
Parameters:channel
Returns:
get_gateway()[source]

Return the wss url to connect to.

Returns:wss url
Return type:str
mod_channel(channel: str, *args)[source]
Parameters:
  • channel
  • args
Returns:

send_file(channel: str, content: str, file: str, tts: bool = False)[source]
Parameters:
  • channel
  • content
  • file
  • tts
Returns:

send_message(channel: str, content: str, tts: bool = False)[source]
Parameters:
  • channel
  • content
  • tts
Returns:

Interface

Util Functions

brainpywer.tinyutils.thaw(snowflake)[source]

Tiny function to return the unix timestamp of a snowflake

Parameters:snowflake (int) – a discord snowflake (It’s unique, just like you! ha.)
Returns:unix timestamp of the message
Return type:int