Changed directory structure

This commit is contained in:
Vegard Berg 2022-10-15 02:51:21 +02:00
parent 4441737d57
commit 8aec106671
Signed by: myrkvi
GPG Key ID: BFE35EA1A44D5E40
10 changed files with 36 additions and 19 deletions

View File

@ -157,13 +157,13 @@ def main():
JoinLeave.create_table()
# Load extensions
bot.load_extension("commands.admin")
bot.load_extension("commands.gatekeep")
bot.load_extension("commands.quote")
bot.load_extension("commands.infractions")
bot.load_extension("commands.self_roles")
bot.load_extension("commands.polls")
bot.load_extension("commands.bot_messages")
bot.load_extension("heimdallr.commands.admin")
bot.load_extension("heimdallr.commands.gatekeep")
bot.load_extension("heimdallr.commands.quote")
bot.load_extension("heimdallr.commands.infractions")
bot.load_extension("heimdallr.commands.self_roles")
bot.load_extension("heimdallr.commands.polls")
bot.load_extension("heimdallr.commands.bot_messages")
bot.start(getenv("DISCORD_TOKEN"))
if __name__ == "__main__":

View File

@ -15,6 +15,7 @@ from naff import (
Button,
ButtonStyles,
)
from naff.ext.paginators import Paginator
from peewee import fn
from database import (
GuildSettings,
@ -59,7 +60,10 @@ class Infractions(Extension):
)
embeds.append(embed)
await ctx.send(embed=embeds, ephemeral=True)
# await ctx.send(embed=embeds, ephemeral=True)
paginator = Paginator.create_from_embeds(self.client, *embeds)
await paginator.send(ctx)
paginator.send
@slash_command(
name="user-infractions",
@ -121,6 +125,7 @@ class Infractions(Extension):
)
embeds.append(embed)
if len(embeds) <= 10:
await ctx.send(
content=f"{user.mention} has {infractions_weight[0].total_infractions} infractions, for a total weight of {infractions_weight[0].total_weight:.2f}"
if infractions_weight.count() > 0
@ -128,6 +133,15 @@ class Infractions(Extension):
embed=embeds,
ephemeral=False,
)
else:
await ctx.send(
content=f"{user.mention} has {infractions_weight[0].total_infractions} infractions, for a total weight of {infractions_weight[0].total_weight:.2f}"
if infractions_weight.count() > 0
else None,
embed=embeds[:10],
ephemeral=False,
)
await ctx.send(embed=embeds[10:])
@slash_command(
name="warn",
@ -209,7 +223,6 @@ class Infractions(Extension):
ephemeral=True,
)
# TODO: Add this in again when GuildSettings is implemented
guild_settings: Optional[GuildSettings] = GuildSettings.get_or_none(GuildSettings.guild_id == int(ctx.guild_id))
if guild_settings is not None:
@ -271,6 +284,7 @@ class Infractions(Extension):
)
]
given_by: Member = await self.client.fetch_member(f"{infraction.given_by}", ctx.guild_id)
await ctx.send(
content="Remove this infraction? (times out in 60 seconds)",
embed=Embed(
@ -284,7 +298,7 @@ class Infractions(Extension):
value=f"<t:{int(infraction.at_time.timestamp())}:F>",
),
EmbedField(name="**Severity**", value=f"{infraction.weight}"),
EmbedField(name="**Issued by**", value=f"{infraction.given_by}"),
EmbedField(name="**Issued by**", value=f"{given_by.display_name} ({given_by.username}#{given_by.discriminator})"),
],
),
ephemeral=True,

View File

@ -309,7 +309,6 @@ class Polls(Extension):
@listen(events.Button)
async def on_button(self, button: events.Button):
ctx = button.context
await ctx.defer(ephemeral=True)
# Ensure that the pressed button is a vote button.
if ctx.custom_id.startswith("poll-vote:"):
@ -325,6 +324,7 @@ class Polls(Extension):
if poll_entry.expires and datetime.now() > poll_entry.expires:
return
await ctx.defer(ephemeral=True)
if not poll_entry.multiple_choice:
votes_q: List[PollVotesModel] = PollVotesModel.select().where(
PollVotesModel.poll_id == poll_id,

View File

@ -4,6 +4,9 @@ version = "0.1.0"
description = "A moderation and general-purpose Discord bot, originally intended for the Norwegian Language Learning community."
authors = ["Vegard Berg <vgberg@gmail.com>"]
[tool.poetry.scripts]
heimdallr = "heimdallr.Heimdallr:main"
[tool.poetry.dependencies]
python = "^3.10"
peewee = "^3.15.1"

2
run.sh
View File

@ -1,6 +1,6 @@
#! /bin/sh
if command -v poetry > /dev/null; then
poetry install -q && poetry run python Heimdallr.py
poetry install -q && poetry run python heimdallr/Heimdallr.py
else
echo "Poetry must be installed and available in the PATH" >&2
fi