1
- import heartbeat
2
- import localizations
3
- import statusicon
4
- import serverstatus
5
-
6
1
import argparse
7
2
import json
8
3
import logging
9
4
import os
5
+ import sys
6
+ import traceback
10
7
11
8
import discord
12
9
from discord .commands import Option
13
10
from discord .ext import tasks
14
11
12
+ import heartbeat
13
+ import localizations
14
+ import serverstatus
15
+ import statusicon
16
+
15
17
logging .basicConfig (level = logging .INFO )
16
18
logging .basicConfig (level = logging .WARNING )
17
19
18
20
# Botの名前
19
21
bot_name = "R6SSS"
20
22
# Botのバージョン
21
- bot_version = "1.3.8 "
23
+ bot_version = "1.3.9 "
22
24
23
25
default_embed = discord .Embed
24
26
@@ -151,7 +153,8 @@ async def updateserverstatus():
151
153
loc = db [str (guild .id )]["server_status_message" ][2 ]
152
154
except Exception as e :
153
155
logging .warning (f"ギルドデータ({ guild .name } ) の読み込み失敗" )
154
- logging .warning (e )
156
+ tb = sys .exc_info ()
157
+ logging .error (str (traceback .format_tb (tb )))
155
158
db [str (guild .id )] = default_guilddata_item
156
159
ch_id = db [str (guild .id )]["server_status_message" ][0 ]
157
160
msg_id = db [str (guild .id )]["server_status_message" ][1 ]
@@ -177,10 +180,12 @@ async def updateserverstatus():
177
180
else :
178
181
await msg .edit (embeds = await generateserverstatusembed (loc ))
179
182
except Exception as e :
183
+ tb = sys .exc_info ()
180
184
logging .error (f"ギルド { guild .name } のサーバーステータスメッセージ({ str (msg_id )} )の更新に失敗" )
181
- logging .error (str (e ))
185
+ logging .error (str (traceback . format_tb ( tb ) ))
182
186
except Exception as e :
183
- logging .error (str (e ))
187
+ tb = sys .exc_info ()
188
+ logging .error (str (traceback .format_tb (tb )))
184
189
heartbeat .monitor .ping (state = "fail" , message = "サーバーステータスの更新エラー: " + str (e ))
185
190
186
191
# Cronitorのモニターに成功したことを報告
@@ -214,8 +219,6 @@ async def generateserverstatusembed(locale):
214
219
for p in pf_list [pf ]:
215
220
if p .startswith ("_" ): continue
216
221
217
- if status [p ]["Maintenance" ] == None : status [p ]["Maintenance" ] = []
218
-
219
222
# サーバーの状態によってアイコンを変更する
220
223
# 問題なし
221
224
if status [p ]["Status" ]["Connectivity" ] == "Operational" :
@@ -244,9 +247,6 @@ async def generateserverstatusembed(locale):
244
247
f_status_icon = statusicon .Operational
245
248
if s != "Operational" :
246
249
f_status_icon = statusicon .Degraded # 停止
247
- if f in status [p ]["Maintenance" ]:
248
- f_status_icon = statusicon .Maintenance # メンテナンス
249
- s = "Maintenance"
250
250
if s == "Unknown" : f_status_icon = statusicon .Unknown # 不明
251
251
f_list .append ("┣━ **" + localizations .translate (f ) + "**\n ┣━ " + f_status_icon + "`" + localizations .translate (s ) + "`" )
252
252
f_text = "" + "\n " .join (f_list )
@@ -288,6 +288,8 @@ async def status(ctx):
288
288
try :
289
289
await ctx .send_followup (embeds = await generateserverstatusembed (db [str (ctx .guild_id )]["server_status_message" ][2 ]))
290
290
except Exception as e :
291
+ tb = sys .exc_info ()
292
+ logging .error (str (traceback .format_tb (tb )))
291
293
await ctx .send_followup (content = "サーバーステータスメッセージの送信時にエラーが発生しました: `" + str (e ) + "`" )
292
294
293
295
@client .slash_command ()
@@ -323,6 +325,8 @@ async def create(ctx, channel: Option(
323
325
if type (e ) == discord .errors .ApplicationCommandInvokeError and str (e ).endswith ("Missing Permissions" ):
324
326
await ctx .send_followup (content = "テキストチャンネル " + ch .mention + " へメッセージを送信する権限がありません!" )
325
327
else :
328
+ tb = sys .exc_info ()
329
+ logging .error (str (traceback .format_tb (tb )))
326
330
await ctx .send_followup (content = "サーバーステータスメッセージの作成時にエラーが発生しました: `" + str (e ) + "`" )
327
331
return
328
332
@@ -332,6 +336,8 @@ async def create(ctx, channel: Option(
332
336
333
337
await ctx .send_followup (content = "テキストチャンネル " + ch .mention + " へサーバーステータスメッセージを送信しました。\n 以後このメッセージは自動的に更新されます。" + additional_msg )
334
338
except Exception as e :
339
+ tb = sys .exc_info ()
340
+ logging .error (str (traceback .format_tb (tb )))
335
341
await ctx .send_followup (content = "サーバーステータスメッセージの送信時にエラーが発生しました: `" + str (e ) + "`" )
336
342
337
343
@client .slash_command ()
@@ -343,6 +349,8 @@ async def ping(ctx):
343
349
ping_embed = discord .Embed (title = "Pong!" ,description = f"Latency: **`{ ping } `** ms" ,color = discord .Colour .from_rgb (79 ,168 ,254 ))
344
350
await ctx .respond (embed = ping_embed )
345
351
except Exception as e :
352
+ tb = sys .exc_info ()
353
+ logging .error (str (traceback .format_tb (tb )))
346
354
await ctx .respond (content = "コマンドの実行時にエラーが発生しました: `" + str (e ) + "`" )
347
355
348
356
@client .slash_command ()
@@ -357,6 +365,8 @@ async def about(ctx):
357
365
358
366
await ctx .respond (embed = embed )
359
367
except Exception as e :
368
+ tb = sys .exc_info ()
369
+ logging .error (str (traceback .format_tb (tb )))
360
370
await ctx .respond (content = "コマンドの実行時にエラーが発生しました: `" + str (e ) + "`" )
361
371
362
372
@@ -366,5 +376,6 @@ async def about(ctx):
366
376
client .run (f .read ())
367
377
f .close ()
368
378
except Exception as e :
369
- logging .error (str (e ))
379
+ tb = sys .exc_info ()
380
+ logging .error (str (traceback .format_tb (tb )))
370
381
#os.system("kill 1")
0 commit comments