database.database module

class database.database.Database[source]

Bases: object

An interface to the bot’s database.

add_member(member_id, username)[source]

Adds a member to the database.

Parameters:
  • member_id – Unique discord id for that member.
  • username – Membername and discriminator combination string.
Returns:

A member record.

member_exists(member_id)[source]

Checks whether the chosen member is present in the database.

Parameters:member_id – Unique discord id for that member.
Returns:Whether there is a member with that id in the database.
get_member(member_id)[source]

Gets a member from the database.

Parameters:member_id – Unique discord id for that member.
Returns:A member record.
delete_member(member_id)[source]

Deletes a member from the database.

Parameters:member_id – Unique discord id for that member.
Returns:Whether the member was succesfully deleted.
add_message(message)[source]

Adds a message to the database.

Parameters:message – A discord message.
Returns:A message record.
get_message(message_id)[source]

Gets a message from the database.

Parameters:message_id – The message’s uid in the database.
Returns:A message record.
get_messages_for_member(member_id)[source]

Gets all messages for the chosen member.

Parameters:member_id – Unique discord id for that member.
Returns:A list of message records.
delete_message(message_id)[source]

Deletes a message from the database.

Parameters:message_id – The message’s uid in the database.
Returns:Whether the message was succesfully deleted.
get_top_members_per_message_count(top_n=9)[source]

Gets the most active members sorted by number of messages posted.

Parameters:top_n – The maximum number of members to return.
Returns:A list of the top n most active members.
get_top_members_per_num_characters(top_n=20)[source]

Gets the most active members sorted by the sum of the number of characters in the messages they posted.

Parameters:top_n – The maximum number of members to return.
Returns:A list of the top n most active members.
get_message_count_over_period(period)[source]

Gets the number of messages posted by date.

Parameters:period – The period over which to count messages, can be “day” or “week”.
Returns:A list of objects containing a date and a count (number of messages posted that day) for every date where a message was posted on the channel.
thank_member(thanks_recipient_id, thanks_giver_id)[source]

Adds a thank you to the database.

Parameters:
  • thanks_recipient_id – The id of the member to be thanked.
  • thanks_giver_id – The id of the member who’s thankful.
Returns:

A thanks record.