1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

discord.pyで大きいログを出力する

Posted at

discordでは1回のメッセージは2KBです
botでの動作ログを見たいときはメッセージとして出すと送れないかもしれません。

そこで、テキストファイルとしてbotにアップロードしてもらうと便利です。

@client.event
async def on_message(message):

   if message.content = 'log':
       log = ''

       #適当にログを組み立てる
       for d in data:
           log += d + '\n'

       with StringIO(log) as bs:
           await message.channel.send(file=discord.File(bs, 'log.txt'))
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?