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

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

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

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

Python

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

Q&A

1回答

2770閲覧

discordのbotが動かない件について。

zettau

総合スコア14

Discord

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

Python

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

0グッド

0クリップ

投稿2021/08/30 16:46

編集2021/08/30 16:57

botが動かない件について。

前回の投稿ではソースの一部分をあげていましたが、そこの部分以外に原因があると考え投稿させて頂きます。
ご指摘頂ければ幸いです。

python

1import discord # インストールした discord.py 2import datetime # 滞在時間計測用 3import asyncio 4 5token = 'token' 6 7client = discord.Client() # 接続に使用するオブジェクト 8 9 10 11# 強制退出処理 12async def move_to_none(): 13 # 接続に利用するオブジェクト 14 client = discord.Client() 15 # 該当サーバーの特定のチャンネルIDを入れてください。 16 talk_channel_id =878830663808213026 17 channel = client.get_channel(talk_channel_id) 18 # チャンネル経由でサーバー内のボイスチャンネル全体を走査 19 for ch in channel.guild.voice_channels: 20 for member in ch.members: 21 # move_to(None)で特定のメンバーを切断する 22 await member.move_to(None) 23 24 25# 起動時に通知してくれる処理 26@client.event 27async def on_ready(): 28 last_clocked_time = datetime.datetime.now() 29 30 while True: 31 # ここから30秒間隔の処理 32 if last_clocked_time.hour is not datetime.datetime.now().hour: 33 # 2時に強制退出 34 if datetime.datetime.now().hour == 4: 35 print("強制退出を実行します") 36 await move_to_none() 37 last_clocked_time = datetime.datetime.now() # 時刻更新処理 38 await asyncio.sleep(30) 39 40import twitter 41import discord 42 43# 取得したキーとアクセストークンを設定する 44 45intents = discord.Intents.default() 46intents.members = True 47client = discord.Client(intents=intents) 48 49@client.event 50async def on_ready(): 51 print('Logged in as') 52 print(client.user.name) 53 print(client.user.id) 54 print('------') 55@client.event 56async def on_message(message): 57 if message.author.bot: 58 return 59 if message.content.startswith("!twi"): 60 message.content=message.content.replace("!twi",message.author.name+":") 61 # twitterへメッセージを投稿する 62 if len(message.content) <= 140: 63 #Twitterに投稿 64 Oauth = twitter.OAuth(consumer_key="api", 65 consumer_secret="api", 66 token="api", 67 token_secret=api) 68 twi = twitter.Twitter(auth=Oauth) 69 twi.statuses.update(status=message.content) 70 else: 71 msg="Twitterへの投稿に失敗しました、文字数を減らしてください。" 72 await message.channel.send(msg) 73 74import discord 75 76# 自分のBotのアクセストークン 77TOKEN = 'token' 78 79# Reaction 80list_yesno = ['????‍♂️', '????‍♂️'] 81list_vote = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '????'] 82 83 84def emphasize(text): 85 return "**" + text + "**" 86 87 88def underline(text): 89 return "__" + text + "__" 90 91 92def isContainedNoInput(command): 93 for i in command: 94 if i == "": 95 return True 96 return False 97 98 99client = discord.Client() 100 101 102# メッセージ受信時に動作する処理 103@client.event 104async def on_message(message): 105 # メッセージ送信者がBotだった場合は無視する 106 if message.author.bot: 107 return 108 109 # コマンドのセパレータは"." 110 command = message.content.split(".") 111 112 # 投票関連のコマンド 113 if command[0] == "/Q": 114 115 # セパレータによる不自然な挙動を防止 116 if isContainedNoInput(command): 117 await message.channel.send("無効なコマンドです (セパレータが連続もしくは最後に入力されています)") 118 return 119 120 try: 121 # Yes-No 疑問文 122 if command[1] == "yes-no": 123 embed = discord.Embed(title=command[2], description="", color=discord.Colour.blue()) 124 125 # 質問文を表示してYes,Noを絵文字でリアクション 126 voting_msg = await message.channel.send(embed=embed) 127 for i in range(len(list_yesno)): 128 await voting_msg.add_reaction(list_yesno[i]) 129 return 130 131 # 選択肢のある疑問文  132 elif command[1] == "vote": 133 embed = discord.Embed(title=command[2], description="", color=discord.Colour.green()) 134 135 # 選択肢の数を確認 136 select = len(command) - 3 137 if select > 10: 138 await message.channel.send("可能な選択肢は最大10個までです") 139 return 140 141 # 選択肢を表示 142 vote_candidate = command[3:] 143 for i in range(len(vote_candidate)): 144 embed.description = embed.description + list_vote[i] + " " + vote_candidate[i] + "\n" 145 146 # リアクションによる回答欄を作成 147 voting_msg = await message.channel.send(embed=embed) 148 for i in range(select): 149 await voting_msg.add_reaction(list_vote[i]) 150 return 151 152 # 使い方 153 elif command[1] == "help": 154 embed = discord.Embed(title="使用方法", description="", color=discord.Colour.red()) 155 embed.description = emphasize("question.[TYPE].[CONTENT] + .[CANDIDATE]\n") + \ 156 "注意 : 質問文や選択肢に\".\"を含めないでください\n" \ 157 "\n" \ 158 + emphasize("[TYPE] : \"yes-no\" or \"vote\"\n") + \ 159 underline("\"yes-no\" : \n") + \ 160 "Yes-No疑問文を作成します\n" \ 161 "[CANDIDATE]は必要ありません\n" \ 162 + underline("\"vote\" : \n") + \ 163 "選択肢が複数ある質問を作成します\n" \ 164 "[CANDIDATE]がない場合は質問文だけ表示されます\n" \ 165 "\n" \ 166 + emphasize("[CONTENT] : \n") + \ 167 "質問文に相当します\n" \ 168 "\n" \ 169 + emphasize("[CANDIDATE] : \n") + \ 170 "質問形式が\"vote\"である場合の選択肢です\n" \ 171 "選択肢として可能な最大個数は10個までです\n" 172 await message.channel.send(embed=embed) 173 174 # 以上のどの形式でもないものは形式不備を伝える 175 else: 176 await message.channel.send("質問形式が異なっています (2つめの引数が正しくありません)") 177 return 178 179 except IndexError: 180 await message.channel.send("質問の入力形式に間違いがあります (引数が足りません)") 181 return 182 183import discord 184 185client = discord.Client() 186 187@client.event 188async def on_ready(): 189 embed = discord.Embed( # Embedを定義する 190 title="botを起動しました",# タイトル 191 color=0x00ff00, # フレーム色指定(今回は緑) 192 description="不具合、質問がある場合はdmに下さい。", # Embedの説明文 必要に応じて 193 url="https://example.com" # これを設定すると、タイトルが指定URLへのリンクになる 194 ) 195 196 embed.set_author( 197 name=client.user, # Botのユーザー名 198 url="https://repo.exapmle.com/bot", # titleのurlのようにnameをリンクにできる。botのWebサイトとかGithubとか 199 icon_url=client.user.avatar_url # Botのアイコンを設定してみる 200 ) 201 202 embed.set_thumbnail(url="https://image.example.com/thumbnail.png") # サムネイルとして小さい画像を設定できる 203 204 embed.set_image(url="https://image.example.com/main.png") # 大きな画像タイルを設定できる 205 206 embed.add_field(name="フィールド1",value="値1") # フィールドを追加。 207 embed.add_field(name="フィールド2",value="値2") 208 209 embed.set_footer( 210 text="made by nashiroaoi", # フッターには開発者の情報でも入れてみる 211 icon_url="https://dev.exapmple.com/profile.png" 212 ) 213 214 channel = client.get_channel(881166734835470406) # ここのチャンネルIDを間違えると送信できないので注意してください 215 await channel.send(embed=embed) 216 217 activity = discord.Activity(name='Prodeced by Senchan', type=discord.ActivityType.watching) 218 # watchingの部分を変えることで表示を変えることができます。 219 # playing: ○○をプレイ中, streaming: ○○を配信中, listening: ○○を再生中, watching: ○○を視聴中 220 await client.change_presence(activity=activity) 221 222@client.event 223async def on_message(message): 224 if message.author.bot: 225 return 226 if message.content.startswith('/ver'): # startswithにすることにより、/ver, /ver abc, /versionなどに反応します。 227 send_message = '> ver1.0' 228 await message.channel.send(send_message) 229 230 231# exitを使うため 232import sys 233# discordのAPI 234import discord 235# Google検索 236from googlesearch import search 237 238# 接続に必要らしい(よくわかってない) 239client = discord.Client() 240 241# とりあえずフラグでモード管理しようかなと 242ModeFlag = 0 243 244 245# メッセージを受けた時の動作 246@client.event 247async def on_message(message): 248 # イベント入るたびに初期化はまずいのでグローバル変数で 249 global ModeFlag 250 # botの発言は無視する(無限ループ回避) 251 if message.author.bot: 252 return 253 # 一応終了するコマンドも用意しておく 254 if message.content == '!exit': 255 await message.channel.send('ノシ') 256 sys.exit() 257 # google検索モード(次に何か入力されるとそれを検索) 258 if ModeFlag == 1: 259 kensaku = message.content 260 ModeFlag = 0 261 count = 0 262 # 日本語で検索した上位5件を順番に表示 263 for url in search(kensaku, lang="jp",num = 5): 264 await message.channel.send(url) 265 count += 1 266 if(count == 5): 267 break 268 # google検索モードへの切り替え 269 if message.content == '/google': 270 ModeFlag = 1 271 await message.channel.send('検索するワードをチャットで発言してね') 272 # 単純な応答 273 if message.content == 'bot君いる?': 274 await message.channel.send('私bot君。あなたの後ろにいるよ。') 275 # 特定の文字から始まる文章が発言されたとき 276 if message.content.startswith('負け'): 277 lose = message.author.name + "の負け!w" 278 await message.channel.send(lose) 279 #リプライを受け取った時 280 if client.user in message.mentions: 281 reply = f'{message.author.mention} うるさいよ。' 282 await message.channel.send(reply) 283 # これについては触れないよ。 284 if message.content.startswith("なんだかんだ"): 285 kanda = "かんだ・・・神田ァ!?\n" + "https://www.youtube.com/watch?v=KUwpssJX37M" 286 await message.channel.send(kanda) 287 288 289client.run("token") 290

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

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

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

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

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

Awayume

2021/08/30 16:51

TOKENは隠してください。BOTが乗っ取られ、荒らしに使われてしまいます。 特に最近は横行しているので注意が必要です。 今すぐに質問文を編集し、Discord Developer PortalからTOKENを再生成してください。
zettau

2021/08/30 16:54

質問文を編集し、トークンを再生性しました。 御迷惑おかけしました。
Awayume

2021/08/30 16:55

Twitterに関するものも編集してください。 このままでは乗っ取りが可能です。
zettau

2021/08/30 16:57

なんべんもすみません。変更させて頂きました
guest

回答1

0

python

1import discord # インストールした discord.py 2import datetime # 滞在時間計測用 3import asyncio 4import twitter 5import sys 6from googlesearch import search 7 8token = 'token' 9intents = discord.Intents.default() 10intents.members = True 11client = discord.Client(intents=intents) 12 13@client.event 14async def on_ready(): 15 print('Logged in as') 16 print(client.user.name) 17 print(client.user.id) 18 print('------') 19 20 embed = discord.Embed( # Embedを定義する 21 title="botを起動しました",# タイトル 22 color=0x00ff00, # フレーム色指定(今回は緑) 23 description="不具合、質問がある場合はdmに下さい。", # Embedの説明文 必要に応じて 24 url="https://example.com" # これを設定すると、タイトルが指定URLへのリンクになる 25 ) 26 27 embed.set_author( 28 name=client.user, # Botのユーザー名 29 url="https://repo.exapmle.com/bot", # titleのurlのようにnameをリンクにできる。botのWebサイトとかGithubとか 30 icon_url=client.user.avatar_url # Botのアイコンを設定してみる 31 ) 32 33 embed.set_thumbnail(url="https://image.example.com/thumbnail.png") # サムネイルとして小さい画像を設定できる 34 35 embed.set_image(url="https://image.example.com/main.png") # 大きな画像タイルを設定できる 36 37 embed.add_field(name="フィールド1",value="値1") # フィールドを追加。 38 embed.add_field(name="フィールド2",value="値2") 39 40 embed.set_footer( 41 text="made by nashiroaoi", # フッターには開発者の情報でも入れてみる 42 icon_url="https://dev.exapmple.com/profile.png" 43 ) 44 45 channel = client.get_channel(881166734835470406) # ここのチャンネルIDを間違えると送信できないので注意してください 46 await channel.send(embed=embed) 47 48 activity = discord.Activity(name='Prodeced by Senchan', type=discord.ActivityType.watching) 49 # watchingの部分を変えることで表示を変えることができます。 50 # playing: ○○をプレイ中, streaming: ○○を配信中, listening: ○○を再生中, watching: ○○を視聴中 51 await client.change_presence(activity=activity) 52 53 last_clocked_time = datetime.datetime.now() 54 55 while True: 56 # ここから30秒間隔の処理 57 if last_clocked_time.hour is not datetime.datetime.now().hour: 58 # 2時に強制退出 59 if datetime.datetime.now().hour == 4: 60 print("強制退出を実行します") 61 await move_to_none() 62 last_clocked_time = datetime.datetime.now() # 時刻更新処理 63 await asyncio.sleep(30) 64 65# Reaction 66list_yesno = ['????‍♂️', '????‍♂️'] 67list_vote = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '????'] 68 69 70def emphasize(text): 71 return "**" + text + "**" 72 73 74def underline(text): 75 return "__" + text + "__" 76 77 78def isContainedNoInput(command): 79 for i in command: 80 if i == "": 81 return True 82 return False 83 84# とりあえずフラグでモード管理しようかなと 85ModeFlag = 0 86 87# 強制退出処理 88@client.event 89async def move_to_none(): 90 # 該当サーバーの特定のチャンネルIDを入れてください。 91 talk_channel_id =878830663808213026 92 channel = client.get_channel(talk_channel_id) 93 # チャンネル経由でサーバー内のボイスチャンネル全体を走査 94 for ch in channel.guild.voice_channels: 95 for member in ch.members: 96 # move_to(None)で特定のメンバーを切断する 97 await member.move_to(None) 98 99@client.event 100async def on_message(message): 101 if message.author.bot: 102 return 103 if message.content.startswith("!twi"): 104 message.content=message.content.replace("!twi",message.author.name+":") 105 # twitterへメッセージを投稿する 106 if len(message.content) <= 140: 107 #Twitterに投稿 108 Oauth = twitter.OAuth(consumer_key="api", 109 consumer_secret="api", 110 token="api", 111 token_secret=api) 112 twi = twitter.Twitter(auth=Oauth) 113 twi.statuses.update(status=message.content) 114 else: 115 msg="Twitterへの投稿に失敗しました、文字数を減らしてください。" 116 await message.channel.send(msg) 117 118 # コマンドのセパレータは"." 119 command = message.content.split(".") 120 121 # 投票関連のコマンド 122 if command[0] == "/Q": 123 124 # セパレータによる不自然な挙動を防止 125 if isContainedNoInput(command): 126 await message.channel.send("無効なコマンドです (セパレータが連続もしくは最後に入力されています)") 127 return 128 129 try: 130 # Yes-No 疑問文 131 if command[1] == "yes-no": 132 embed = discord.Embed(title=command[2], description="", color=discord.Colour.blue()) 133 134 # 質問文を表示してYes,Noを絵文字でリアクション 135 voting_msg = await message.channel.send(embed=embed) 136 for i in range(len(list_yesno)): 137 await voting_msg.add_reaction(list_yesno[i]) 138 return 139 140 # 選択肢のある疑問文  141 elif command[1] == "vote": 142 embed = discord.Embed(title=command[2], description="", color=discord.Colour.green()) 143 144 # 選択肢の数を確認 145 select = len(command) - 3 146 if select > 10: 147 await message.channel.send("可能な選択肢は最大10個までです") 148 return 149 150 # 選択肢を表示 151 vote_candidate = command[3:] 152 for i in range(len(vote_candidate)): 153 embed.description = embed.description + list_vote[i] + " " + vote_candidate[i] + "\n" 154 155 # リアクションによる回答欄を作成 156 voting_msg = await message.channel.send(embed=embed) 157 for i in range(select): 158 await voting_msg.add_reaction(list_vote[i]) 159 return 160 161 # 使い方 162 elif command[1] == "help": 163 embed = discord.Embed(title="使用方法", description="", color=discord.Colour.red()) 164 embed.description = emphasize("question.[TYPE].[CONTENT] + .[CANDIDATE]\n") + \ 165 "注意 : 質問文や選択肢に\".\"を含めないでください\n" \ 166 "\n" \ 167 + emphasize("[TYPE] : \"yes-no\" or \"vote\"\n") + \ 168 underline("\"yes-no\" : \n") + \ 169 "Yes-No疑問文を作成します\n" \ 170 "[CANDIDATE]は必要ありません\n" \ 171 + underline("\"vote\" : \n") + \ 172 "選択肢が複数ある質問を作成します\n" \ 173 "[CANDIDATE]がない場合は質問文だけ表示されます\n" \ 174 "\n" \ 175 + emphasize("[CONTENT] : \n") + \ 176 "質問文に相当します\n" \ 177 "\n" \ 178 + emphasize("[CANDIDATE] : \n") + \ 179 "質問形式が\"vote\"である場合の選択肢です\n" \ 180 "選択肢として可能な最大個数は10個までです\n" 181 await message.channel.send(embed=embed) 182 183 # 以上のどの形式でもないものは形式不備を伝える 184 else: 185 await message.channel.send("質問形式が異なっています (2つめの引数が正しくありません)") 186 return 187 188 except IndexError: 189 await message.channel.send("質問の入力形式に間違いがあります (引数が足りません)") 190 return 191 192 if message.content.startswith('/ver'): # startswithにすることにより、/ver, /ver abc, /versionなどに反応します。 193 send_message = '> ver1.0' 194 await message.channel.send(send_message) 195 196 # イベント入るたびに初期化はまずいのでグローバル変数で 197 global ModeFlag 198 # 一応終了するコマンドも用意しておく 199 if message.content == '!exit': 200 await message.channel.send('ノシ') 201 sys.exit() 202 # google検索モード(次に何か入力されるとそれを検索) 203 if ModeFlag == 1: 204 kensaku = message.content 205 ModeFlag = 0 206 count = 0 207 # 日本語で検索した上位5件を順番に表示 208 for url in search(kensaku, lang="jp",num = 5): 209 await message.channel.send(url) 210 count += 1 211 if(count == 5): 212 break 213 # google検索モードへの切り替え 214 if message.content == '/google': 215 ModeFlag = 1 216 await message.channel.send('検索するワードをチャットで発言してね') 217 # 単純な応答 218 if message.content == 'bot君いる?': 219 await message.channel.send('私bot君。あなたの後ろにいるよ。') 220 # 特定の文字から始まる文章が発言されたとき 221 if message.content.startswith('負け'): 222 lose = message.author.name + "の負け!w" 223 await message.channel.send(lose) 224 #リプライを受け取った時 225 if client.user in message.mentions: 226 reply = f'{message.author.mention} うるさいよ。' 227 await message.channel.send(reply) 228 # これについては触れないよ。 229 if message.content.startswith("なんだかんだ"): 230 kanda = "かんだ・・・神田ァ!?\n" + "https://www.youtube.com/watch?v=KUwpssJX37M" 231 await message.channel.send(kanda) 232 233 234client.run(token)

おそらくこれで一応動くかと。
もし動かなかったりエラーが出たらまた教えてください。
使ったことのないライブラリなどが結構多いので、記法的に問題のあるところを直しておきました。

投稿2021/08/30 17:20

編集2021/09/01 03:23
Awayume

総合スコア60

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

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

zettau

2021/08/30 17:29

File "C:/Users/せんちゃん/PycharmProjects/pythonProject1/bot.py", line 55 while True: ^ IndentationError: unexpected indent こちらのエラーが出ました。。。
Awayume

2021/08/30 17:35

すみません、うっかりしてました。 修正しました。
zettau

2021/08/30 17:36

ありがとうございます! 試させて頂きます。
zettau

2021/08/30 17:41

File "C:/Users/せんちゃん/PycharmProjects/pythonProject1/bot.py", line 195 if message.content.startswith('/ver'): # startswithにすることにより、/ver, /ver abc, /versionなどに反応します。 ^ IndentationError: unindent does not match any outer indentation level 次はこちらみたいです。。
Awayume

2021/08/30 17:50

修正しました。
zettau

2021/08/30 18:36

gnoring exception in on_message Traceback (most recent call last): File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 375, in _handle_response handle = urllib_request.urlopen(req, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 569, in error return self._call_chain(*args) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 503, in _call_chain result = func(*args) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "C:/Users/せんちゃん/PycharmProjects/pythonProject1/bot.py", line 115, in on_message twi.statuses.update(status=message.content) File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 364, in __call__ return self._handle_response(req, uri, arg_data, _timeout) File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 406, in _handle_response raise TwitterHTTPError(e, uri, self.format, arg_data) twitter.api.TwitterHTTPError: Twitter sent status 403 for URL: 1.1/statuses/update.json using parameters: (oauth_consumer_key=3rJOl1ODzm9yZy63FACdg&oauth_nonce=3200536443004776409&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1630348446&oauth_token=184389298-Fwdx3Knf3FYfli1iagOSUnWBKxxlaBgOlPa4ykoM&oauth_version=1.0&status=%2Fver&oauth_signature=Kfq0wsnwq2ioi6803yEflIQWIKQ%3D) details: {'errors': [{'code': 187, 'message': 'Status is a duplicate.'}]} Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 375, in _handle_response このエラー吐いてます。。。 プレイ中、emdedは確認できました。ありがとうございます。
zettau

2021/08/30 18:37

Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 375, in _handle_response handle = urllib_request.urlopen(req, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 569, in error return self._call_chain(*args) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 503, in _call_chain result = func(*args) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "C:/Users/せんちゃん/PycharmProjects/pythonProject1/bot.py", line 115, in on_message twi.statuses.update(status=message.content) File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 364, in __call__ return self._handle_response(req, uri, arg_data, _timeout) File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 406, in _handle_response raise TwitterHTTPError(e, uri, self.format, arg_data) twitter.api.TwitterHTTPError: Twitter sent status 403 for URL: 1.1/statuses/update.json using parameters: (oauth_consumer_key=3rJOl1ODzm9yZy63FACdg&oauth_nonce=1357156004494375601&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1630348621&oauth_token=184389298-Fwdx3Knf3FYfli1iagOSUnWBKxxlaBgOlPa4ykoM&oauth_version=1.0&status=_%E3%82%B5%E3%82%A4%E3%82%B3%E3%83%AD&oauth_signature=l2vE2V0PPtN8RxMu9f4jCiTpVt0%3D) details: {'errors': [{'code': 187, 'message': 'Status is a duplicate.'}]} Logged in as leyx bot test 876503844899663882 ------ Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 375, in _handle_response handle = urllib_request.urlopen(req, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 569, in error return self._call_chain(*args) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 503, in _call_chain result = func(*args) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "C:/Users/せんちゃん/PycharmProjects/pythonProject1/bot.py", line 115, in on_message twi.statuses.update(status=message.content) File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 364, in __call__ return self._handle_response(req, uri, arg_data, _timeout) File "C:\Users\せんちゃん\PycharmProjects\pythonProject1\venv\lib\site-packages\twitter\api.py", line 406, in _handle_response raise TwitterHTTPError(e, uri, self.format, arg_data) twitter.api.TwitterHTTPError: Twitter sent status 403 for URL: 1.1/statuses/update.json using parameters: (oauth_consumer_key=3rJOl1ODzm9yZy63FACdg&oauth_nonce=12740443104644060107&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1630348628&oauth_token=184389298-Fwdx3Knf3FYfli1iagOSUnWBKxxlaBgOlPa4ykoM&oauth_version=1.0&status=%2Fver&oauth_signature=bspMcvo%2FnHWfrKdh6TnlHxGSq2U%3D) details: {'errors': [{'code': 187, 'message': 'Status is a duplicate.'}]} こちらでした。
Awayume

2021/09/01 03:03

どのライブラリを使っているか教えてください。
zettau

2021/09/01 03:51

まるまるプログラムを書き換えました。 新しい方に新しい機能も搭載し投稿していますので、もし良ければそちらをご覧下さい。
Awayume

2021/09/01 04:12

了解しました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問