前提・実現したいこと
Discord.pyの初心者です。
botのいるサーバーのボイスチャンネルに入り、「ts/join」と実行すると、
ボイスチャンネルにボットが入ってくる
コマンドが作りたいのですが、
コマンドを実行すると次のようなエラーが起きます。
発生している問題・エラーメッセージ
File "D:\discord.bot\discord-bot-py\test.py", line 17, in join vchannel.connect() AttributeError: 'NoneType' object has no attribute 'connect' The above exception was the direct cause of the following exception:
該当のソースコード
cmd
1python -m pip install discord.py 2python -m pip install --upgrade pip
Python
1import discord 2from discord.ext import commands 3ext = "ts/" 4bot = commands.Bot(command_prefix=ext) 5bot.remove_command("help") 6client = discord.Client() 7 8@bot.event 9async def on_ready(): 10 activity = discord.Activity(name=f'{ext}help', type=discord.ActivityType.playing) 11 await bot.change_presence(activity=activity) 12 print("起動完了") 13 14@bot.command() 15async def join(ctx): 16 vchannel = bot.get_channel(ctx.author.voice.channel) 17 vchannel.connect() 18 19bot.run('TOKEN')
上記のソースコード
BOTは立ち上がりましたが「ts/join」としても何も応答がありませんでした。
補足情報(FW/ツールのバージョンなど)
discord.py
Python3.9.1
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。