Skip to content

Commit

Permalink
Refactor into namespace package for lightbulb
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonJonn committed Dec 13, 2021
1 parent 37e3815 commit 2afc2c4
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 23 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Neon

Neon is an add-on for [Lightbulb](https://github.com/tandemdude/hikari-lightbulb/) making it easier to handle component interactions.
**Neon** is an add-on for [Lightbulb](https://github.com/tandemdude/hikari-lightbulb/) making it easier to handle component interactions.

## Installation

```bash
pip install git+https://github.com/neonjonn/lightbulb-neon.git
pip install git+https://github.com/neonjonn/lightbulb-ext-neon.git
```

## Documentation
Expand All @@ -15,6 +15,8 @@ pip install git+https://github.com/neonjonn/lightbulb-neon.git
## Usage

```python
from lightbulb.ext import neon

class Menu(neon.ComponentMenu):
@neon.button("earth", "earth_button", hikari.ButtonStyle.SUCCESS, emoji="\N{DECIDUOUS TREE}")
async def earth(self, button: neon.Button) -> None:
Expand All @@ -41,16 +43,17 @@ class Menu(neon.ComponentMenu):
@lightbulb.implements(lightbulb.SlashCommand, lightbulb.PrefixCommand)
async def neon_command(ctx: lightbulb.Context) -> None:
menu = Menu(ctx, timeout=30)
resp = await ctx.respond("Bar", components=menu.build())
resp = await ctx.respond("Check out Neon's component builder!", components=menu.build())
await menu.run(resp)
```

## Contributing

If you wish to contribute to this project, please [open an issue](https://github.com/neonjonn/lightbulb-neon/issues/new) first to describe your issue or feature request.
If you wish to contribute to this project, please [open an issue](https://github.com/neonjonn/lightbulb-ext-neon/issues/new) first to describe your issue or feature request.

As soon as you've done that you may make a pull request, and I'll review your changes.

## Contributors

* [thomm.o](https://github.com/tandemdude) - [Refactor, improve code, mypy compliance](https://github.com/neonjonn/lightbulb-neon/pull/1)
* [thomm.o](https://github.com/tandemdude) - [Refactor, improve code, mypy compliance](https://github.com/neonjonn/lightbulb-ext-neon/pull/1)
* [Coler6gamer](https://github.com/Coler6gamer) - [Removed blocking return statement](https://github.com/neonjonn/lightbulb-ext-neon/pull/2)
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
black>=21.12b0
isort>=5.10.1
python-dotenv>=0.19.2
2 changes: 1 addition & 1 deletion doc_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
furo~=2021.11.23
sphinx==4.3.1
sphinx~=4.3.1
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
copyright = "2021-present, NeonJonn"
author = "NeonJonn"

with open("../../neon/__init__.py") as fp:
with open("../../lightbulb/ext/neon/__init__.py") as fp:
file = fp.read()
version = re.search(r"__version__ = \"([^\"]+)", file).group(1)
release = version
Expand Down
14 changes: 7 additions & 7 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Getting Started
Before you start
================

* Make sure you're on the latest version of ``lightbulb-neon``.
* Make sure you're on the latest version of ``lightbulb-ext-neon``.

Basic Button Menu
=================
Expand All @@ -16,22 +16,22 @@ This assumes ``bot`` is an instance of :obj:`lightbulb.BotApp`

.. code-block:: python
import neon
from lightbulb.ext import neon
class Menu(neon.ComponentMenu):
@neon.button("fire", "fire_button", hikari.ButtonStyle.DANGER, emoji="\N{FIRE}")
async def fire(self) -> None:
await self.edit_msg("\N{FIRE}")
@bot.command
@lightbulb.command("flames", "Make a cosy fire")
@lightbulb.implements(lightbulb.SlashCommand)
@lightbulb.command("fire", "Make a cosy fire!")
@lightbulb.implements(lightbulb.PrefixCommand, lightbulb.SlashCommand)
async def fire_command(ctx: lightbulb.Context) -> None:
menu = Menu(ctx)
resp = await ctx.respond("Bar", components=menu.build())
resp = await ctx.respond("Make a cosy fire!", components=menu.build())
await menu.run(resp)
When the ``flames`` command is ran, it will produce a message with a red button, that says ``fire`` next to the 🔥 emoji.
When the ``flames`` command is ran, it will produce a message with a red button that says ``fire`` next to the 🔥 emoji.

.. note::

Expand Down Expand Up @@ -75,7 +75,7 @@ Select Menus
@neon.option("Earth", "earth", emoji="\N{DECIDUOUS TREE}")
@neon.select_menu("select_menu", "Pick earth or water!")
async def select_menu_test(self, values: list) -> None:
await self.edit_msg(values[0])
await self.edit_msg(f"You chose: {values[0]}")
.. note::

Expand Down
6 changes: 4 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Neon

Neon is an add-on for `Lightbulb <https://github.com/tandemdude/hikari-lightbulb>`_ making it easier to handle component interactions

Repository: `View on GitHub <https://github.com/neonjonn/lightbulb-neon>`_
Repository: `View on GitHub <https://github.com/neonjonn/lightbulb-ext-neon>`_

Docs: `View Here <https://lightbulb-neon.readthedocs.io/en/latest>`_

If you need any help with this library, Lightbulb or Hikari at any point feel free to join the `Discord Server <https://discord.gg/ACpBqbAyC9>`_

If you think you have found a bug or other problem with the library, or you would like to suggest a feature,
you should submit an issue on the GitHub repository `here <https://github.com/neonjonn/lightbulb-neon/issues>`_.
you should submit an issue on the GitHub repository `here <https://github.com/neonjonn/lightbulb-ext-neon/issues>`_.
Before doing so you should make sure you are on the latest version of the library and check to see if an issue
already exists for your bug or feature.

Expand All @@ -30,6 +30,8 @@ already exists for your bug or feature.
**Contributors:**

- `NeonJonn#1650 (creator) <https://github.com/neonjonn>`_
- `thomm.o#8637 <https://github.com/tandemdude>`_
- `Coler#1987 <https://github.com/Coler6gamer>`_

**Index:**

Expand Down
4 changes: 2 additions & 2 deletions examples/button_menu.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

import dotenv
import lightbulb
from hikari import ButtonStyle

import neon
import lightbulb
from lightbulb.ext import neon

dotenv.load_dotenv()

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion neon/neon.py → lightbulb/ext/neon/neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
import typing as t

import hikari
import lightbulb
from hikari.interactions.component_interactions import ComponentInteraction

import lightbulb

CallbackT = t.TypeVar(
"CallbackT", bound=t.Callable[..., t.Coroutine[t.Any, t.Any, None]]
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hikari-lightbulb>=2.0.4
hikari-lightbulb~=2.1.0
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

from setuptools import find_namespace_packages, setup

name = "neon"
name = "lightbulb"


def parse_meta():
with open(os.path.join(name, "__init__.py")) as fp:
with open(os.path.join("lightbulb", "ext", "neon", "__init__.py")) as fp:
code = fp.read()

token_pattern = re.compile(
Expand Down Expand Up @@ -57,7 +57,7 @@ def parse_requirements_file(path):
meta = parse_meta()

setup(
name="lightbulb-neon",
name="lightbulb-ext-neon",
version=meta.version,
description="An add-on for Lightbulb making it easier to handle component interactions",
long_description=long_description(),
Expand Down

0 comments on commit 2afc2c4

Please sign in to comment.