# 各チャンネルのメッセージを取得して統計情報を収集します
for channel in guild.channels:
if isinstance(channel, discord.TextChannel):
#print(f"Processing channel: {channel.name}")
# メッセージを取得して統計情報を収集します
async for message in channel.history(limit=None):
if message.author.bot:
continue # ボットの発言は無視します
# メッセージの日付が指定した月と一致する場合にのみ処理を行います
if message.created_at.strftime("%Y-%m") == month:
# 発言者の名前を取得します
author_name = str(message.author)
# Counterオブジェクトを初期化します
if channel.id not in channel_stats:
channel_stats[channel.id] = Counter()
# 発言者のカウントを増やします
channel_stats[channel.id][author_name] += 1
if isinstance(channel, discord.Thread):
async for message in channel.history(limit=None):
discord.pyのバージョン2.0以降で動作させていますが、
async for thread in channel.threads:
^^^^^^^^^^^^^^^
AttributeError: 'CategoryChannel' object has no attribute 'threads'
エラーとなります...
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/06/26 04:47