diff --git a/.github/workflows/dev-docs.yml b/.github/workflows/dev-docs.yml index 2ac795b1..6292ded3 100644 --- a/.github/workflows/dev-docs.yml +++ b/.github/workflows/dev-docs.yml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | pip install git+https://github.com/squidfunk/mkdocs-material.git@8.0.0b2 - pip install mkdocstrings httpx mkdocs-literate-nav mkdocs-gen-files mike + pip install mkdocstrings[python] httpx mkdocs-literate-nav mkdocs-gen-files mike - name: Configure Git user run: | diff --git a/docs/bases.md b/docs/bases.md index ec676495..cde64d2a 100644 --- a/docs/bases.md +++ b/docs/bases.md @@ -15,4 +15,4 @@ user = client.get_base_user(1) async for username in user.username_history(): print(username) ``` -This code is functionally identical but won't send any unnecessary requests. \ No newline at end of file +This code is functionally identical but won't send any unnecessary requests. Note that `get_base_XYZ` functions are not asynchronous, so you do not need to await them. diff --git a/docs/tutorial/group-bot/setup.md b/docs/tutorial/group-bot/setup.md new file mode 100644 index 00000000..81381d4b --- /dev/null +++ b/docs/tutorial/group-bot/setup.md @@ -0,0 +1,34 @@ +# Discord-Roblox Group Management Bot +One of the most common uses of ro.py is for Discord-Roblox bots, usually for managing groups. In this guide, we'll create a bot from scratch using [discord.py](https://discordpy.readthedocs.io/en/stable/) and ro.py to manage a group. +While this will all work on its own, you will likely need to make modifications to have some parts work in your own bot (if you already have one). +!!! note + This tutorial uses discord.py prefix commands, which will require the Message Content intent to be enabled on + September 1st, 2022. Concepts related to ro.py will likely still apply when using application commands, but this + guide does not use them. + +## Prerequisites +* Basic knowledge (and how to use [async/await syntax](https://realpython.com/async-io-python/#the-asyncawait-syntax-and-native-coroutines)) and installation of Python +* Basic knowledge of discord.py + +## Setup +Before we get started, there are 2 packages we need to install. Use the following commands in your terminal: +``` +pip install discord.py +pip install roblox +``` +Next, create a new Python file wherever on your system that you'd like. Once you've done so, open it in your favorite editor, and add the following: +```python title="main.py" +import discord +from discord.ext import commands +import roblox + +bot = commands.Bot("!", intents=discord.Intents.default()) +# If your bot will do other things, you may need different intents. Check https://discordpy.readthedocs.io/en/stable/intents.html for information on how to use intents. +client = roblox.Client("YOUR_TOKEN_HERE") +``` +Here, we've imported the discord.py package, the commands extension, and the ro.py package, then created a new Discord Bot Client and Roblox Client. Replace `YOUR_TOKEN_HERE` with your [.ROBLOSECURITY](https://ro.py.jmk.gg/dev/roblosecurity/) token. +!!! danger + Under no circumstances should you give anyone else access to your .ROBLOSECURITY token, as this gives them access + to your account. It is recommended to use an alternate account for this, and one with only the permissions necessary + for your bot to function. It is also recommended to [enable 2FA](https://en.help.roblox.com/hc/articles/212459863), + as this makes it much more difficult for some to randomly gain access to your account, even if they know your password. diff --git a/roblox/client.py b/roblox/client.py index fbea3a43..65c93aa2 100644 --- a/roblox/client.py +++ b/roblox/client.py @@ -221,7 +221,7 @@ def get_base_user(self, user_id: int) -> BaseUser: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: user_id: A Roblox user ID. @@ -282,7 +282,7 @@ def get_base_group(self, group_id: int) -> BaseGroup: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: group_id: A Roblox group ID. @@ -335,7 +335,7 @@ def get_base_universe(self, universe_id: int) -> BaseUniverse: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: universe_id: A Roblox universe ID. @@ -389,7 +389,7 @@ def get_base_place(self, place_id: int) -> BasePlace: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: place_id: A Roblox place ID. @@ -430,7 +430,7 @@ def get_base_asset(self, asset_id: int) -> BaseAsset: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: asset_id: A Roblox asset ID. @@ -484,7 +484,7 @@ def get_base_plugin(self, plugin_id: int) -> BasePlugin: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: plugin_id: A Roblox plugin ID. @@ -525,7 +525,7 @@ def get_base_badge(self, badge_id: int) -> BaseBadge: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: badge_id: A Roblox badge ID. @@ -542,7 +542,7 @@ def get_base_gamepass(self, gamepass_id: int) -> BaseGamePass: !!! note This method does not send any requests - it just generates an object. - For more information on bases, please see [Bases](/bases). + For more information on bases, please see [Bases](/dev/bases). Arguments: gamepass_id: A Roblox gamepass ID.