Skip to content

Commit

Permalink
add core plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mudkipdev committed Jul 24, 2024
1 parent d95623a commit 2e7f043
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 3 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"[python]": {
"editor.formatOnSave": true
},
"editor.defaultFormatter": "charliermarsh.ruff",
"files.exclude": {
"**/__pycache__": true
}
Expand Down
71 changes: 70 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ python = "3.12.4"
python-dotenv = "^1.0.1"
uvloop = "^0.19.0"
hikari = { extras = ["speedups"], version = "^2.0.0.dev126" }
hikari-arc = "^1.3.4"
hikari-miru = "^4.1.1"

[tool.poetry.group.dev.dependencies]
ruff = "^0.5.4"
Expand Down
1 change: 1 addition & 0 deletions scnewsbot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "2.0.0"
14 changes: 12 additions & 2 deletions scnewsbot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
from hikari import GatewayBot, Intents
from dotenv import load_dotenv
from hikari import GatewayBot, Intents
import arc


EXTENSIONS = ("core",)


def main() -> None:
load_dotenv()
load_dotenv()
token = os.getenv("DISCORD_TOKEN")

if not token:
Expand All @@ -13,9 +17,15 @@ def main() -> None:

if os.name != "nt":
import uvloop

uvloop.install()

bot = GatewayBot(intents=Intents.ALL_UNPRIVILEGED, token=token)
client = arc.GatewayClient(bot)

for extension in EXTENSIONS:
client.load_extension(extension)

bot.run()


Expand Down
49 changes: 49 additions & 0 deletions scnewsbot/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from __init__ import __version__
from platform import python_version
from datetime import datetime
import hikari
import arc
import miru

start_time = datetime.now()
plugin = arc.GatewayPlugin("Core")
arc.loader(lambda client: client.add_plugin(plugin))
arc.unloader(lambda client: client.remove_plugin(plugin))


@plugin.include
@arc.slash_command("about", "Shows you some info about the bot.")
async def about(
context: arc.GatewayContext,
):
libraries = f"- Python {python_version()}\n"
libraries += f"- Hikari {hikari.__version__}\n"
libraries += f"- Arc {arc.__version__}\n"
libraries += f"- Miru {miru.__version__}"

embed = hikari.Embed(
color=0x00DD99,
title="About",
description="""
SCNewsBot is a Discord bot created for the r/starcitizen
Discord server to help with writing news posts.
""",
)
embed.add_field(name="Version", value="v" + __version__)
embed.add_field(name="Author", value="[mudkip](https://mudkip.dev)")
embed.add_field(name="Uptime", value=f"<t:{round(start_time.timestamp())}:R>")
embed.add_field(name="Libraries", value=libraries)

view = miru.View()
view.add_item(
miru.LinkButton(
label="Source Code",
url="https://github.com/mudkipdev/scnewsbot/tree/rewrite",
)
)

await context.respond(
embed=embed,
components=view,
flags=hikari.MessageFlag.EPHEMERAL,
)

0 comments on commit 2e7f043

Please sign in to comment.