Ejemplo n.º 1
0
async def show_me(context):
    discord_id = context.message.author.id
    author = context.message.author.mention

    giftee_key = queries.get_user_key(discord_id)

    if not giftee_key:
        await context.send(messages.not_a_giftee(author))
        return

    message = queries.process_giftee_to_message(giftee_key)
    await context.send(author + message)
Ejemplo n.º 2
0
async def add_wish(context, *args):
    message = ' '.join(args)
    discord_id = context.message.author.id
    author = context.message.author.mention

    user_key = queries.get_user_key(discord_id)
    if not user_key:
        await context.send(messages.not_a_giftee(author))
        return

    name, url = message.split(maxsplit=1)
    queries.save_wish(name, url, user_key)
    await context.send(messages.wish_success(author, name, url))
Ejemplo n.º 3
0
async def update_address(context, *args):
    discord_id = context.message.author.id
    author = context.message.author.mention

    if not queries.get_user_key(discord_id):
        await context.send(messages.not_a_giftee(author))
        return

    if len(args) == 0:
        await context.send(messages.address_empty(author))
        return

    address = ' '.join(args)

    queries.update_address(address, discord_id)
    await context.send(messages.address_success(author, address))
Ejemplo n.º 4
0
async def leave(context):
    discord_id = context.message.author.id
    author = context.message.author.mention

    if DEADLINE <= datetime.datetime.now():
        await context.send(messages.past_deadline(author))
        return

    giftee_key = queries.get_user_key(discord_id)

    if not giftee_key:
        await context.send(messages.not_a_giftee(author))
        return

    queries.delete_giftee(giftee_key)
    await context.send(messages.leave_success(author))
Ejemplo n.º 5
0
async def show_giftee(context):
    discord_id = context.message.author.id
    author = context.message.author.mention

    if not context.channel.type == discord.ChannelType.private:
        await context.send(messages.not_private_chat(author))
        await context.send(messages.dm_bot(bot.user.mention))
        return

    giftee_key = queries.get_user_key(discord_id)

    if not giftee_key:
        await context.send(messages.not_a_giftee(author))
        return

    message = queries.process_giftee_to_message(giftee_key)
    await context.send(author + message)
Ejemplo n.º 6
0
async def update_nationality(context, *args):
    country = ' '.join(args).lower()
    discord_id = context.message.author.id
    author = context.message.author.mention

    if not queries.get_user_key(discord_id):
        await context.send(messages.not_a_giftee(author))
        return

    if not queries.check_nationality(country):
        await context.send(
            'Invalid country. Please refer to the file attached.',
            file=discord.File(COUNTRIES_TXT_FILE, filename='countries.txt'))
        return

    countries = queries.get_countries()
    queries.update_nationality(countries[country], discord_id)

    await context.send(messages.nationality_success(author, country))