0
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 5 years have passed since last update.

Discord.pyがrewriteが主流になってきたので初心者用コードを書いてみる。

Last updated at Posted at 2018-11-08

#Discord.pyとは
Discord Botをpythonで書くためのライブラリです。
Botの登録方法はこちらを。
また、日本人向けのDiscord.pyのサーバーはこちら

#コード

bot_example.py
import discord

client = discord.Client()


@client.event
async def on_ready():
    print('ログ中:')
    print(f'Botの名前: {client.user.name}')
    print(f'Botのid: {client.user.id}')
    print('------')


@client.event
async def on_message(message):
    if message.content.startswith('私は誰でしょう?'):
        reply = 'あなたは{.name}さんです'.format(message.author)
        await message.channel.send(reply)

# botの接続と起動
# (tokenにはbotアカウントのアクセストークンを入れてください)
client.run('token')
0
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
0
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?