|
15 | 15 | from githubkit import GitHub |
16 | 16 | from githubkit.exception import GitHubException |
17 | 17 | from githubkit.rest import Issue, PullRequest, SimpleUser |
18 | | -from more_itertools import consecutive_groups |
| 18 | +from more_itertools import consecutive_groups, ilen |
19 | 19 | from yarl import URL |
20 | 20 |
|
| 21 | +from ghutils.common.__version__ import VERSION |
21 | 22 | from ghutils.core.cog import GHUtilsCog, SubGroup |
22 | 23 | from ghutils.core.types import LoginState, NotLoggedInError |
23 | 24 | from ghutils.db.models import ( |
@@ -215,38 +216,54 @@ async def status( |
215 | 216 | ): |
216 | 217 | """Show information about GitHub Utils.""" |
217 | 218 |
|
218 | | - embed = Embed( |
219 | | - title="Bot Status", |
220 | | - color=Color.green(), |
221 | | - ) |
222 | | - |
223 | | - commands = list(self.bot.tree.walk_commands()) |
224 | | - |
225 | | - if deployment := self.env.deployment: |
226 | | - commit_url = f"https://github.com/object-Object/discord-github-utils/commit/{deployment.commit_sha}" |
227 | | - embed.add_field( |
228 | | - name="Commit", |
229 | | - value=textwrap.dedent( |
230 | | - f"""\ |
231 | | - [{shorten_sha(deployment.commit_sha)}]({commit_url}): {deployment.commit_message} |
232 | | - {_discord_date(deployment.commit_timestamp)}""" |
233 | | - ), |
| 219 | + if info := self.env.deployment: |
| 220 | + color = Color.green() |
| 221 | + commit_url = f"https://github.com/object-Object/discord-github-utils/commit/{info.commit_sha}" |
| 222 | + commit_info = textwrap.dedent( |
| 223 | + f"""\ |
| 224 | + [{info.short_commit_sha}]({commit_url}): {info.commit_message} |
| 225 | + {_discord_date(info.commit_timestamp)}""" |
| 226 | + ) |
| 227 | + deployment_time_info = _discord_date(info.timestamp) |
| 228 | + else: |
| 229 | + color = Color.orange() |
| 230 | + commit_info = "Unknown" |
| 231 | + deployment_time_info = "Unknown" |
| 232 | + |
| 233 | + embed = ( |
| 234 | + Embed( |
| 235 | + title="Bot Status", |
| 236 | + color=color, |
| 237 | + ) |
| 238 | + .set_footer(text=f"v{VERSION}") |
| 239 | + .add_field( |
| 240 | + name="Deployed commit", |
| 241 | + value=commit_info, |
234 | 242 | inline=False, |
235 | 243 | ) |
236 | | - embed.add_field( |
237 | | - name="Latest deployment", |
238 | | - value=_discord_date(deployment.timestamp), |
| 244 | + .add_field( |
| 245 | + name="Deployment time", |
| 246 | + value=deployment_time_info, |
239 | 247 | inline=False, |
240 | 248 | ) |
241 | | - |
242 | | - embed.add_field( |
243 | | - name="Latest restart", |
244 | | - value=_discord_date(self.bot.start_time), |
245 | | - inline=False, |
| 249 | + .add_field( |
| 250 | + name="Uptime", |
| 251 | + value=_discord_date(self.bot.start_time), |
| 252 | + inline=False, |
| 253 | + ) |
| 254 | + .add_field( |
| 255 | + name="Servers", |
| 256 | + value=f"{len(self.bot.guilds)}", |
| 257 | + ) |
| 258 | + .add_field( |
| 259 | + name="Cogs", |
| 260 | + value=f"{len(self.bot.cogs)}", |
| 261 | + ) |
| 262 | + .add_field( |
| 263 | + name="Commands", |
| 264 | + value=f"{ilen(self.bot.tree.walk_commands())}", |
| 265 | + ) |
246 | 266 | ) |
247 | | - embed.add_field(name="Servers", value=f"{len(self.bot.guilds)}") |
248 | | - embed.add_field(name="Cogs", value=f"{len(self.bot.cogs)}") |
249 | | - embed.add_field(name="Commands", value=f"{len(commands)}") |
250 | 267 |
|
251 | 268 | await respond_with_visibility(interaction, visibility, embed=embed) |
252 | 269 |
|
|
0 commit comments