Bug fixes, add /serverinfo, closes #73
This commit is contained in:
parent
4482cb1cd0
commit
967d94242e
5 changed files with 52 additions and 24 deletions
|
@ -4,13 +4,13 @@ from pathlib import Path
|
|||
from discord import Intents
|
||||
from discord.ext import commands
|
||||
from discord.utils import find
|
||||
from discord_slash import SlashCommand
|
||||
from psutil import Process
|
||||
|
||||
from jarvis import logo, tasks, utils
|
||||
from jarvis.config import get_config
|
||||
from jarvis.db import DBManager
|
||||
from jarvis.events import guild, member, message
|
||||
from psutil import Process
|
||||
|
||||
from discord_slash import SlashCommand
|
||||
|
||||
if asyncio.get_event_loop().is_closed():
|
||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||
|
@ -25,7 +25,7 @@ jarvis = commands.Bot(
|
|||
)
|
||||
slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True)
|
||||
jarvis_self = Process()
|
||||
__version__ = "1.8.0"
|
||||
__version__ = "1.8.1"
|
||||
|
||||
|
||||
db = DBManager(get_config().mongo).mongo
|
||||
|
|
|
@ -20,17 +20,9 @@ class ModlogCommandCog(commands.Cog):
|
|||
fields = [
|
||||
Field("Command", ctx.name),
|
||||
]
|
||||
if ctx.args:
|
||||
fields.append(
|
||||
Field(
|
||||
"Args",
|
||||
" ".join(ctx.args),
|
||||
False,
|
||||
)
|
||||
)
|
||||
if ctx.kwargs:
|
||||
kwargs_string = " ".join(
|
||||
f"{k}: {ctx.kwargs[k]}" for k in ctx.kwargs
|
||||
f"{k}: {str(ctx.kwargs[k])}" for k in ctx.kwargs
|
||||
)
|
||||
fields.append(
|
||||
Field(
|
||||
|
|
|
@ -2,7 +2,6 @@ from datetime import datetime, timedelta
|
|||
|
||||
import discord
|
||||
from discord.utils import find
|
||||
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.field import Field
|
||||
|
||||
|
@ -41,7 +40,7 @@ def modlog_embed(
|
|||
return embed
|
||||
|
||||
|
||||
def get_latest_log(self, auditlog, target):
|
||||
def get_latest_log(auditlog, target):
|
||||
before = datetime.utcnow() - timedelta(seconds=10)
|
||||
return find(
|
||||
lambda x: x.target.id == target.id and x.created_at > before,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from discord import TextChannel
|
||||
from discord.ext import commands
|
||||
from discord_slash import SlashContext, cog_ext
|
||||
from discord_slash.utils.manage_commands import create_option
|
||||
|
||||
from jarvis.db.types import Star, Starboard
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
from discord_slash import SlashContext, cog_ext
|
||||
from discord_slash.utils.manage_commands import create_option
|
||||
|
||||
supported_images = [
|
||||
"image/png",
|
||||
"image/gif",
|
||||
|
@ -221,11 +221,6 @@ class StarboardCog(commands.Cog):
|
|||
base="star",
|
||||
name="delete",
|
||||
description="Delete a starred message",
|
||||
guild_ids=[
|
||||
862402786116763668,
|
||||
418094694325813248,
|
||||
578757004059738142,
|
||||
],
|
||||
options=[
|
||||
create_option(
|
||||
name="id",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import re
|
||||
from io import BytesIO
|
||||
|
||||
from discord import File, Role, User
|
||||
from discord import File, Guild, Role, User
|
||||
from discord.ext import commands
|
||||
from discord_slash import SlashContext, cog_ext
|
||||
from discord_slash.utils.manage_commands import create_option
|
||||
|
@ -225,6 +225,48 @@ class UtilCog(commands.Cog):
|
|||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@cog_ext.cog_slash(name="serverinfo", description="Get server info")
|
||||
async def _server_info(self, ctx: SlashContext):
|
||||
guild: Guild = ctx.guild
|
||||
|
||||
owner = (
|
||||
f"{guild.owner.name}#{guild.owner.discriminator}"
|
||||
if guild.owner
|
||||
else "||`[redacted]`||"
|
||||
)
|
||||
|
||||
region = guild.region
|
||||
categories = len(guild.categories)
|
||||
text_channels = len(guild.text_channels)
|
||||
voice_channels = len(guild.voice_channels)
|
||||
members = guild.member_count
|
||||
roles = len(guild.roles)
|
||||
role_list = ", ".join(role.name for role in guild.roles)
|
||||
|
||||
fields = [
|
||||
Field(name="Owner", value=owner),
|
||||
Field(name="Region", value=region),
|
||||
Field(name="Channel Categories", value=categories),
|
||||
Field(name="Text Channels", value=text_channels),
|
||||
Field(name="Voice Channels", value=voice_channels),
|
||||
Field(name="Members", value=members),
|
||||
Field(name="Roles", value=roles),
|
||||
]
|
||||
if len(role_list) < 1024:
|
||||
fields.append(
|
||||
Field(name="Role List", value=role_list, inline=False)
|
||||
)
|
||||
|
||||
embed = build_embed(
|
||||
title="", description="", fields=fields, timestamp=guild.created_at
|
||||
)
|
||||
|
||||
embed.set_author(name=guild.name, icon_url=guild.icon_url)
|
||||
embed.set_thumbnail(url=guild.icon_url)
|
||||
embed.set_footer(text=f"ID: {guild.id} | Server Created")
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(UtilCog(bot))
|
||||
|
|
Loading…
Add table
Reference in a new issue