class EventColors(Enum): ban = Colour.dark_red() unban = Colour.teal() kick = Colour.red() join = Colour.dark_green() leave = Colour.blue() delete = Colour.magenta() bulk_delete = Colour.dark_magenta() edit = Colour.gold() name_change = Colour.purple() nickname_change = Colour.blurple() role_added = Colour.dark_teal() role_removed = Colour.orange() verified = Colour.light_grey()
# coding=utf-8 import datetime from discord import TextChannel, Guild, Embed, HTTPException, Member from discord.colour import Colour from discord.ext.commands import AutoShardedBot, Context, group, guild_only, has_permissions from peewee import DoesNotExist from smithy.constants import NOTE_CLOSED, NOTE_OPEN, NOTE_RESOLVED from smithy.database import manager, DBServer, Note __author__ = "Gareth Coles" CLOSED_COLOUR = Colour.red() OPEN_COLOR = Colour.blurple() RESOLVED_COLOUR = Colour.green() class Notes: """ In-channel notes """ def __init__(self, bot: AutoShardedBot): self.bot = bot @group(invoke_without_command=True, aliases=["note"]) async def notes(self, ctx: Context): """ In-channel notes management """ await ctx.invoke(self.bot.get_command("help"), "notes")
class Track(PCMVolumeTransformer): length = 0 requester = None _embed_colour = Colour.blurple() _track_type = 'Track' def __init__( self, source, config: SubRedis, volume: float = 0.15, requester: Optional[User] = None, **kwargs ): if not volume: volume = float(config.hget("config:defaults", "volume")) super().__init__(FFmpegPCMAudio(source, **kwargs), volume) self.requester = requester self._frames = 0 def read(self): self._frames += 1 return super().read() @property def play_time(self) -> int: """Returns the current track play time in seconds.""" return round(self._frames / 50) @property def information(self) -> str: """Provides basic information on a track An example of this would be the title and artist. """ return self._track_type @property def status_information(self) -> str: """Provides basic information on a track for use in the discord status section An example of this would be the title and artist. """ return self._track_type @property def playing_message(self) -> Dict[str, Embed]: """A discord embed with more detailed information to be displayed when a track is playing.""" em = Embed( colour=self._embed_colour, description=self.information ) return {'embed': em} @property def request_message(self) -> Dict[str, Embed]: """A discord Embed with basic information to be displayed when a track is requested.""" em = Embed( colour=self._embed_colour, description=f'Adding {self.information} to the queue...' ) em.set_author(name=f'{self._track_type} - Requested by {self.requester}') return {'embed': em} # @classmethod # async def convert(cls, ctx: Converter, argument: str): # raise NotImplementedError @classmethod async def get_user_choice(cls, ctx: Context, search_query: str, entries: List[Tuple[str]]) -> int: em = Embed(colour=cls._embed_colour,) em.set_author(name=f'{cls._track_type} search results - {search_query} - Requested by {ctx.author}') for index, entry in enumerate(entries, 1): em.add_field( name=f'{index} - {entry[0]}', value=entry[1], inline=False) search_message = await ctx.send(embed=em) ensure_future(add_numeric_reactions(search_message, len(entries))) def check(react: Reaction, user: User): return any(( react.message.id == search_message.id, user == ctx.author, react.emoji in (numeric_emoji(n) for n in range(1, 1+len(entries))) )) try: reaction, _ = await ctx.bot.wait_for('reaction_add', check=check, timeout=60) except TimeoutError: raise BadArgument("You did not choose a search result in time.") await search_message.delete() return int(reaction.emoji[0]) - 1