from discord.ext import commands
import os
import traceback
import random

bot = commands.Bot(command_prefix='!')
token = os.environ['DISCORD_BOT_TOKEN']

f = open('buki.txt', 'r')

datalist = f.readlines().split()

f.close()

@bot.event
async def on_command_error(ctx, error):
    orig_error = getattr(error, "original", error)
    error_msg = ''.join(traceback.TracebackException.from_exception(orig_error).format())
    await ctx.send(error_msg)


@bot.command()
async def ping(ctx):
    await ctx.send('pong')
    
@bot.command()
async def buki(ctx):
    await ctx.send('あなたのブキは'+ random.choice(datalist) + 'です！')
    
@bot.command()
async def buki(ctx,arg1):
    await ctx.send('あなたのブキは'+ random.sample(datalist,arg1) + 'です！')

bot.run(token)
