前提・実現したいこと
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
python -m pip install discord.py python -m pip install --upgrade pip
Python
import discord from discord.ext import commands ext = "ts/" bot = commands.Bot(command_prefix=ext) bot.remove_command("help") client = discord.Client() @bot.event async def on_ready(): activity = discord.Activity(name=f'{ext}help', type=discord.ActivityType.playing) await bot.change_presence(activity=activity) print("起動完了") @bot.command() async def join(ctx): vchannel = bot.get_channel(ctx.author.voice.channel) vchannel.connect() bot.run('TOKEN')
上記のソースコード
BOTは立ち上がりましたが「ts/join」としても何も応答がありませんでした。
補足情報(FW/ツールのバージョンなど)
discord.py
Python3.9.1
まだ回答がついていません
会員登録して回答してみよう