質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

3回答

9349閲覧

discord.pyを最新のにインストールしたら、前まで使えていたはずのものが使えなくなった

matsuochinyu

総合スコア57

Discord

Discordは、ゲーマー向けのボイスチャットアプリです。チャット・通話がブラウザ上で利用可能で、個人専用サーバーも開設できます。通話中でも音楽を流したり、PC画面を共有できるなど多機能な点が特徴です。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2022/03/31 06:51

前提

discord.pyでBotを作っています。
pip install -U git+https://github.com/Rapptz/discord.py
と入力し、discord.pyを最新のバージョンにしたら使えなくなりました。

実現したいこと

・意味不明のエラーを無くして動くようにする

発生している問題・エラーメッセージ

Traceback (most recent call last): File "/Users/matsuochinyu/home/workspace/Discord/main.py", line 119, in <module> bot.run(TOKEN) File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 709, in run asyncio.run(runner()) File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete return future.result() File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 706, in runner await self.start(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 680, in start await self.connect(reconnect=reconnect) File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 617, in connect raise PrivilegedIntentsRequired(exc.shard_id) from None discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

該当のソースコード

python

1import datetime 2import json 3import os 4import traceback 5 6import discord 7from discord.ext import commands 8from dotenv import load_dotenv 9 10from help_command import HelpCommand 11 12now = datetime.datetime.now() 13load_dotenv() 14TOKEN = os.environ["TOKEN"] 15INITIAL_EXTENSIONS = [ 16 f"cogs.{file}".replace(".py", "") 17 for file in os.listdir("cogs") 18 if file.endswith("py") 19] 20NOTICE = CHANNEL_ID 21 22 23class Bot(commands.Bot): 24 def __init__(self, command_prefix, intents, help_command): 25 super().__init__(command_prefix, intents=intents, help_command=help_command) 26 27 print("Cogを読み込みます") 28 self.success = 0 29 self.failure = 0 30 for cog in INITIAL_EXTENSIONS: 31 print("-" * 10) 32 print(cog) 33 try: 34 self.load_extension(cog) 35 print(f"Read success:{cog}") 36 self.success += 1 37 except Exception as e: 38 print(e) 39 print(f"Read failure:{cog}") 40 self.failure += 1 41 print("-" * 10) 42 print(f"成功:{self.success} 失敗:{self.failure}\n") 43 44 async def on_ready(self): 45 embed = discord.Embed(title="Info", description="", color=0x00FF00) 46 embed.add_field(name="Cogの読み込み", value=f"成功:{self.success} 失敗:{self.failure}") 47 await self.get_channel(NOTICE).send(embed=embed) 48 49 with open("cogs/reload.txt", "r", encoding="utf-8") as f: 50 read_file = f.read() 51 if read_file == "": 52 pass 53 else: 54 await self.get_channel(int(read_file)).send( 55 "``loading...``", delete_after=3 56 ) 57 embed = discord.Embed( 58 title="___リロード完了通知___", description="使えるようになりました。", color=0x00FF00 59 ) 60 await self.get_channel(int(read_file)).send(embed=embed, delete_after=3) 61 with open("cogs/reload.txt", "w", encoding="utf-8") as f: 62 f.write("") 63 64 async def on_command_error(self, ctx, error): 65 """すべてのコマンドで発生したエラーを拾う""" 66 if isinstance(error, commands.CommandInvokeError): 67 orig_error = getattr(error, "original", error) 68 error_msg = "".join( 69 traceback.TracebackException.from_exception(orig_error).format() 70 ) 71 error_message = f"```{error_msg}```" 72 73 ch = ctx.guild.get_channel(NOTICE) 74 embed = discord.Embed( 75 title="エラーログ", description=error_message, color=0xF04747 76 ) 77 embed.set_footer( 78 text=f"Time:{now:%Y-%m-%d %H:%M:%S}\nGuild:{ctx.guild}\nChannel:{ctx.channel}\nUser:{ctx.author.display_name}" 79 ) 80 await ch.send(embed=embed) 81 82if __name__ == "__main__": 83 intent = discord.Intents.all() 84 intent.typing = True 85 intent.members = True 86 intent.messages = True 87 intent.reactions = True 88 89 print("ログイン中...\n") 90 bot = Bot( 91 command_prefix=commands.when_mentioned_or("m:"), 92 intents=intent, 93 help_command=HelpCommand(), 94 ) 95 96 print(f"Informations:{datetime.datetime.now()}") 97 print("-" * 40) 98 print(f"Discord.py Version:{discord.__version__}") 99 print(bot.author.display_name) 100 print(bot.author.id) 101 print("-" * 40) 102 print("ログイン完了\n") 103 bot.run(TOKEN)

補足情報(FW/ツールのバージョンなど)

・MacBook Pro(Retina 15Inch, Early 2013)
・MacOS:Catalina 10.15.7
・discord.py:Version: 2.0.0a4000+g8a222b6
・シェル:Zsh

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

https://zenn.dev/disneyresidents/articles/discordintents
こちらの記事を参考にインテンツを有効にしてみてください。

投稿2022/05/18 15:44

yaakiyu

総合スコア124

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

同様の悩みから解決したのでこの記事にたどり着いた人のために。

yaakiyuさんの回答通り
https://zenn.dev/disneyresidents/articles/discordintents
の記事を参考にPrivileged Intentsを有効にするのですが、
記事の内容と違い第3の項目MESSAGE CONTENT INTENTが追加されているのでこれも有効にしてください。
この文章を書いている時点での通常版では記事通り上2つだけでも動きますが開発版はこれを有効にしていないと動かないようです。

投稿2022/08/15 15:35

hirosaw

総合スコア4

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

自己解決

使わない。が正解でした。

投稿2022/05/26 05:08

matsuochinyu

総合スコア57

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問