Esempio n. 1
0
async def clean(ctx, number):
    number = int(number)
    count = 0
    async for msg in Messageable.history(ctx.message.channel, limit=number):
        await message.Message.delete(msg)
        count = count + 1
    await ctx.send("{} messages cleared!".format(count))
Esempio n. 2
0
async def purge(ctx, number):
    number = int(number)
    async for x in Messageable.history(ctx.message.channel, limit=number):
        if x.author == client.user:
            await x.delete()
            print(f'deleted {x.content}')
    print('done purging')
Esempio n. 3
0
async def post_cards(
        client: Client,
        cards: List[Card],
        channel: Messageable,
        replying_to: Optional[Member] = None,
        additional_text: str = '',
) -> None:
    if len(cards) == 0:
        await post_no_cards(channel, replying_to)
        return
    not_pd = configuration.get_list('not_pd')
    disable_emoji = str(channel.id) in not_pd or (getattr(channel, 'guild', None) is not None and str(channel.guild.id) in not_pd)
    cards = uniqify_cards(cards)
    if len(cards) > MAX_CARDS_SHOWN:
        cards = cards[:DEFAULT_CARDS_SHOWN]
    if len(cards) == 1:
        text = single_card_text_internal(client, cards[0], disable_emoji)
    else:
        text = ', '.join('{name} {legal} {price}'.format(name=card.name, legal=((emoji.info_emoji(card)) if not disable_emoji else ''), price=((card_price.card_price_string(card, True)) if card.get('mode', None) == '$' else '')) for card in cards)
    if len(cards) > MAX_CARDS_SHOWN:
        image_file = None
    else:
        with channel.typing():
            image_file = await image_fetcher.download_image_async(cards)
    if image_file is None:
        text += '\n\n'
        if len(cards) == 1:
            text += emoji.replace_emoji(cards[0].oracle_text, client)
        else:
            text += 'No image available.'
    text += additional_text
    if image_file is None:
        await send(channel, text)
    else:
        await send_image_with_retry(channel, image_file, text)
Esempio n. 4
0
async def clear(ctx, broj):
    broj = int(broj)
    counter = 0
    async for x in Messageable.history(ctx.message.channel, limit = broj):
        if counter < broj:
            await discord.Message.delete(x)
            counter += 1
Esempio n. 5
0
    async def _roll_skill(self, channel: Messageable, author: Member,
                          skill_name: str):
        async with channel.typing():
            server = str(channel.guild.id)
            campaign = channel.name

            d1 = random.randint(1, 6)
            d2 = random.randint(1, 6)

            user_name = author.name
            user_id = author.id
            try:
                characters = self.sheet.get_characters(server, campaign)
            except SheetsEngine.SheetNotSetError:
                await channel.send(
                    f"No Google Sheets spreadsheet was configured.")
                return
            except SheetsEngine.SheetNotAuthorizedError:
                await channel.send(
                    f"A Google Sheets spreadsheet was specified, but it was not authorized. Did you forget to pass the token?"
                )
                return
            except SheetsEngine.SheetAuthorizationExpiredError:
                await channel.send(
                    f"The authentication for the spreadsheet has expired, try authenticating it again."
                )
                return
            except:
                await channel.send(
                    f"An error has occurred. Is `{campaign}` a valid campaign sheet?"
                )
                return

        if user_name not in characters:
            await channel.send(f"<@{user_id}> does not have a character.")
            return

        character = characters[user_name]

        if skill_name not in character["skills"]:
            await channel.send(f"`{skill_name}` is not a valid skill.")
            return

        skill = character["skills"][skill_name]
        total = d1 + d2 + skill

        await self.check_critical(d1, d2, channel)
        await channel.send(
            f"<@{user_id}> rolled:\n{numbers[d1]} {numbers[d2]} + {skill} ({skill_name}) = **{total}**"
        )
Esempio n. 6
0
async def show_board(ctx):
    '''
    Prints the current board to the channel if there is a game running
    :param ctx:
    :return:
    '''
    global last_image
    if white is None and black is None:
        await ctx.channel.send('No game is currently running')
        return
    bg.generate_board(board)

    if turn:
        await ctx.channel.send(file=discord.File('chessboard.png'))
    else:
        await ctx.channel.send(file=discord.File('chessboard_flipped.png'))

    if last_image is not None:
        await last_image.delete()

    async for x in Messageable.history(ctx.message.channel, limit=1):
        last_image = x
Esempio n. 7
0
def get_message(id):
    data = Messageable.fetch_message(id)
    return data