monium.ext package

Submodules

monium.ext.command module

class Command(module: monium.module.module.Module)

Command base class, extend to create your own command

name = ''

Command name

aliases = []

Any command aliases

allow_pm = False

Is this command allowed to be used from a private message

args = []

Command arguments

module

Module this command belongs in

client

Shortcut of module.client

run(message: discord.message.Message, **kwargs)

This function is a coroutine.

Command functionality

Parameters:
  • message – The message that ran this command
  • kwargs – Command arguments as a dictionary
class CommandParser(client: MoniumClient)

Command parser

This is the class responsible for parsing messages for commands and executing them.

register_command(command: monium.ext.command.Command)

Register a command

Parameters:command – Command to register

monium.ext.configuration module

class Configuration(file: str)

Configuration file handler. Uses the HOCON Configuration syntax.

set_if_not_exist(key: str, value, **kwargs)

Same as set(), but only if the key doesn’t exist

set(key: str, value, *, auto_save=False)

Set config key to value, can use dot notation to access nested keys. Also sets the modified variable, so you can see when you have to save.

Parameters:
  • key – Config key with dot notation
  • value – Value
  • auto_save – Save after set
get(key: str, *, default=None)

Get config key, can use dot notation to access nested keys

Parameters:
  • key – Config key with dot notation
  • default – Default value if not found
Returns:

Value

save(*, force=False)

Save config to file. Does not do anything if not modified, unless ‘force’ is set

Parameters:force – Save even if not modified
load()

Loads the config from file.

monium.ext.embeds module

Some pre-made embeds

error_embed(title: str, description: str = '') → discord.embeds.Embed

Returns an embed for an error

Parameters:
  • title – Embed title
  • description – Embed description
Returns:

Error embed

Return type:

discord.Embed

success_embed(title: str, description: str = '') → discord.embeds.Embed

Returns an embed for success

Parameters:
  • title – Embed title
  • description – Embed description
Returns:

Success embed

Return type:

discord.Embed

monium.ext.permissions module

class Permissions(client: MoniumClient, perm_config: monium.ext.configuration.Configuration)

Permission manager

has_permission(user: discord.member.Member, perm: str, *, ignore_owner=False) → bool

Checks if the user has the permission. Server owners will always have all permissions.

Parameters:
  • user – The user to check
  • perm – The permission to check
  • ignore_owner – Disable the the owner having all permissions
Returns:

If the user has the permission or not

Return type:

bool

get_with_permission(perm: str, **kwargs) → List[discord.member.Member]

Gets everyone with permission

Parameters:
  • perm – Permission
  • kwargs – Extra keyword arguments for has_permission
Returns:

Members with permission

Return type:

List[discord.Member]

get_permission(name: str) → List[str]

Get the role names this permission contains

Parameters:name – Permission name
Returns:Role names
Return type:List[str]
permission_exists(name: str) → bool

Check to see if the permission exists

Parameters:name – Permission name
Returns:Does the permission exist?
Return type:bool
add_permission(name: str, roles: List[str])

Adds a permission to the bot. If the permission exists, the bot will not to anything.

Parameters:
  • name – Permission name
  • roles – The role names that will have that permission, also works with the “perm:” and “user:” syntax

monium.ext.translation module

class Translation(module: Module)

The translation manager

default_lang = ''

Default language of this module

register_language(lang_code: str, config_object: monium.ext.configuration.Configuration, *, default=False)

Register a language file

Parameters:
  • lang_code – ISO 639-1 Language code
  • config_objectConfiguration object that stores language data.
  • default – Set to true if this should be the fallback language when a server asks for a invalid language.
get(server_id: str, key: str, format_vars: Dict[str, Any] = None) → str

Get a translated string

Parameters:
  • server_id – Server to get the string for
  • key – Translation key
  • format_vars – Any formatting variables
Returns:

Translated string

Return type:

str

monium.ext.voice module

class VoiceManager(client: monium.client.MoniumClient, vc: discord.channel.Channel)

Manages voice

client

The VoiceClient instance

player = None

The player playing the current sound.

Can be None if nothing is playing.

is_player_ytdl = False

Is true if the player is created from play_url

volume

Get player volume (from 0 to 100)

Returns:Player volume
Return type:int
stop()

Stop player

pause()

Pause player

resume()

Resume player

connect()

Connect to the channel

disconnect()

Disconnect from the channel

play_file(filename: str, *, force=False, callback=None, **kwargs)

Play a file in the voice channel

This function is a coroutine.

Parameters:
  • filename – Filename to play
  • force – Stop the current playing sound if there is any.
  • callback – Coroutine to call back before voice starts playing
  • kwargs – extra arguments to create_ffmpeg_player
play_url(url: str, *, force=False, callback=None, **kwargs)

Play a URL in the voice channel using youtube_dl

This function is a coroutine.

Parameters:
  • url – URL to play
  • force – Stop the current playing sound if there is any.
  • callback – Coroutine to call back before voice starts playing
  • kwargs – extra arguments to create_ytdl_player
class PlaylistType

Types of playlist entries for PlaylistManager

FILE = 0

This playlist entry is a local file, played using play_file

URL = 1

This playlist entry is a URL, played using play_url

class PlaylistManager(vm: monium.ext.voice.VoiceManager)

Playlist wrapper for VoiceManager

import_from(url: str)

Import playlist from URL (A YouTube playlist, for example)

This function is a coroutine.

Parameters:url – Playlist url
play(*, done_cb=None, **kwargs)

Start playing

This function is a coroutine.

Parameters:
  • done_cb – Optional callback for when playing is done. (Coroutine)
  • kwargs – Optional parameters for the play_xyz functions.
search_and_add(query: str)

Add video from YouTube search

This function is a coroutine.

Parameters:url – Playlist url
voice

The VoiceManager instance.

queue

The music queue

add(type: monium.ext.voice.PlaylistType, thing: str)

Add an item to the playlist

Parameters:
  • type – Item type
  • thing – Filename or URL depending on the item type