作るもの

配信者Discord向けの配信者が配信チャンネルに接続したときにメッセージで通知するBOT
作り方
BOTアカウントを作成する。
Discord Devepoper PotarlでBOTアカウントを作成し、トークンを取得します。
Discord.pyをインストールする。
前提となるPythonはインストール済みであると仮定して進めていきます。
DiscordのBOTをPythonで作成する場合、Discord.pyというライブラリーを使用することで作成することができます。
pip install discord.py
プログラミング
早速DiscordBOTを作成します。
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
@bot.event
async def on_ready():
print('起動完了')
@bot.event
async def on_voice_state_update(member, before, after):
if before.channel is None and after.channel is not None and after.channel.id == 配信VCID and member.id == 配信者ID:
channel = bot.get_channel(送信チャンネルID)
await channel.send('送信したいメッセージ')
bot.run('BOTTOKEN')
配信VCIDにボイスチャットのID、配信者IDに監視したい人のID、送信チャンネルIDに送信したいテキストチャンネルのID、送信したいメッセージに送信したいメッセージを入力して保存します。
起動
下記のコマンドを使用して、作成したbot.pyを起動します。
python3 bot.py
python bot.py

起動して起動完了と表示されたら成功です。
VCに接続して試してみてください。
最後に
とても簡単に配信者用VC通知BOTが作成することができました。
コメント
Hi there, just became alert to your blog through Google,
and found that it’s truly informative. I’m gonna
watch out for brussels. I’ll appreciate if you continue this
in future. Many people will be benefited from your writing.
Cheers!