Skip to content

Commit 77b6839

Browse files
committed
Version 1.3.9
- エラー発生時に詳細をコンソールへ出力するように改善 - サーバーステータス更新時に、メンテナンスか判定する処理でエラーが発生する問題を修正
1 parent 7c467bc commit 77b6839

File tree

2 files changed

+26
-60
lines changed

2 files changed

+26
-60
lines changed

src/api.py

-45
This file was deleted.

src/main.py

+26-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
import heartbeat
2-
import localizations
3-
import statusicon
4-
import serverstatus
5-
61
import argparse
72
import json
83
import logging
94
import os
5+
import sys
6+
import traceback
107

118
import discord
129
from discord.commands import Option
1310
from discord.ext import tasks
1411

12+
import heartbeat
13+
import localizations
14+
import serverstatus
15+
import statusicon
16+
1517
logging.basicConfig(level=logging.INFO)
1618
logging.basicConfig(level=logging.WARNING)
1719

1820
# Botの名前
1921
bot_name = "R6SSS"
2022
# Botのバージョン
21-
bot_version = "1.3.8"
23+
bot_version = "1.3.9"
2224

2325
default_embed = discord.Embed
2426

@@ -151,7 +153,8 @@ async def updateserverstatus():
151153
loc = db[str(guild.id)]["server_status_message"][2]
152154
except Exception as e:
153155
logging.warning(f"ギルドデータ({guild.name}) の読み込み失敗")
154-
logging.warning(e)
156+
tb = sys.exc_info()
157+
logging.error(str(traceback.format_tb(tb)))
155158
db[str(guild.id)] = default_guilddata_item
156159
ch_id = db[str(guild.id)]["server_status_message"][0]
157160
msg_id = db[str(guild.id)]["server_status_message"][1]
@@ -177,10 +180,12 @@ async def updateserverstatus():
177180
else:
178181
await msg.edit(embeds=await generateserverstatusembed(loc))
179182
except Exception as e:
183+
tb = sys.exc_info()
180184
logging.error(f"ギルド {guild.name} のサーバーステータスメッセージ({str(msg_id)})の更新に失敗")
181-
logging.error(str(e))
185+
logging.error(str(traceback.format_tb(tb)))
182186
except Exception as e:
183-
logging.error(str(e))
187+
tb = sys.exc_info()
188+
logging.error(str(traceback.format_tb(tb)))
184189
heartbeat.monitor.ping(state="fail", message="サーバーステータスの更新エラー: " + str(e))
185190

186191
# Cronitorのモニターに成功したことを報告
@@ -214,8 +219,6 @@ async def generateserverstatusembed(locale):
214219
for p in pf_list[pf]:
215220
if p.startswith("_"): continue
216221

217-
if status[p]["Maintenance"] == None: status[p]["Maintenance"] = []
218-
219222
# サーバーの状態によってアイコンを変更する
220223
# 問題なし
221224
if status[p]["Status"]["Connectivity"] == "Operational":
@@ -244,9 +247,6 @@ async def generateserverstatusembed(locale):
244247
f_status_icon = statusicon.Operational
245248
if s != "Operational":
246249
f_status_icon = statusicon.Degraded # 停止
247-
if f in status[p]["Maintenance"]:
248-
f_status_icon = statusicon.Maintenance # メンテナンス
249-
s = "Maintenance"
250250
if s == "Unknown": f_status_icon = statusicon.Unknown # 不明
251251
f_list.append("┣━ **" + localizations.translate(f) + "**\n┣━ " + f_status_icon + "`" + localizations.translate(s) + "`")
252252
f_text = "" + "\n".join(f_list)
@@ -288,6 +288,8 @@ async def status(ctx):
288288
try:
289289
await ctx.send_followup(embeds=await generateserverstatusembed(db[str(ctx.guild_id)]["server_status_message"][2]))
290290
except Exception as e:
291+
tb = sys.exc_info()
292+
logging.error(str(traceback.format_tb(tb)))
291293
await ctx.send_followup(content="サーバーステータスメッセージの送信時にエラーが発生しました: `" + str(e) + "`")
292294

293295
@client.slash_command()
@@ -323,6 +325,8 @@ async def create(ctx, channel: Option(
323325
if type(e) == discord.errors.ApplicationCommandInvokeError and str(e).endswith("Missing Permissions"):
324326
await ctx.send_followup(content="テキストチャンネル " + ch.mention + " へメッセージを送信する権限がありません!")
325327
else:
328+
tb = sys.exc_info()
329+
logging.error(str(traceback.format_tb(tb)))
326330
await ctx.send_followup(content="サーバーステータスメッセージの作成時にエラーが発生しました: `" + str(e) + "`")
327331
return
328332

@@ -332,6 +336,8 @@ async def create(ctx, channel: Option(
332336

333337
await ctx.send_followup(content="テキストチャンネル " + ch.mention + " へサーバーステータスメッセージを送信しました。\n以後このメッセージは自動的に更新されます。" + additional_msg)
334338
except Exception as e:
339+
tb = sys.exc_info()
340+
logging.error(str(traceback.format_tb(tb)))
335341
await ctx.send_followup(content="サーバーステータスメッセージの送信時にエラーが発生しました: `" + str(e) + "`")
336342

337343
@client.slash_command()
@@ -343,6 +349,8 @@ async def ping(ctx):
343349
ping_embed = discord.Embed(title="Pong!",description=f"Latency: **`{ping}`** ms",color=discord.Colour.from_rgb(79,168,254))
344350
await ctx.respond(embed=ping_embed)
345351
except Exception as e:
352+
tb = sys.exc_info()
353+
logging.error(str(traceback.format_tb(tb)))
346354
await ctx.respond(content="コマンドの実行時にエラーが発生しました: `" + str(e) + "`")
347355

348356
@client.slash_command()
@@ -357,6 +365,8 @@ async def about(ctx):
357365

358366
await ctx.respond(embed=embed)
359367
except Exception as e:
368+
tb = sys.exc_info()
369+
logging.error(str(traceback.format_tb(tb)))
360370
await ctx.respond(content="コマンドの実行時にエラーが発生しました: `" + str(e) + "`")
361371

362372

@@ -366,5 +376,6 @@ async def about(ctx):
366376
client.run(f.read())
367377
f.close()
368378
except Exception as e:
369-
logging.error(str(e))
379+
tb = sys.exc_info()
380+
logging.error(str(traceback.format_tb(tb)))
370381
#os.system("kill 1")

0 commit comments

Comments
 (0)