Beispiel #1
0
async def ping(ctx):
    random.seed(ctx.author.id)
    r = lambda: random.randint(0, 255)
    rgb = (r(), r(), r())
    desc = f"Pong ! {round(bot.latency * 1000)} ms"
    embed = discord.Embed(description=desc, color=Color.from_rgb(*rgb))
    embed.set_footer(text=f"Requested by {ctx.author}")
    await ctx.send(embed=embed)
Beispiel #2
0
async def totem(ctx, user: discord.User = None):
    guild = db.find_guild(ctx.guild)
    if guild:
        lang = pokedex.Language(guild['lang'])
    else:
        lang = pokedex.Language.DEFAULT
        db.update_guild(ctx.guild, lang=lang.value, name=ctx.guild.name)

    user = user or ctx.author
    user_db = db.find_user(user)
    settings = db.get_settings()
    rc = user_db['reroll_count'] if user_db else 0
    global_rc = settings['global_rc'] if settings else 100

    random.seed(user.id + rc + global_rc)
    head = str(random.randint(pokedex.Pokedex.MIN_ID, pokedex.Pokedex.MAX_ID))
    body = str(random.randint(pokedex.Pokedex.MIN_ID, pokedex.Pokedex.MAX_ID))
    color = str(random.randint(pokedex.Pokedex.MIN_ID, pokedex.Pokedex.MAX_ID))
    head_id, head = dex.resolve(head, lang)
    body_id, body = dex.resolve(body, lang)
    color_id, color = dex.resolve(color, lang)
    last_queries[ctx.message.channel] = head, body, color

    file = api.PokeFusion.get_fusion_as_file(head_id=head_id,
                                             body_id=body_id,
                                             color_id=color_id)
    if file:
        if color_id == "0":
            filename = f"fusion_{head_id}{head}_{body_id}{body}.png"
        else:
            filename = f"fusion_{head_id}{head}_{body_id}{body}_{color_id}{color}.png"
        f = discord.File(fp=file, filename=filename)
        c = Color.from_rgb(*utils.get_dominant_color(file))
        share_url = f"http://pokefusion.japeal.com/{body_id}/{head_id}/{color_id}"
        embed = discord.Embed(title=f"{user.display_name}'s totem",
                              url=share_url,
                              color=c)
        embed.set_thumbnail(url=user.avatar_url)
        embed.add_field(name="Head",
                        value=f"{head.title()} #{head_id}",
                        inline=True)
        embed.add_field(name="Body",
                        value=f"{body.title()} #{body_id}",
                        inline=True)
        if color_id != "0":
            embed.add_field(name="Colors",
                            value=f"{color.title()} #{color_id}")
        embed.set_image(
            url=f"attachment://{filename.replace('(', '').replace(')', '')}")
        embed.set_footer(text=f"Requested by {ctx.author}")
        await ctx.send(embed=embed, file=f)
Beispiel #3
0
async def pokemon(ctx, pkmn="random"):
    guild = db.find_guild(ctx.guild)
    if guild:
        lang = pokedex.Language(guild['lang'])
    else:
        lang = pokedex.Language.DEFAULT
        db.update_guild(ctx.guild, lang=lang.value, name=ctx.guild.name)
    result = dex.resolve(pkmn, lang)
    if result:
        dex_num, pkmn = result
        file = api.PokeFusion.get_sprite_as_file(pkmn_id=dex_num)
        filename = f"sprite_{dex_num}_{pkmn}.png"
        f = discord.File(fp=file, filename=filename)
        color = Color.from_rgb(*utils.get_dominant_color(file))
        embed = discord.Embed(title=f"{pkmn.title()} #{dex_num}", color=color)
        embed.set_image(
            url=f"attachment://{filename.replace('(', '').replace(')', '')}")
        embed.set_footer(text=f"Requested by {ctx.author}")
        await ctx.send(embed=embed, file=f)
Beispiel #4
0
async def fusion(ctx, head="?", body="?", color="0"):
    guild = db.find_guild(ctx.guild)
    if guild:
        lang = pokedex.Language(guild['lang'])
    else:
        lang = pokedex.Language.DEFAULT
        db.update_guild(ctx.guild, lang=lang.value, name=ctx.guild.name)

    head_result = dex.resolve(head, lang)
    body_result = dex.resolve(body, lang)
    color_result = dex.resolve(color, lang) if color != "0" else (color, "")
    if None in (head_result, body_result, color_result):
        head_guess = dex.guess(head, lang)[0] if head_result is None else head
        body_guess = dex.guess(body, lang)[0] if body_result is None else body
        color_guess = dex.guess(color,
                                lang)[0] if color_result is None else color
        body_tmp = body_guess
        color_tmp = color_guess if color_guess != "0" else ""
        if body_tmp in pokedex.Pokedex.RANDOM_QUERIES and not color_tmp:
            body_tmp = ""
        cmd = utils.strict_whitespace(
            f"**{bot.command_prefix}f {head_guess} {body_tmp} {color_tmp}**")
        desc = f"Did you mean   {cmd}   ?\n\nType **yes** to proceed, or **no** to cancel."
        embed = discord.Embed(description=desc, color=Color.light_grey())
        embed.set_thumbnail(url="https://i.imgur.com/Rcys72H.png")
        embed.set_footer(text=f"Requested by {ctx.author}")
        await ctx.send(embed=embed)
        check = lambda m: m.author == ctx.author and m.channel == ctx.channel and utils.yes_or_no(
            m.content)
        try:
            reply = await bot.wait_for("message", check=check, timeout=60)
        except asyncio.TimeoutError:
            pass
        else:
            if reply.content.lower() == "yes":
                await ctx.invoke(fusion,
                                 head=head_guess,
                                 body=body_guess,
                                 color=color_guess)
    else:
        h_id, h = head_result
        b_id, b = body_result
        c_id, c = color_result
        last_queries[ctx.message.channel] = h_id, b_id, c_id

        file = api.PokeFusion.get_fusion_as_file(head_id=h_id,
                                                 body_id=b_id,
                                                 color_id=c_id)
        if file:
            if c_id == "0":
                filename = f"fusion_{h_id}{h}_{b_id}{b}.png"
            else:
                filename = f"fusion_{h_id}{h}_{b_id}{b}_{c_id}{c}.png"
            f = discord.File(fp=file, filename=filename)
            color = Color.from_rgb(*utils.get_dominant_color(file))
            share_url = f"http://pokefusion.japeal.com/{b_id}/{h_id}/{c_id}"
            embed = discord.Embed(title="PokéFusion",
                                  url=share_url,
                                  color=color)
            embed.add_field(name="Head",
                            value=f"{h.title()} #{h_id}",
                            inline=True)
            embed.add_field(name="Body",
                            value=f"{b.title()} #{b_id}",
                            inline=True)
            if c_id != "0":
                embed.add_field(name="Colors", value=f"{c.title()} #{c_id}")
            embed.set_image(
                url=f"attachment://{filename.replace('(', '').replace(')', '')}"
            )
            embed.set_footer(text=f"Requested by {ctx.author}")
            await ctx.send(embed=embed, file=f)
Beispiel #5
0
# Set up Intents
intents = discord.Intents.all()
bot = Bot(command_prefix='!', intents=intents)
EEMSG = 789236911364505600
CPEMSG = 789236918872703018
CSMSG = 789236932693459014
COLORMSG = 789281035657412619
SDMSG = 789241290411868170
WELCOME = 694552494172536833

Color_Emoji = {
    "<:invisible:789271633343807488>": ["invisible",
                                        Color.dark_theme()],
    "<:greyple:789271633352589352>": ["greyple", Color.greyple()],
    "<:white:789271633360977960>": ["white",
                                    Color.from_rgb(255, 255, 255)],
    "<:teal:789271633373298718>": ["teal", Color.teal()],
    "<:darkteal:789271633356521473>": ["darkteal",
                                       Color.dark_teal()],
    "<:darkgreen:789271633336205342>": ["darkgreen",
                                        Color.dark_green()],
    "<:blurple:789271633356783666>": ["blurple", Color.blurple()],
    "<:darkblue:789271633373954048>": ["darkblue",
                                       Color.dark_blue()],
    "<:darkpurple:789271633386405908>": ["darkpurple",
                                         Color.dark_purple()],
    "<:purple:789271633436737586>": ["purple", Color.purple()],
    "<:darkorange:789271633332142091>": ["darkorange",
                                         Color.dark_orange()],
    "<:gold:789271633415503902>": ["gold", Color.gold()],
}
# coding=utf-8
import logging
import sys

from discord.colour import Color
from sqlalchemy.ext.declarative import declarative_base

# MAIN
VERSION = '5.2.2'
BOT_PREFIX = ',,'
DESCRIPTION = 'The only custom reaction bot you\'ll ever need'
BOT_MENTION_URL = '@386627978618077184'
EMBED_COLOR = Color.from_rgb(253, 4, 91)

# GAME
DELETE_TIME = 15

# Reactions
INVISIBLE_CHAR = ' ̷̧̟̭̺͕̜̦̔̏̊̍ͧ͊́̚̕͞'

# SQLAlchemy
BASE = declarative_base()

# Logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
formatter = logging.Formatter('[%(asctime)s][%(levelname)s] - %(message)s')
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
logger.addHandler(handler)