Data Models¶
This module contains a compilation of data models.
- to_dict()[source]¶
Convert a Discord object into a Dictionary.
Note
Currently only supports User, Guild, and TextChannel.
- Parameters
dc_obj (Union[
discord.User
,discord.Guild
,discord.TextChannel
,discord.Role
]) – Discord object to be converted.- Returns
Dictionary of Discord object.
- Return type
Dict[str, Any]
- class Model[source]¶
The Base Model Class which has a corresponding Collection in the DB.
- Parameters
user (
discord.Member
) – The user to map the collection to.
- uid_fields = <bound method ? of <class 'scripts.base.models.Model'>>¶
- get()[source]¶
Returns the Model object as a dictionary.
- Parameters
param (str) – The attribute to get from the Model.
- Returns
The attribute value.
- Return type
Any
- classmethod latest()[source]¶
Returns the latest douments from the DB for a model.
- Parameters
limit (Optional[int]) – The number of documents to return., default 5
- Returns
The documents from the DB.
- Return type
List[Dict]
- classes = <bound method ? of <class 'scripts.base.models.Model'>>¶
- classmethod censor_uids()[source]¶
Censors the user IDs in all the collections.
- Parameters
user (
discord.User
) – The user to censor.- Returns
The number of documents censored.
- Return type
int
- class Blacklist[source]¶
Wrapper for blacklisted users based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.mod (Optional[
discord.Member
]) – The Admin who used the command.reason (Optional[str]) – The reason for the blacklist.
- class CommandData[source]¶
Wrapper for command based DB actions
- Parameters
user (
discord.Member
) – The user to map the collection to.message (Message) – The message which triggered the command.
is_interaction (bool) – Whether the command is an interaction.
command (str) – The command which was triggered.
args (List[str]) – The arguments passed to the command.
kwargs (Dict[str, Any]) – The keyword arguments passed to the command.
- classmethod history()[source]¶
Returns the list of commands used on PG till now.
- Parameters
limit (Optional[int]) – The number of documents to return., default 5
- Returns
The recorded commands from the DB.
- Return type
List[Dict]
- classmethod most_active_channel()[source]¶
Returns the most active channel.
- Returns
The most active channel.
- Return type
Dict
- classmethod most_used_command()[source]¶
Returns the most used command.
- Returns
The most used command.
- Return type
Dict
- classmethod most_active_user()[source]¶
Returns the most active user.
- Returns
The most active user.
- Return type
Dict
- classmethod num_user_cmds()[source]¶
Returns the number of commands used by a user.
- Parameters
user_id (str) – The ID of the user.
- Returns
The number of commands used by the user.
- Return type
int
- classmethod clean_guild()[source]¶
Replaces the given guild ID in all commands with “REDACTED”.
- Parameters
guild_id (str) – The ID of the guild.
- Returns
The number of removed commands.
- Return type
int
- classmethod trend()[source]¶
Returns the number of commands used on PG per day.
- Parameters
include_os (bool) – Whether to include commands used on the Official Server.
start_time (Optional[datetime]) – The start time of the period.
end_time (Optional[datetime]) – The end time of the period.
- Returns
The number of commands used on PG.
- Return type
Iterable[Dict[str, Union[int, datetime]]]
- class DuelActionsModel[source]¶
Wrapper for duel actions based DB actions
- Parameters
user (
discord.Member
) – The user to map the collection to.action (Optional[str]) – An action which can be used in a duel.
level (Optional[str]) – The level of the action.
- class Exchanges[source]¶
Wrapper for currency exchanges based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.admin (Optional[
discord.Member
]) – The Admin who performed the exchange.pokebot (Optional[
discord.Member
]) – The Pokemon themed bot.chips (Optional[int]) – The amount of chips exchanged.
mode (Optional[str]) – The mode of the exchange., default is Deposit.
- class Inventory[source]¶
Wrapper for Inventory based DB operations.
- Parameters
user (
discord.Member
) – The user to map the collection to.
- delete()[source]¶
Deletes an Item from user’s Inventory. Input can either be a name or List of itemids. If item name is given, a quantity can be provided. If quantity is -1, all items of the name will be removed.
- Parameters
item_inp (Union[str, List[str]]) – The name or list of item ids to delete.
quantity (int) – The quantity of items to delete., default is -1.
is_name (bool) – Whether the input is a name or list of item ids.
- Returns
The number of items deleted.
- Return type
int
- from_id()[source]¶
Gets an item using ItemID if it exists in user’s inventory.
- Parameters
itemid (str) – The ItemID of the item.
- Returns
The Item object.
- Return type
- from_name()[source]¶
Returns a list of ItemIDs if they exist in user’s Inventory.
- Parameters
name (str) – The name of the item.
- Returns
The list of ItemIDs.
- Return type
List[str]
- get()[source]¶
Returns a list of items in user’s Inventory and the net worth.
- Parameters
category (Optional[str]) – The category to filter by.
- Returns
The list of items and the net worth of the inventory.
- Return type
Tuple[Dict[str, List], int]
- class Matches[source]¶
Wrapper for Gamble matches based DB actions
- Parameters
user (
discord.Member
) – The user to map the collection to.started_by (Optional[
discord.Member
]) – The user who started the match.participants (Optional[List[
discord.Member
]]) – The list of participants.winner (
discord.Member
) – The user who won.deal_cost (int) – The fee of the gamble match., deafult is 50.
lower_wins (bool) – Was the lower_wins rule in place?
by_joker (bool) – Did the match end due to a joker?
- property num_matches: int¶
Returns number of gamble matches played.
- Returns
Number of matches played.
- Return type
int
- property num_wins: int¶
Returns number of gamble matches won.
- Returns
Number of matches won.
- Return type
int
- get_stats()[source]¶
Get Match
num_matches()
andnum_wins()
as a Tuple.- Returns
Tuple of num_matches and num_wins.
- Return type
Tuple[int, int]
- class Trades[source]¶
Wrapper for trades based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.traded_to (
discord.Member
) – The user with whom the trade happened.given_chips (int) – The number of pokechips given to user.
taken_chips (int) – The number of pokechips taken from user.
given_items (List[str]) – The list of items given to user.
taken_items (List[str]) – The list of items taken from user.
- class Transactions[source]¶
Wrapper for webshop transactions based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.created_on (datetime) – The date and time of the transaction.
tx_id (str) – The transaction ID.
gateway (str) – The gateway used for the transaction.
webitem_id (str) – The ID of the webitem.
quantity (int) – The quantity of the webitem purchased.
total_price (float) – The total price of the transaction.
redeemed (bool) – Was the webitem redeemed?
- get()[source]¶
Get all transactions for the user.
- Returns
List of transactions.
- Return type
List[Transactions]
- from_tx_id()[source]¶
Get the transaction with the given ID.
- Parameters
tx_id (str) – The transaction ID.
- Returns
The transaction.
- Return type
- class Minigame[source]¶
Base class for Minigames.
- property num_plays: int¶
Returns number of minigames (of specified type) played.
- Returns
Number of minigames played.
- Return type
int
- property num_wins¶
Returns number of minigames (of specified type) won.
- Returns
Number of minigames won.
- Return type
int
- get_lb()[source]¶
Returns leaderboard for the specified minigame.
- Returns
The leaderboard for the minigame.
- Return type
List[Dict]
- class UnlockedModel[source]¶
The Base Unlocked Model class which can be modified after creation.
- Parameters
user (
discord.Member
) – The user to map the collection to.
- pk_field: str = 'user_id'¶
The name of the primary key.
- class UnboundModel[source]¶
A special subset of Models which don’t have a user associated with them.
- Parameters
pk_value (Optional[Any]) – The value of the primary key.
- pk_field: str = '_id'¶
The name of the primary key.
- class Boosts[source]¶
Wrapper for Permanent Boosts based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.
- class Loots[source]¶
Wrapper for Loots based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.
- class Profiles[source]¶
Wrapper for Profiles based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.
- property full_info: Dict¶
Get the full/consolidated info for the user.
- Returns
The full info for the user.
- Return type
Dict
- credit()[source]¶
Shorthand method to credit user’s balance and won_chips.
- Parameters
amount (int) – The amount to credit to the balance.
bonds (bool) – Currency type is Pokebonds?
- debit()[source]¶
Shorthand method to debit user’s balance and won_chips.
- Parameters
amount (int) – The amount to debit from the balance.
bonds (bool) – Currency type is Pokebonds?
- get_badges()[source]¶
Computes the Badges unlocked by the user.
- Returns
The list of badges unlocked by the user.
- Return type
List[str]
- get_rank()[source]¶
Get the user’s rank in the leaderboard.
- Returns
The user’s rank in the leaderboard.
- Return type
int
- classmethod get_all()[source]¶
DB query to get all whitelisted profiles.
- Parameters
ids_only (bool) – Return only the user IDs?
- Returns
The list of whitelisted profiles.
- Return type
List[Dict]
- class Votes[source]¶
Wrapper for Votes based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.
- classmethod most_active_voter()[source]¶
Get the most active voter.
- Returns
The most active voter.
- Return type
Dict
- votes_count = <bound method ? of <class 'scripts.base.models.Votes'>>¶
- class Webshop[source]¶
Wrapper for Webshop Model.
- Parameters
name (str) – The name of the item.
description (str) – The description of the item.
image (str) – The image of the item.
price (float) – The price of the item.
offer_price (float) – Any special offer price for the item.
reward_pokechips (int) – The amount of Pokechips held by the item.
reward_pokebonds (int) – The amount of Pokebonds held by the item.
reward_items (List[
Item
]) – The ingame Items held by the item.meta (Dict[str, bool]) – Metadata Dictionary
- class Duels[source]¶
Wrapper for duels based DB actions
- Parameters
user (
discord.Member
) – The user to map the collection to.gladiator (Optional[str]) – The gladiator used by the user.
opponent (Optional[
discord.Member
]) – The opponent for the Duel.opponent_gladiator (Optional[str]) – The gladiator of the opponent.
won (Optional[str]) – The ID of the winner of the Duel.
cost (Optional[int]) – The cost of the Duel., default is 50.
- class Flips[source]¶
Wrapper for Quickflips based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.cost (int) – The cost of the flip.
won (bool) – Did the user win the flip?
- class Moles[source]¶
Wrapper for Whackamole based DB actions.
- Parameters
user (
discord.Member
) – The user to map the collection to.cost (int) – The cost of the mole.
level (int) – The level of the mole.
won (bool) – Did the user win the mole?
- class Checkpoints[source]¶
Wrapper for Daily Checkpoints Model.
- Parameters
ctx (
bot.PokeGambler
) – The PokeGambler client.
- num_profiles¶
The number of profiles created till this checkpoint.
- num_guilds¶
The number of guilds the bot is in.
- num_commands¶
The number of commands used till this checkpoint.
- num_votes¶
The number of votes received till this checkpoint.
- class Nitro[source]¶
Wrapper for Nitro Reward records.
- Parameters
boosters (List[
discord.Member
]) – The list of the nitro boosters.rewardboxes (List[str]) – The list of IDs of nitro reward boxes.