Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tandemdude committed Feb 16, 2024
1 parent 2c29658 commit 5d1ed4c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 238 deletions.
180 changes: 0 additions & 180 deletions docs/source/extension-libs.rst

This file was deleted.

56 changes: 29 additions & 27 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Getting Started
===============

Lightbulb can be installed using Python's pip:
Lightbulb can be installed using pip:

``$ pip install hikari-lightbulb``

Expand All @@ -19,23 +19,29 @@ Creating Your First Bot
Your first bot can be written in just a few lines of code:
::

# Import the command handler
# Import the libraries
import hikari
import lightbulb

# Instantiate a Bot instance
bot = lightbulb.BotApp(token="your_token_here", prefix="your_prefix_here")

# Register the command to the bot
@bot.command
# Use the command decorator to convert the function into a command
@lightbulb.command("ping", "checks the bot is alive")
# Define the command type(s) that this command implements
@lightbulb.implements(lightbulb.PrefixCommand)
# Define the command's callback. The callback should take a single argument which will be
# an instance of a subclass of lightbulb.Context when passed in
async def ping(ctx: lightbulb.Context) -> None:
# Send a message to the channel the command was used in
await ctx.respond("Pong!")
# Create a GatewayBot instance
bot = hikari.GatewayBot("your_token_here")
client = lightbulb.client_from_app(bot)

# Register the command with the client
@client.register()
class Ping(
# Command type - builtins include SlashCommand, UserCommand, and MessageCommand
lightbulb.SlashCommand,
# Command declaration parameters
name="ping",
description="checks the bot is alive",
):
# Define the command's invocation method. This method must take the context as the first
# argument (excluding self) which contains information about the command invocation.
@lightbulb.invoke
async def invoke(self, ctx: lightbulb.Context) -> None:
# Send a message to the channel the command was used in
await ctx.respond("Pong!")

# Run the bot
# Note that this is blocking meaning no code after this line will run
Expand All @@ -45,18 +51,12 @@ Your first bot can be written in just a few lines of code:
When this code is run, you will get some logging information and a Hikari banner printed across your
terminal. The bot will be online and you can test out the command!

.. note::
You should note that the order that the decorators are applied is rather important. The ``lightbulb.implements``
decorator should **always** be on the bottom of the stack, followed by the ``lightbulb.command`` decorator on top
of it. The ``bot.command`` decorator **must** always be on the top of the stack if you are using it.

Optional: Setting up logging
============================

Lightbulb uses the ``logging`` library for the logging of useful information for debugging and testing purposes. For
example, if the logging level is set to debug, messages will be displayed every time a command, plugin or extension
is added or removed. This can be changed by using the ``logs`` argument if you want to keep the customization that
``hikari`` does by default. Alternatively, you can use ``logging`` directly.
Lightbulb uses the ``logging`` library for the logging of useful information for debugging and testing purposes.
This can be changed by using the ``logs`` argument of the ``GatewayBot`` constructor. Alternatively, you can use
``logging`` directly.

Changing the logging level with using the ``logs`` argument:
::
Expand All @@ -65,7 +65,8 @@ Changing the logging level with using the ``logs`` argument:
import lightbulb

# Set to debug for both lightbulb and hikari
bot = lightbulb.BotApp(..., logs="DEBUG")
bot = hikari.GatewayBot(..., logs="DEBUG")
...

bot.run()

Expand All @@ -76,7 +77,7 @@ Using different logging levels for both ``hikari`` and ``lightbulb``:
import lightbulb

# Set different logging levels for both lightbulb and hikari
bot = lightbulb.BotApp(
bot = hikari.GatewayBot(
...,
logs={
"version": 1,
Expand All @@ -88,6 +89,7 @@ Using different logging levels for both ``hikari`` and ``lightbulb``:
},
},
)
...

bot.run()

Expand Down
2 changes: 1 addition & 1 deletion docs/source/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Guides
Here you will find an index of all the guide pages to help with using Lightbulb.

If you feel like any feature is unclear or hard to use then either make a pull request to add a guide for it yourself, or
contact thomm.o#8637 on discord.
contact thomm.o on discord.

**Index:**

Expand Down
2 changes: 1 addition & 1 deletion docs/source/hikari-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Hikari Basics
Here you will find an index of all the Hikari Basics pages to help with common issues developers encounter while using Hikari.

If you feel like any Hikari feature is unclear or hard to use then either make a pull request to add a section for it yourself, or
contact thomm.o#8637 on discord.
contact thomm.o on discord.

**Index:**

Expand Down
37 changes: 8 additions & 29 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,46 +40,26 @@ you should submit an issue on the GitHub repository `here <https://github.com/ta
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.

Also see `Tanjun <https://fasterspeeding.github.io/Tanjun/master/>`_ if you would prefer different command handler
syntax. I recommend taking a look at both Lightbulb and Tanjun before choosing which one you wish to use for your bot.

`View Tanjun on GitHub <https://github.com/FasterSpeeding/Tanjun>`_

Helpful Resources:
------------------

- `Hikari Documentation <https://www.hikari-py.dev/>`_

- `Lightbulb Tutorial <https://novanai.readthedocs.io/en/latest/lightbulb/index.html>`_ (Thanks to Nova)

- :ref:`guides`

- :ref:`extension-libs`

Contributors:
-------------

- `thomm.o#8637 (creator) <https://github.com/tandemdude>`_

- `davfsa#7026 <https://github.com/davfsa>`_
Maintainers:
------------

- `nekoka#8788 <https://gitlab.com/nekokatt>`_
- `thomm.o (creator) <https://github.com/tandemdude>`_

- `Forbidden#0001 <https://github.com/Forbidden-A>`_

- `Dec0Ded#2693 <https://github.com/Dec0Dedd>`_

- `Yoda#0660 <https://github.com/YodaPY>`_

- `M.A#4999 <https://gitlab.com/MonAaraj>`_

- `norizon#2612 <https://github.com/norinorin>`_
- `nulldomain <https://github.com/null-domain>`_

- `benn#1953 <https://github.com/ben2224>`_
Special Thanks:
---------------

- `Parafoxia#1911 <https://github.com/parafoxia>`_
- `nekokatt <https://gitlab.com/nekokatt>`_ for helping with the early stages of lightbulb and teaching me much of what I know.

- `nulldomain <https://github.com/null-domain>`_
- `davfsa <https://github.com/davfsa>`_ for maintaining Hikari for all this time. Without which lightbulb could not exist.

Index:
------
Expand All @@ -91,7 +71,6 @@ Index:
guide
api-reference
changelog
extension-libs
hikari-basics

* :ref:`genindex`

0 comments on commit 5d1ed4c

Please sign in to comment.