Example #1
0
import datadog
import discord
import psutil
from discord.ext import commands
from dotenv import find_dotenv, load_dotenv
from motor.motor_asyncio import AsyncIOMotorClient

from ext import utils
from ext.context import CustomContext
from ext.view import CustomView
from ext.command import command
from ext.utils import InvalidPlatform, InvalidBSTag, InvalidTag, NoTag, APIError
from ext.log import LoggingHandler
from locales.i18n import Translator

_ = Translator('Core', __file__)


class Statsy(commands.AutoShardedBot):
    """Custom client for statsy made by Kyber"""
    emoji_servers = [
        376364364636094465, 376368487037140992, 376364990023729152,
        377742732501843968, 376365022752014345, 386872710225068042,
        389369383639842817, 390674234239746055, 454111856983015424,
        454113083217149972, 454117186823258112, 521586528909000744
    ]

    developers = [325012556940836864, 180314310298304512, 273381165229146112]

    def __init__(self):
        super().__init__(case_insensitive=True, command_prefix=None)
Example #2
0
import discord
import requests
from cachetools import TTLCache
from discord.ext import commands
from oauth2client.service_account import ServiceAccountCredentials
from pymongo import ReturnDocument

from ext import utils
from ext.context import NoContext
from ext.command import cog, command, group
from ext.utils import e
from ext.embeds import clashroyale as cr
from ext.paginator import Paginator
from locales.i18n import Translator

_ = Translator('Clash Royale', __file__)

shortcuts = {
    # stus army
    'SA1': '88PYQV',
    'SA2': '29UQQ282',
    'SA3': '28JU8P0Y',
    'SA4': '8PUUGRYG',
    # underbelly
    'UNDERBELLY': '2J8UVG99',
    # dat banana boi
    'BANANA': '9Y0CVVL2',
    # the reapers
    'VOIDR': '9L2PLGRR',
    'FLAMER': '22UY8R9Q',
    'ICYR': 'CJCRRCR',
Example #3
0
import textwrap
import traceback
from contextlib import redirect_stdout

import datadog
import discord
import psutil
from discord.ext import commands

from ext import utils
from ext.command import command
from ext.paginator import Paginator

from locales.i18n import Translator

_ = Translator('Utils', __file__)


class Bot_Related:
    """Commands that pertain to bot utility."""
    def __init__(self, bot):
        self.bot = bot

    @utils.developer()
    @command(hidden=True)
    async def psa(self, ctx, *, message):
        em = discord.Embed(color=0xf9c93d)
        em.title = 'Created Announcement'
        em.description = message

        if message.lower() in 'clearnone':
Example #4
0
import datetime

import discord

from ext.utils import e, random_color
from locales.i18n import Translator

_ = Translator('FN Embeds', __file__)


def timestamp(minutes):
    return str(datetime.timedelta(minutes=minutes))[:-3]


async def format_profile(ctx, platform, p):
    ems = []
    top = {'solo': (10, 25), 'duo': (5, 12), 'squad': (3, 6)}

    if p['totals']['matchesplayed']:
        kdr = p['totals']['wins'] / p['totals']['matchesplayed'] * 100
    else:
        kdr = 0

    fields = [(_('Kills {}').format(e("fnskull")), p['totals']['kills']),
              (_('Victory Royale! {}').format(e("fnvictoryroyale")),
               f"{p['totals']['wins']} ({kdr:.2f})"),
              (_('Kill Death Ratio'), p['totals']['kd']),
              (_('Time Played'), timestamp(p['totals']['minutesplayed']))]

    ems.append(
        discord.Embed(description=_('Overall Statistics'),
Example #5
0
import datadog
import discord
import requests
from box import Box
from cachetools import TTLCache
from discord.ext import commands

import box
from ext import utils
from ext.command import cog, command
from ext.embeds import brawlstars
from ext.paginator import Paginator
from locales.i18n import Translator

_ = Translator('Brawl Stars', __file__)

shortcuts = {
    'juice': '2PP00',
    'pulp': 'PY9JLV'
}


class TagCheck(commands.MemberConverter):

    check = 'PYLQGRJCUV0289'

    def resolve_tag(self, tag):
        if tag in shortcuts:
            tag = shortcuts[tag]
        tag = tag.strip('#').upper().replace('O', '0')
Example #6
0
import datetime
import math
import re
import asyncio

import discord

from ext.utils import e, random_color, asyncexecutor
from locales.i18n import Translator

import io
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont

_ = Translator('CR Embeds', __file__)

images = 'https://royaleapi.github.io/cr-api-assets/cards-png8'


def camel_case(text):
    # from stackoverflow :p
    if text in (None, 'PvP'):
        return text
    matches = re.finditer(
        '.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)', text)
    return ' '.join(m.group(0) for m in matches).title()


def get_card_level(card):
Example #7
0
import os
from urllib.parse import urlencode

import aiohttp
import datadog
import discord
from discord.ext import commands

from ext import utils
from ext.embeds import fortnite
from ext.paginator import Paginator

from ext.command import cog, command
from locales.i18n import Translator

_ = Translator('Fortnite', __file__)


class TagOrUser(commands.MemberConverter):
    async def convert(self, ctx, argument):
        try:
            return await super().convert(ctx, argument)
        except commands.BadArgument:
            return argument


def lower(argument):
    return argument.lower()


@cog('fn')
Example #8
0
import copy
import io
import math
from datetime import datetime

import box
import discord

from ext.utils import e, get_datetime, random_color
from locales.i18n import Translator

_ = Translator('BS Embeds', __file__)

url = 'https://fourjr.github.io/bs-assets'


def format_timestamp(seconds: int):
    minutes = max(math.floor(seconds / 60), 0)
    seconds -= minutes * 60
    hours = max(math.floor(minutes / 60), 0)
    minutes -= hours * 60
    days = max(math.floor(hours / 60), 0)
    hours -= days * 60
    timeleft = ''
    if days > 0:
        timeleft += f'{days}d'
    if hours > 0:
        timeleft += f' {hours}h'
    if minutes > 0:
        timeleft += f' {minutes}m'
    if seconds > 0:
Example #9
0
import os

import aiohttp
import datadog
import discord
from cachetools import TTLCache
from discord.ext import commands
from PIL import Image

from ext import utils
from ext.command import cog, command, group
from ext.embeds import clashofclans
from ext.paginator import Paginator
from locales.i18n import Translator

_ = Translator('Clash of Clans', __file__)

shortcuts = {}


class TagCheck(commands.UserConverter):

    check = 'PYLQGRJCUV0289'

    def resolve_tag(self, ctx, tag):
        if tag.startswith('-'):
            try:
                index = int(tag.replace('-', ''))
            except ValueError:
                pass
            else:
Example #10
0
from discord.ext import commands

from locales.i18n import Translator

_ = Translator('Command Handler', __file__)


class StatsyCommand(commands.Command):

    def short_doc(self, ctx):
        """Overwrites default to use translations"""
        return _(super().short_doc)


class StatsyGroup(commands.Group):

    def short_doc(self, ctx):
        """Overwrites default to use translations"""
        return _(super().short_doc)

    def command(self, *args, **kwargs):
        """Overwrites GroupMixin.command to use StatsyCommand"""
        def decorator(func):
            result = command(*args, **kwargs)(func)
            self.add_command(result)
            return result

        return decorator


def command(**attrs):