discordSuperUtils Modules

discordSuperUtils.Antispam module

class discordSuperUtils.Antispam.DefaultSpamDetectionGenerator[source]

Bases: discordSuperUtils.Antispam.SpamDetectionGenerator

generate(last_messages: List[discord.message.Message]) Union[bool, Any][source]

This function is an abstract method. The generate function of the generator.

Parameters

last_messages (List[discord.Message]) – The last messages sent (5 is max).

Returns

A boolean representing if the message is spam.

Return type

Union[bool, Any]

class discordSuperUtils.Antispam.SpamDetectionGenerator[source]

Bases: abc.ABC

Represents a SpamManager that filters messages to find spam.

abstract generate(last_messages: List[discord.message.Message]) Union[bool, Any][source]

This function is an abstract method. The generate function of the generator.

Parameters

last_messages (List[discord.Message]) – The last messages sent (5 is max).

Returns

A boolean representing if the message is spam.

Return type

Union[bool, Any]

class discordSuperUtils.Antispam.SpamManager(bot: commands.Bot, generator: SpamDetectionGenerator = None, wipe_cache_delay: timedelta = datetime.timedelta(seconds=300))[source]

Bases: discordSuperUtils.Base.EventManager

Represents a SpamManager which detects spam.

add_punishments(punishments: List[Punishment]) None[source]
bot
generator
static get_messages_similarity(messages: Iterable[str]) float[source]

Gets the similarity between messages.

Parameters

messages (Iterable[str]) – Messages to compare.

Return type

float

Returns

The similarity between messages (0-1)

punishments

discordSuperUtils.Ban module

class discordSuperUtils.Ban.BanManager(bot: commands.Bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker, discordSuperUtils.Punishments.Punisher

A BanManager that manages guild bans.

async ban(member: discord.member.Member, reason: str = 'No reason provided.', time_of_ban: Union[int, float] = 0) None[source]

This function is a coroutine.

Bans the member from the guild.

Parameters
  • member (discord.Member) – The member to ban.

  • reason (str) – The reason of the ban.

  • time_of_ban (Union[int, float]) – The time of ban.

Returns

None

Return type

None

bot
async static get_ban(member: Union[discord.member.Member, discord.user.User], guild: discord.guild.Guild) Optional[discord.user.User][source]

This function is a coroutine.

This function returns the user object of the member if he is banned from the guild.

Parameters
  • member (discord.Member) – The banned member.

  • guild (discord.Guild) – The guild.

Returns

The user object if found.

Return type

Optional[discord.User]

async get_banned_members() List[Dict[str, Any]][source]

This function is a coroutine.

This function returns all the members that are supposed to be unbanned but are banned.

Returns

The list of unbanned members.

Return type

List[Dict[str, Any]]

async on_database_connect()[source]
async punish(ctx: commands.Context, member: discord.Member, punishment: Punishment) None[source]

The manager’s punish function.

Parameters
  • ctx (commands.Context) – The context of the punishments.

  • member (discord.Member) – The member to punish.

  • punishment (Punishment) – The punishment to punish the member with.

Return type

None

Returns

None

async unban(member: Union[discord.member.Member, discord.user.User], guild: Optional[discord.guild.Guild] = None) bool[source]
exception discordSuperUtils.Ban.UnbanFailure[source]

Bases: Exception

Raises an exception when the user tries to unban a discord.User without passing the guild.

discordSuperUtils.Base module

class discordSuperUtils.Base.CogManager[source]

Bases: object

A CogManager which helps the user use the managers inside discord cogs.

class Cog(managers: Optional[List] = None)[source]

Bases: object

The internal Cog class.

static event(manager_type: Any) Callable[source]

Adds an event to the Cog event list.

Parameters

manager_type (Any) – The manager type of the event.

Return type

Callable

Returns

The inner function.

Raises

TypeError: The listener isn’t async.

class discordSuperUtils.Base.DatabaseChecker(tables_column_data: List[Dict[str, str]], table_identifiers: List[str])[source]

Bases: discordSuperUtils.Base.EventManager

A database checker which makes sure the database is connected to a manager and handles the table creation.

async connect_to_database(database: Database, tables: List[str]) None[source]

Connects to the database. Calls on_database_connect when connected.

Parameters
  • database (Database) – The database to connect to.

  • tables (List[str]) – The tables to create (incase they do not exist).

Return type

None

Returns

None

exception discordSuperUtils.Base.DatabaseNotConnected[source]

Bases: Exception

Raises an error when the user tries to use a method of a manager without a database connected to it.

class discordSuperUtils.Base.EventManager[source]

Bases: object

An event manager that manages events for managers.

add_event(func: Callable, name: Optional[str] = None) None[source]

Adds an event to the event dictionary.

Parameters
  • func (Callable) – The event callback.

  • name (str) – The event name.

Returns

None

Return type

None

Raises

TypeError: The listener isn’t async.

async call_event(name: str, *args, **kwargs) None[source]

Calls the event name with the arguments

Parameters
  • name (str) – The event name.

  • args – The arguments.

  • kwargs – The key arguments.

Returns

None

Return type

None

event(name: Optional[str] = None) Callable[source]

A decorator which adds an event listener.

Parameters

name (str) – The event name.

Returns

The inner function.

Return type

Callable

remove_event(func: Callable, name: Optional[str] = None) None[source]

Removes an event from the event dictionary.

Parameters
  • func (Callable) – The event callback.

  • name (str) – The event name.

Returns

None

Return type

None

exception discordSuperUtils.Base.InvalidGenerator(generator)[source]

Bases: Exception

Raises an exception when the user passes an invalid generator.

generator
discordSuperUtils.Base.generate_column_types(types: Iterable[str], database_type: Any) Optional[List[str]][source]

Generates the column type names that are suitable for the database type.

Parameters
  • types (Iterable[str]) – The column types.

  • database_type (Any) – The database type.

Returns

The suitable column types for the database types.

Return type

Optional[List[str]]

discordSuperUtils.Base.get_generator_response(generator: Any, generator_type: Any, *args, **kwargs) Any[source]

Returns the generator response with the arguments.

Parameters
  • generator (Any) – The generator to get the response from.

  • generator_type (Any) – The generator type. (Should be same as the generator type.

  • args – The arguments of the generator.

  • kwargs – The key arguments of the generator

Returns

The generator response.

Return type

Any

async discordSuperUtils.Base.maybe_coroutine(function: Callable, *args, **kwargs) Any[source]

This function is a coroutine.

Returns the coroutine version of the function.

Parameters
  • function (Union[Awaitable, Callable]) – The function to convert.

  • args – The arguments.

  • kwargs – The key arguments:

Returns

The coroutine version of the function.

Return type

Awaitable

async discordSuperUtils.Base.questionnaire(ctx: commands.Context, questions: Iterable[Union[str, discord.Embed]], public: bool = False, timeout: Union[float, int] = 30, member: discord.Member = None) Tuple[List[str], bool][source]

This function is a coroutine.

Questions the member using a “quiz” and returns the answers. The questionnaire can be used without a specific member and be public. If no member was passed and the questionnaire public argument is true, a ValueError will be raised.

Raises

ValueError: The questionnaire is private and no member was provided.

Parameters
  • ctx (commands.Context) – The context (where the questionnaire will ask the questions).

  • questions (Iterable[Union[str, discord.Embed]]) – The questions the questionnaire will ask.

  • public (bool) – A bool indicating if the questionnaire is public.

  • timeout (Union[float, int]) – The number of seconds until the questionnaire will stop and time out.

  • member (discord.Member) – The member the questionnaire will get the answers from.

Returns

The answers and a boolean indicating if the questionnaire timed out.

Return type

Tuple[List[str], bool]

discordSuperUtils.Birthday module

class discordSuperUtils.Birthday.BirthdayManager(bot: discord.ext.commands.bot.Bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker

async create_birthday(member: discord.member.Member, member_birthday: float, timezone: str = 'UTC') None[source]
async get_birthday(member: discord.member.Member) Optional[discordSuperUtils.Birthday.BirthdayMember][source]
async get_members_with_birthday(timezones: List[str]) List[Dict[str, Any]][source]

This function receives a list of timezones and returns a list of members that have birthdays in that date and timezone.

Parameters

timezones

Returns

static get_midnight_timezones() List[str][source]

This method returns a list of timezones where the current time is 12 am. :return:

async get_upcoming(guild: discord.guild.Guild) List[discordSuperUtils.Birthday.BirthdayMember][source]
async on_database_connect()[source]
static round_to_nearest(timedelta_to_round)[source]

This function receives a timedelta to round to and gets the amount of seconds before that timestamp.

Parameters

timedelta_to_round

Returns

class discordSuperUtils.Birthday.BirthdayMember(birthday_manager: discordSuperUtils.Birthday.BirthdayManager, member: discord.member.Member)[source]

Bases: object

async age() int[source]
async birthday_date() datetime.datetime[source]
async delete() discordSuperUtils.Birthday.PartialBirthdayMember[source]
async set_birthday_date(timestamp: float) None[source]
async set_timezone(timezone: str) None[source]
async timezone() str[source]
class discordSuperUtils.Birthday.PartialBirthdayMember(member: discord.member.Member, birthday_date: datetime.datetime, timezone: str)[source]

Bases: object

discordSuperUtils.CommandHinter module

class discordSuperUtils.CommandHinter.CommandHinter(bot: discord.ext.commands.bot.Bot, generator=None)[source]

Bases: object

bot
property command_names: List[str]
generator
class discordSuperUtils.CommandHinter.CommandResponseGenerator[source]

Bases: abc.ABC

abstract generate(invalid_command: str, suggestions: List[str]) Union[str, discord.embeds.Embed][source]
class discordSuperUtils.CommandHinter.DefaultResponseGenerator[source]

Bases: discordSuperUtils.CommandHinter.CommandResponseGenerator

generate(invalid_command: str, suggestions: List[str]) discord.embeds.Embed[source]

discordSuperUtils.Convertors module

class discordSuperUtils.Convertors.TimeConvertor[source]

Bases: discord.ext.commands.converter.Converter

Converts a given argument to an int that represents time in seconds.

Examples

7d: 604800 (7 days in seconds)

1m: 60 (1 minute in seconds)

heyh: BadArgument (‘hey’ is not an int)

100j: BadArgument (‘j’ is not a valid time multiplier)

async convert(ctx: discord.ext.commands.context.Context, argument: str) Optional[Union[int, float]][source]

This function is a coroutine.

The method to override to do conversion logic.

If an error is found while converting, it is recommended to raise a CommandError derived exception as it will properly propagate to the error handlers.

Parameters
  • ctx (Context) – The invocation context that the argument is being used in.

  • argument (str) – The argument that is being converted.

Raises
  • CommandError – A generic exception occurred when converting the argument.

  • BadArgument – The converter failed to convert the argument.

discordSuperUtils.Convertors.isfloat(string: str) bool[source]

This function receives a string and returns if it is a float or not :param string: :return:

discordSuperUtils.Database module

class discordSuperUtils.Database.Database(database)[source]

Bases: abc.ABC

abstract async close()[source]
abstract async create_table(table_name: str, columns: Optional[Dict[str, str]] = None, exists: Optional[bool] = False)[source]
abstract async delete(table_name: str, checks: Dict[str, Any])[source]
abstract async execute(sql_query: str, values: List[Any], fetchall: bool = True) Union[List[Dict[str, Any]], Dict[str, Any]][source]
abstract async insert(table_name: str, data: Dict[str, Any])[source]
abstract async insertifnotexists(table_name: str, data: Dict[str, Any], checks: Dict[str, Any])[source]
abstract async select(table_name: str, keys: List[str], checks: Optional[Dict[str, Any]] = None, fetchall: Optional[bool] = False)[source]
abstract async update(table_name: str, data: Dict[str, Any], checks: Dict[str, Any])[source]
abstract async updateorinsert(table_name: str, data: Dict[str, Any], checks: Dict[str, Any], insert_data: Dict[str, Any])[source]
class discordSuperUtils.Database.DatabaseManager[source]

Bases: object

static connect(database)[source]
exception discordSuperUtils.Database.UnsupportedDatabase[source]

Bases: Exception

Raises error when the user tries to use an unsupported database.

async discordSuperUtils.Database.create_mysql(host, port, user, password, dbname)[source]

discordSuperUtils.Economy module

class discordSuperUtils.Economy.EconomyAccount(guild: int, member: int, database, table)[source]

Bases: object

async bank()[source]
async change_bank(amount: int)[source]
async change_currency(amount: int)[source]
async currency()[source]
async net()[source]
class discordSuperUtils.Economy.EconomyManager(bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker

async create_account(member: discord.member.Member) None[source]
static generate_checks(guild: int, member: int)[source]
async get_account(member: discord.member.Member) Optional[discordSuperUtils.Economy.EconomyAccount][source]
async get_leaderboard(guild) List[discordSuperUtils.Economy.EconomyAccount][source]

discordSuperUtils.FiveM module

class discordSuperUtils.FiveM.FiveMPlayer(player_id, identifiers, name, ping)[source]

Bases: object

classmethod fetch(player_dict)[source]
class discordSuperUtils.FiveM.FiveMServer(ip, resources, players, name, variables)[source]

Bases: object

async classmethod fetch(ip)[source]
exception discordSuperUtils.FiveM.ServerNotFound[source]

Bases: Exception

Raises an error when a server is invalid or offline.

discordSuperUtils.Imaging module

class discordSuperUtils.Imaging.Backgrounds(value)[source]

Bases: enum.Enum

An enumeration.

BLANK_GRAY = 'd:\\python\\lib\\site-packages\\discordSuperUtils\\assets\\2.png'
GALAXY = 'd:\\python\\lib\\site-packages\\discordSuperUtils\\assets\\1.png'
GAMING = 'd:\\python\\lib\\site-packages\\discordSuperUtils\\assets\\3.png'
class discordSuperUtils.Imaging.ImageManager[source]

Bases: object

async classmethod convert_image(url: str) Image[source]
async create_leveling_profile(member: discord.Member, member_account: LevelingAccount, background: Backgrounds, text_color: Tuple[int, int, int], rank: int, font_path: str = None, outline: int = 5) discord.File[source]
async create_welcome_card(member: discord.member.Member, background: discordSuperUtils.Imaging.Backgrounds, text_color: Tuple[int, int, int], title: str, description: str, font_path: Optional[str] = None, outline: int = 5, transparency: int = 0) discord.file.File[source]
async draw_profile_picture(card: Image, member: discord.Member, location: Tuple[int, int], size: int = 180, outline_thickness: int = 5, status: bool = True, outline_color: Tuple[int, int, int] = (255, 255, 255))[source]
classmethod human_format(num)[source]
static load_asset(name: str) str[source]
async static make_request(url: str) Optional[bytes][source]
async merge_image(foreground: str, background: str, blend_level: float = 0.6, discord_file: bool = True) Union[discord.File, Image][source]

Merges two images together

static multiline_text(card: ImageDraw, text: str, font: ImageFont, text_color: Tuple[int, int, int], start_height: Union[int, float], width: int)[source]

discordSuperUtils.Infractions module

class discordSuperUtils.Infractions.Infraction(database, table: str, member: discord.Member, infraction_id: str)[source]

Bases: object

An infraction object.

async datetime() Optional[datetime.datetime][source]
async delete() discordSuperUtils.Infractions.PartialInfraction[source]
async reason() Optional[str][source]
async set_reason(new_reason: str) None[source]
class discordSuperUtils.Infractions.InfractionManager(bot: commands.Bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker, discordSuperUtils.Punishments.Punisher

add_punishments(punishments: List[Punishment]) None[source]
async get_infractions(member: discord.Member, infraction_id: str = None, from_timestamp: Union[int, float] = 0) List[Infraction][source]
async punish(ctx: commands.Context, member: discord.Member, punishment: Punishment) None[source]

The manager’s punish function.

Parameters
  • ctx (commands.Context) – The context of the punishments.

  • member (discord.Member) – The member to punish.

  • punishment (Punishment) – The punishment to punish the member with.

Return type

None

Returns

None

async warn(ctx: commands.Context, member: discord.Member, reason: str) Infraction[source]
class discordSuperUtils.Infractions.PartialInfraction(member: discord.Member, infraction_id: str, reason: str, date_of_infraction: datetime)[source]

Bases: object

A partial infraction.

discordSuperUtils.InviteTracker module

” If InviteTracker is used in any way that breaks Discord TOS we, (the DiscordSuperUtils team) are not responsible or liable in any way. InviteTracker by DiscordSuperUtils was not intended to violate Discord TOS in any way. In case we are contacted by Discord, we will remove any and all features that violate the Discord ToS. Please feel free to read the Discord Terms of Service https://discord.com/terms.

class discordSuperUtils.InviteTracker.InviteAccount(invite_tracker: InviteTracker, member: discord.Member)[source]

Bases: object

async get_invited_users()[source]
class discordSuperUtils.InviteTracker.InviteTracker(bot: commands.Bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker

async fetch_inviter(invite: discord.Invite) Union[discord.Member, discord.User][source]
async get_invite(member: discord.Member) Optional[discord.Invite][source]
async get_members_invited(user: Union[discord.User, discord.Member], guild: discord.Guild)[source]
get_user_info(member: discord.Member) InviteAccount[source]
async register_invite(invite: discord.Invite, member: discord.Member, inviter: Union[discord.Member, discord.User]) None[source]

discordSuperUtils.Kick module

class discordSuperUtils.Kick.KickManager(bot: commands.Bot)[source]

Bases: discordSuperUtils.Base.EventManager, discordSuperUtils.Punishments.Punisher

A KickManager that manages kicks for guilds.

bot
async punish(ctx: commands.Context, member: discord.Member, punishment: Punishment) None[source]

The manager’s punish function.

Parameters
  • ctx (commands.Context) – The context of the punishments.

  • member (discord.Member) – The member to punish.

  • punishment (Punishment) – The punishment to punish the member with.

Return type

None

Returns

None

discordSuperUtils.Leveling module

class discordSuperUtils.Leveling.LevelingAccount(leveling_manager: LevelingManager, member: discord.Member)[source]

Bases: object

async initial_rank_xp()[source]
async level()[source]
async next_level()[source]
async percentage_next_level()[source]
async set_level(value)[source]
async set_next_level(value)[source]
async set_xp(value)[source]
async xp()[source]
class discordSuperUtils.Leveling.LevelingManager(bot, award_role: bool = False, default_role_interval: int = 5, xp_on_message=5, rank_multiplier=1.5, xp_cooldown=60)[source]

Bases: discordSuperUtils.Base.DatabaseChecker

async create_account(member)[source]
static generate_checks(member: discord.Member)[source]
async get_account(member)[source]
async get_leaderboard(guild: discord.Guild)[source]
async get_roles(guild: discord.Guild) List[int][source]

Returns the role IDs of the guild.

Parameters

guild (discord.Guild) – The guild to get the roles from.

Returns

Return type

List[int]

async on_database_connect()[source]
async set_interval(guild: discord.Guild, interval: int = None) None[source]

Set the role interval of a guild.

Parameters
  • interval (int) – The interval to set.

  • guild (discord.Guild) – The guild to set the role interval in.

Returns

Return type

None

async set_roles(guild: discord.Guild, roles: Iterable[discord.Role]) None[source]

Sets the roles of the guild.

Parameters
  • guild (discord.Guild) – The guild to set the roles in.

  • roles (Iterable[discord.Role]) – The roles to set.

Returns

Return type

None

discordSuperUtils.MessageFilter module

class discordSuperUtils.MessageFilter.DefaultMessageResponseGenerator[source]

Bases: discordSuperUtils.MessageFilter.MessageResponseGenerator

DISCORD_INVITE_RE = re.compile('(?:(?:http|https)://)?(?:www.)?(?:disco|discord|discordapp).(?:com|gg|io|li|me|net|org)(?:/(?:invite))?/([a-z0-9-.]+)')
URL_RE = re.compile('(https?://(?:www\\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|www\\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|https?://(?:www\\.|(?!www))[a-zA-Z0-9]+\\.[^\\s]{2,}|www\\.[a-zA-Z0)
generate(message: discord.Message) Union[bool, Any][source]

This function is an abstract method. The generate function of the generator.

Parameters

message (discord.Message) – The message to filter.

Returns

A boolean representing if the message contains inappropriate content.

Return type

Union[bool, Any]

class discordSuperUtils.MessageFilter.MessageFilter(bot: commands.Bot, generator: MessageResponseGenerator = None, delete_message: bool = True, wipe_cache_delay: timedelta = datetime.timedelta(seconds=300))[source]

Bases: discordSuperUtils.Base.EventManager

Represents a discordSuperUtils message filter that filters messages and finds inappropriate content.

add_punishments(punishments: List[Punishment]) None[source]
bot
generator
punishments
wipe_cache_delay
class discordSuperUtils.MessageFilter.MessageResponseGenerator[source]

Bases: abc.ABC

Represents a URL response generator that filters messages and checks if they contain URLs or anything inappropriate.

abstract generate(message: discord.Message) Union[bool, Any][source]

This function is an abstract method. The generate function of the generator.

Parameters

message (discord.Message) – The message to filter.

Returns

A boolean representing if the message contains inappropriate content.

Return type

Union[bool, Any]

discordSuperUtils.Music module

exception discordSuperUtils.Music.AlreadyConnected[source]

Bases: Exception

Raises error when client is already connected to voice

exception discordSuperUtils.Music.AlreadyPaused[source]

Bases: Exception

Raises error when player is already paused.

exception discordSuperUtils.Music.InvalidSkipIndex[source]

Bases: Exception

Raises error when the skip index is < 0

class discordSuperUtils.Music.Loops(value)[source]

Bases: enum.Enum

An enumeration.

LOOP = 1
NO_LOOP = 0
QUEUE_LOOP = 2
class discordSuperUtils.Music.MusicManager(bot: commands.Bot, spotify_support: bool = True, inactivity_timeout: int = 60, **kwargs)[source]

Bases: discordSuperUtils.Base.EventManager

Represents a MusicManager.

bot
client_id
client_secret
async create_player(query: str, requester: discord.member.Member) List[discordSuperUtils.Music.Player][source]

This function is a coroutine.

Creates a list of players from the query. This function supports Spotify and all YTDL supported links.

Parameters
  • requester (discord.Member) – The requester.

  • query (str) – The query.

Returns

The list of players.

Return type

List[Player]

async ensure_activity(ctx: commands.Context) None[source]

This function is a coroutine.

Waits the inactivity timeout and ensures the voice client in ctx is playing a song. If no song is playing, it disconnects and calls the on_inactivity_timeout event.

Parameters

ctx (commands.Context) – The context.

Returns

None

Return type

None

async static fetch_data(query: str) Optional[dict][source]

This function is a coroutine.

Fetches the YTDL data of the query.

Parameters

query (str) – The query.

Returns

The YTDL data.

Return type

Optional[dict]

async get_player_played_duration(ctx: commands.Context, player: Player) Optional[float][source]

This function is a coroutine.

Returns the played duration of a player.

Parameters
  • ctx (commands.Context) – The context.

  • player (Player) – The player.

Returns

The played duration of the player in seconds.

Return type

Optional[float]

async get_queue(ctx: commands.Context) Optional[QueueManager][source]

This function is a coroutine.

Returns the queue of ctx.

Parameters

ctx (commands.Context) – The context.

Returns

The queue.

Return type

Optional[QueueManager]

inactivity_timeout
async join(ctx: commands.Context) Optional[discord.VoiceChannel][source]

This function is a coroutine.

Joins the ctx voice channel. Calls on_music_error with AlreadyConnected or UserNotConnected.

Parameters

ctx (commands.Context) – The context.

Returns

The voice channel it joined.

Return type

Optional[discord.VoiceChannel]

async leave(ctx: commands.Context) Optional[discord.VoiceChannel][source]

This function is a coroutine.

Leaves the voice channel in ctx.

Parameters

ctx (commands.Context) – The context.

Returns

The voice channel it left.

Return type

Optional[discord.VoiceChannel]

async loop(ctx: commands.Context) Optional[bool][source]

This function is a coroutine.

Toggles the loop.

Parameters

ctx (commands.Context) – The context

Returns

A bool indicating if the loop is now enabled or disabled.

Return type

Optional[bool]

async lyrics(ctx: commands.Context, query: str = None) Optional[str][source]

This function is a coroutine.

Returns the lyrics from the query or the currently playing song.

Parameters
  • ctx (commands.Context) – The context.

  • query (str) – The query.

Returns

The lyrics.

Return type

Optional[str]

async now_playing(ctx: commands.Context) Optional[Player][source]

This function is a coroutine.

Returns the currently playing player.

Parameters

ctx (commands.Context) – The context.

Returns

The currently playing player.

Return type

Optional[Player]

async pause(ctx: commands.Context) Optional[bool][source]

This function is a coroutine.

Pauses the currently playing song in ctx. Calls on_music_error with AlreadyPaused if already paused.

Parameters

ctx (commands.Context) – The context.

Returns

A bool indicating if the pause was successful

Return type

Optional[bool]

async play(ctx: commands.Context, player: Player = None) Optional[bool][source]

This function is a coroutine.

Plays the player or the next song in the queue if the player is not passed.

Parameters
  • ctx (commands.Context) – The context.

  • player (Player) – The player.

Returns

A bool indicating if the play was successful

Return type

Optional[bool]

queue
async queue_add(players: List[Player], ctx: commands.Context) Optional[bool][source]

This function is a coroutine.

Adds a list of players to the ctx queue. If a queue does not exist in ctx, it creates one.

Parameters
  • players (List[Player]) – The list of players.

  • ctx (commands.Context) – The context.

Returns

A bool indicating if it was successful

Return type

Optional[bool]

async queue_remove(ctx: commands.Context, index: int) None[source]

This function is a coroutine.

Removes a player from the queue in ctx at the specified index. Calls on_music_error with QueueError if index is invalid.

Parameters
  • ctx (commands.Context) – The context.

  • index (int) – The index.

Returns

None

Return type

None

async queueloop(ctx: commands.Context) Optional[bool][source]

This function is a coroutine.

Toggles the queue loop.

Parameters

ctx (commands.Context) – The context

Returns

A bool indicating if the queue loop is now enabled or disabled.

Return type

Optional[bool]

async resume(ctx: commands.Context) Optional[bool][source]

This function is a coroutine.

Resumes the currently paused song in ctx. Calls on_music_error with NotPaused if not paused.

Parameters

ctx (commands.Context) – The context.

Returns

A bool indicating if the resume was successful

Return type

Optional[bool]

async skip(ctx: commands.Context, index: int = None) Optional[Player][source]

This function is a coroutine.

Skips to the index in ctx. Calls on_music_error with InvalidSkipIndex or SkipError.

Parameters
  • index (int) – The index to skip to.

  • ctx (commands.Context) – The context.

Returns

A bool indicating if the skip was successful

Return type

Optional[Player]

spotify
spotify_support
async volume(ctx: commands.Context, volume: int = None) Optional[float][source]

This function is a coroutine.

Sets the volume in ctx. Returns the current volume if volume is None.

Parameters
  • volume (int) – The volume to set.

  • ctx (commands.Context) – The context.

Returns

The new volume.

Return type

Optional[float]

exception discordSuperUtils.Music.NotConnected[source]

Bases: Exception

Raises error when client is not connected to a voice channel

exception discordSuperUtils.Music.NotPaused[source]

Bases: Exception

Raises error when player is not paused

exception discordSuperUtils.Music.NotPlaying[source]

Bases: Exception

Raises error when client is not playing

class discordSuperUtils.Music.Player(source, requester: discord.member.Member, *, data, volume=0.1)[source]

Bases: discord.player.PCMVolumeTransformer

Represents a music player.

data
duration
last_pause_timestamp
async static make_multiple_players(songs: Iterable[str], requester: discord.member.Member) List[discordSuperUtils.Music.Player][source]

This function is a coroutine.

Returns a list of players from a iterable of queries.

Parameters
  • requester (discord.Member) – The requester.

  • songs (Iterable[str]) – The queries.

Returns

The list of created players.

Return type

List[Player]

async classmethod make_player(query: str, requester: discord.member.Member, playlist: bool = True) List[discordSuperUtils.Music.Player][source]

This function is a coroutine.

Returns a list of players from the query. The list will contain the first video incase it is not a playlist.

Parameters
  • requester (discord.Member) – The requester.

  • query (str) – The query.

  • playlist (bool) – A bool indicating if the function should fetch playlists or get the first video.

Returns

The list of created players.

Return type

List[Player]

start_timestamp
stream_url
title
url
exception discordSuperUtils.Music.QueueEmpty[source]

Bases: Exception

Raises error when queue is empty

exception discordSuperUtils.Music.QueueError[source]

Bases: Exception

Raises error when something is wrong with the queue

class discordSuperUtils.Music.QueueManager(volume: float, queue: List[discordSuperUtils.Music.Player])[source]

Bases: object

add(player: discordSuperUtils.Music.Player) None[source]

Adds a player to the queue.

Parameters

player (Player) – The player to add.

Returns

None

Return type

None

clear() None[source]

Clears the queue.

Returns

None

Return type

None

history
loop
now_playing
queue
remove(index: int) Union[discordSuperUtils.Music.Player, Any][source]

Removes and element from the queue at the specified index, and returns the element’s value.

Parameters

index (int) – The index.

Returns

The element’s value

Return type

Union[Player, Any]

volume
exception discordSuperUtils.Music.SkipError[source]

Bases: Exception

Raises error when there is no song to skip to

exception discordSuperUtils.Music.UserNotConnected[source]

Bases: Exception

Raises error when user is not connected to channel

discordSuperUtils.Mute module

exception discordSuperUtils.Mute.AlreadyMuted[source]

Bases: Exception

Raises an error when a user is already muted.

class discordSuperUtils.Mute.MuteManager(bot: commands.Bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker, discordSuperUtils.Punishments.Punisher

A MuteManager that handles mutes for guilds.

bot
async static ensure_permissions(guild: discord.guild.Guild, muted_role: discord.role.Role) None[source]

This function is a coroutine.

This function loops through the guild’s channels and ensures the muted_role is not allowed to send messages or speak in that channel.

Parameters
  • guild (discord.Guild) – The guild to get the channels from.

  • muted_role (discord.Role) – The muted role.

Returns

None

async get_muted_members() List[Dict[str, Any]][source]

This function is a coroutine.

This function returns all the members that are supposed to be unmuted but are muted.

Returns

The unmuted members.

Return type

List[Dict[str, Any]]

async mute(member: discord.member.Member, reason: str = 'No reason provided.', time_of_mute: Union[int, float] = 0) None[source]

This function is a coroutine.

Mutes a member.

Raises

AlreadyMuted: The member is already muted.

Parameters
  • member (discord.Member) – The member to mute.

  • reason (str) – The reason of the mute.

  • time_of_mute (Union[int, float]) – The time of mute.

Returns

None,

Return type

None

async on_database_connect()[source]
async on_member_join(member: discord.member.Member) None[source]

This function is a coroutine.

The on_member_join event callback. Used so the member cant leave the guild, join back and be unmuted.

Parameters

member (discord.Member) – The member that joined.

Returns

None

Return type

None

async punish(ctx: commands.Context, member: discord.Member, punishment: Punishment) None[source]

The manager’s punish function.

Parameters
  • ctx (commands.Context) – The context of the punishments.

  • member (discord.Member) – The member to punish.

  • punishment (Punishment) – The punishment to punish the member with.

Return type

None

Returns

None

async unmute(member: discord.member.Member) Optional[bool][source]

This function is a coroutine.

Unmutes a member.

Parameters

member (discord.Member) – The member to unmute.

Return type

Optional[bool]

Returns

A bool indicating if the unmute was successful

discordSuperUtils.Paginator module

class discordSuperUtils.Paginator.ButtonsPageManager(ctx, messages, timeout=60, buttons=None, public=False, index=0, button_color=None)[source]

Bases: object

button_color
buttons
ctx
index
messages
public
async run()[source]
timeout
exception discordSuperUtils.Paginator.EmojiError[source]

Bases: Exception

class discordSuperUtils.Paginator.PageManager(ctx, messages, timeout=60, emojis=None, public=False, index=0)[source]

Bases: object

ctx
emojis
index
messages
public
async run()[source]
timeout
discordSuperUtils.Paginator.generate_embeds(list_to_generate, title, description, fields=25, color=16711680, string_format='{}')[source]

discordSuperUtils.Prefix module

class discordSuperUtils.Prefix.PrefixManager(bot: discord.ext.commands.bot.Bot, default_prefix: str, mentioned: bool = False)[source]

Bases: discordSuperUtils.Base.DatabaseChecker

async get_prefix(guild: Union[discord.guild.Guild, Any]) str[source]
async set_prefix(guild: discord.guild.Guild, prefix: str) None[source]

discordSuperUtils.Punishments module

class discordSuperUtils.Punishments.Punisher[source]

Bases: abc.ABC

abstract async punish(ctx: commands.Context, member: discord.Member, punishment: Punishment) None[source]

The manager’s punish function.

Parameters
  • ctx (commands.Context) – The context of the punishments.

  • member (discord.Member) – The member to punish.

  • punishment (Punishment) – The punishment to punish the member with.

Return type

None

Returns

None

class discordSuperUtils.Punishments.Punishment(punishment_manager, punish_after: int = 3, punishment_reason: str = 'No reason specified.', punishment_time: datetime.timedelta = datetime.timedelta(days=1))[source]

Bases: object

A punishment class that is used for punishing members.

discordSuperUtils.Punishments.get_relevant_punishment(punishments: List[discordSuperUtils.Punishments.Punishment], punish_count: int) Optional[discordSuperUtils.Punishments.Punishment][source]

Returns the punishment that is suitable for the punish count.

Parameters
  • punishments (List[Punishment]) – The punishments to pick from.

  • punish_count (int) – The punishment count.

Return type

Optional[Punishment]

Returns

The suitable punishment.

discordSuperUtils.ReactionRoles module

class discordSuperUtils.ReactionRoles.ReactionManager(bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker

async create_reaction(guild, message, role, emoji, remove_on_reaction: int)[source]
async delete_reaction(guild, message, emoji)[source]
static get_emoji_sql(emoji)[source]
async get_reactions(guild=None)[source]
async on_database_connect()[source]

discordSuperUtils.Spotify module

class discordSuperUtils.Spotify.SpotifyClient(client_id: str, client_secret: str, loop=None)[source]

Bases: object

async fetch_full_playlist(url: str) List[Dict[str, dict]][source]

This function receives a url and returns all the tracks in that URL.

Parameters

url

Returns

async fetch_playlist_data(url: str, offset: int) Dict[str, Union[int, list]][source]

This function receives a URL and an offset and returns 100 tracks from that offset Example: Offset: 50, the URL has 160 tracks, returns tracks from 50-150 (limit is 100).

Parameters
  • url

  • offset

Returns

async get_songs(url: str) List[str][source]

This function receives a URL and returns all the tracks in that URL.

Parameters

url

Returns

static get_type(url: str) Optional[str][source]

This function receives a url and returns the type of the URL. Return examples: playlist, user, album, etc.

Parameters

url

Returns

static make_title(song: Dict[str, dict]) str[source]

This function receives a song and creates a title that can be used for youtube_dl searching. Return example: Never Gonna Give You Up by Rick Astley

Parameters

song

Returns

discordSuperUtils.Template module

class discordSuperUtils.Template.DictionaryConvertible[source]

Bases: abc.ABC

abstract classmethod from_dict(convert_from: Dict[str, Any]) discordSuperUtils.Template.DictionaryConvertible[source]
class discordSuperUtils.Template.PartialTemplate(info: discordSuperUtils.Template.TemplateInfo, categories: List[discordSuperUtils.Template.TemplateCategory], text_channels: List[discordSuperUtils.Template.TemplateTextChannel], voice_channels: List[discordSuperUtils.Template.TemplateVoiceChannel], roles: List[discordSuperUtils.Template.TemplateRole])[source]

Bases: object

categories
info
roles
text_channels
voice_channels
class discordSuperUtils.Template.Template(database: Database, tables: Dict[str, str], info: TemplateInfo, categories: List[TemplateCategory], text_channels: List[TemplateTextChannel], voice_channels: List[TemplateVoiceChannel], roles: List[TemplateRole])[source]

Bases: object

async apply(guild: discord.guild.Guild) None[source]
async apply_categories(guild: discord.guild.Guild, reason: str) Dict[int, discord.channel.CategoryChannel][source]
async apply_channels(guild: discord.guild.Guild, reason: str, categories: Dict[int, discord.channel.CategoryChannel], roles: Dict[int, discord.role.Role]) Dict[int, discord.channel.TextChannel][source]
async apply_roles(guild: discord.guild.Guild, reason: str) Dict[int, discord.role.Role][source]
async apply_settings(guild: discord.guild.Guild, reason: str, channels: Dict[int, Union[discord.channel.VoiceChannel, discord.channel.TextChannel]]) None[source]
async apply_voice_channels(guild: discord.guild.Guild, reason: str, categories: Dict[int, discord.channel.CategoryChannel], roles: Dict[int, discord.role.Role]) Dict[int, discord.channel.VoiceChannel][source]
categories
database
async delete() discordSuperUtils.Template.PartialTemplate[source]
static format_overwrites(overwrites: Dict[int, discord.permissions.PermissionOverwrite], roles: Dict[int, discord.role.Role]) Dict[discord.role.Role, discord.permissions.PermissionOverwrite][source]
static get_overwrite(overwrites: List[Dict[str, Any]], overwrite_object: int) Dict[int, discord.permissions.PermissionOverwrite][source]
async classmethod get_template(database: Database, tables: Dict[str, str], template_id: str) Optional[Template][source]
info
roles
tables
text_channels
voice_channels
class discordSuperUtils.Template.TemplateCategory(name: str, position: int, category_id: int, overwrites: Dict[int, int])[source]

Bases: discordSuperUtils.Template.DictionaryConvertible

category_id
classmethod from_dict(convert_from: Dict[Any, Any]) discordSuperUtils.Template.TemplateCategory[source]
name
overwrites
position
class discordSuperUtils.Template.TemplateInfo(template_id: str, guild: int, afk_timeout: int, mfa_level: int, verification_level: discord.enums.VerificationLevel, explict_content_filter: int, system_channel: int, afk_channel: int)[source]

Bases: discordSuperUtils.Template.DictionaryConvertible

afk_channel
afk_timeout
explict_content_filter
classmethod from_dict(convert_from: Dict[str, Any]) discordSuperUtils.Template.TemplateInfo[source]
guild
mfa_level
system_channel
template_id
verification_level
class discordSuperUtils.Template.TemplateManager(bot: commands.Bot)[source]

Bases: discordSuperUtils.Base.DatabaseChecker

bot
async create_template(guild: discord.guild.Guild) discordSuperUtils.Template.Template[source]
async get_template(template_id: str) Optional[discordSuperUtils.Template.Template][source]
async get_templates(guild: Optional[discord.guild.Guild] = None) List[discordSuperUtils.Template.Template][source]
async write_overwrites(template_id: str, overwrites_object: int, overwrites: discord.permissions.PermissionOverwrite) None[source]
class discordSuperUtils.Template.TemplateRole(default_role: bool, name: str, color: int, hoist: bool, position: int, mentionable: bool, role_id: int, permissions: discord.permissions.Permissions)[source]

Bases: discordSuperUtils.Template.DictionaryConvertible

color
default_role
classmethod from_dict(convert_from: Dict[str, Any]) discordSuperUtils.Template.TemplateRole[source]
get_raw()[source]
hoist
mentionable
name
permissions
position
role_id
class discordSuperUtils.Template.TemplateTextChannel(name: str, position: int, category: int, topic: str, slowmode: int, nsfw: bool, channel_id: int, overwrites: Dict[int, discord.permissions.PermissionOverwrite])[source]

Bases: discordSuperUtils.Template.DictionaryConvertible

category
channel_id
classmethod from_dict(convert_from: Dict[str, Any]) discordSuperUtils.Template.TemplateTextChannel[source]
name
nsfw
overwrites
position
slowmode
topic
class discordSuperUtils.Template.TemplateVoiceChannel(name: str, position: int, category: int, bitrate: int, user_limit: int, channel_id: int, overwrites: Dict[int, discord.permissions.PermissionOverwrite])[source]

Bases: discordSuperUtils.Template.DictionaryConvertible

bitrate
category
channel_id
classmethod from_dict(convert_from: Dict[str, Any]) discordSuperUtils.Template.TemplateVoiceChannel[source]
name
overwrites
position
user_limit

discordSuperUtils.Youtube module