Q&A
パイソンを勉強し始めるにあたってまずは手を動かそうと思い、discord で読み上げbotを作っています。
参考にしたサイトは下記の二つです。
はじめてでしたのでサイトの手順通りに作成しております。
①https://appli-world.jp/posts/16908
②https://qiita.com/9610r/items/d04bd91d373d31d9c3f3
コマンドプロンプトにてdiscord botのログインを行おうとしたところ下記のエラーメッセージが出力されました。
実現したいこと
discord botのログイン処理を行いたいです。
またエラーが起きている個所はわかるがどのように修正したらよいのかわからないので教えていただきたいです。
発生している問題・エラーメッセージ
エラーメッセージ
Traceback (most recent call last):
File "C:\open_jtalk\bin\read_bot.py", line 7, in <module>
client = commands.Bot(command_prefix='.')
TypeError: BotBase.init() missing 1 required keyword-only argument: 'intents'
該当のソースコード
discord.py
1import discord 2from discord.ext import commands 3import subprocess 4import ffmpeg 5from voice_generator import creat_WAV 6 7client = commands.Bot(command_prefix='.') 8voice_client = None 9 10 11@client.event 12async def on_ready(): 13 print('Logged in as') 14 print(client.user.name) 15 print(client.user.id) 16 print('------') 17 18 19@client.command() 20async def join(ctx): 21 #voicechannelを取得 22 vc = ctx.author.voice.channel 23 #voicechannelに接続 24 await vc.connect() 25 26@client.command() 27async def bye(ctx): 28 #切断 29 await ctx.voice_client.disconnect() 30 31@client.event 32async def on_message(message): 33 if message.content.startswith('.'): 34 pass 35 36 else: 37 if message.guild.voice_client: 38 print(message.content) 39 creat_WAV(message.content) 40 source = discord.FFmpegPCMAudio("output.wav") 41 message.guild.voice_client.play(source) 42 else: 43 pass 44 45 46client.run("あなたのTOKEN")
試したこと
discord.pyがインストールされているか→〇
Developer PortalにてIntentsが有効にされているかどうか→〇
ソースソースコードの”あなたのTOKEN”は個人のTOKENに変えているか→〇
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2022/09/24 06:45
2022/09/24 11:37
2022/09/24 12:53
2022/09/28 10:33
2022/09/28 10:34