Skip to content

Commit c06df64

Browse files
authored
New README information. (#224)
* Add files via upload * Update README.md * haha oops i forgot discord and pypi links im kinda dumb
1 parent d99a533 commit c06df64

File tree

2 files changed

+115
-46
lines changed

2 files changed

+115
-46
lines changed

.github/banner_transparent.png

14 KB
Loading

README.md

Lines changed: 115 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,89 @@
1+
<div align="center">
2+
<a href="https://pypi.org/project/discord-py-slash-command/">
3+
<img src="https://raw.githubusercontent.com/discord-py-slash-commands/discord-py-interactions/goverfl0w-new-readme/.github/banner_transparent.png" alt="discord-py-interactions" height="128">
4+
</a>
5+
<h2>Your ultimate discord interactions library for <a href="https://github.com/Rapptz/discord.py">discord.py</a>.</h2>
6+
</div>
7+
8+
<div align="center">
9+
<a href="https://app.codacy.com/gh/eunwoo1104/discord-py-slash-command?utm_source=github.com&utm_medium=referral&utm_content=eunwoo1104/discord-py-slash-command&utm_campaign=Badge_Grade_Settings">
10+
<img src="https://api.codacy.com/project/badge/Grade/224bdbe58f8f43f28a093a33a7546456" alt="Codacy Badge">
11+
</a>
12+
<a href="https://discord.gg/KkgMBVuEkx">
13+
<img alt="Discord" src="https://img.shields.io/discord/789032594456576001">
14+
</a>
15+
</div>
16+
117
<p align="center">
2-
<br>
3-
<a href="https://pypi.org/project/discord-py-slash-command/"><img src="https://raw.githubusercontent.com/eunwoo1104/discord-py-slash-command/master/.github/discordpyslashlogo.png" alt="discord-py-slash-command" height="128"></a>
4-
<h2 align = "center">A simple discord slash command handler for <a href="https://github.com/Rapptz/discord.py">discord.py</a></h2>
5-
</p>
6-
<p align="center">
7-
<a href="https://app.codacy.com/gh/eunwoo1104/discord-py-slash-command?utm_source=github.com&utm_medium=referral&utm_content=eunwoo1104/discord-py-slash-command&utm_campaign=Badge_Grade_Settings"><img src="https://api.codacy.com/project/badge/Grade/224bdbe58f8f43f28a093a33a7546456" alt="Codacy Badge"></a>
8-
<a href="https://discord.gg/KkgMBVuEkx"> <img alt="Discord" src="https://img.shields.io/discord/789032594456576001"></a>
9-
</p>
10-
<p align="center">
11-
<a href="#about">About</a> ⦿
12-
<a href="#installation">Installation</a> ⦿
13-
<a href="#examples">Examples</a> ⦿
14-
<a href="https://discord-py-slash-command.readthedocs.io/en/latest/">Documentation</a> ⦿
15-
<a href="https://discord.gg/KkgMBVuEkx">Discord Server</a>
18+
<a href="#about">About</a> |
19+
<a href="#installation">Installation</a> |
20+
<a href="#examples">Examples</a> |
21+
<a href="https://discord.gg/KkgMBVuEkx">Discord</a> |
22+
<a href="https://pypi.org/project/discord-py-slash-command/">PyPI</a>
1623
</p>
1724

18-
## About
19-
Discord Slash Commands are a new implementation for the Bot API that utilize the forward-slash "/" symbol.
20-
Released on 15 December 2020, many bot developers are still learning to learn how to implement this into
21-
their very own bots. This command handler aims to help serve as a guidance for those looking into wanting to add
22-
these new slash commands into their bots for those that use discord.py, building off of the current library
23-
code and substituting its own for where it's needed. *discord-py-slash-command* stands as the first public
24-
slash command handler library to be made for Discord Bot API libraries.
25+
# About
26+
## What is discord-interactions?
27+
discord-interactions is, in the simplest terms, a library extension that builds off of the currently existing
28+
discord.py API wrapper. While we do use our own basic class code for our own library, a large majority of
29+
this library uses discord.py base events in order to make contextualization of interactions relatively easy
30+
for us.
31+
32+
### When did this begin?
33+
In mid-December of 2020, Discord released the very first type of components, **slash commands.** These were
34+
relatively primitive at the time of their debut, however, over time they slowly came to grew more complex
35+
and mutable. This library was created 2 days after the release of slash commands to Discord, and ever since
36+
has been actively growing.
37+
38+
## What do we currently support?
39+
At this time, we are able to provide you an non-exhaustive list, however, incomplete (because Discord are actively
40+
creating more interactions at this time) of all components integrated as interactions:
41+
42+
* Slash Commands
43+
* Buttons
44+
* Selects (also known as *dropdowns* or *menus*)
2545

26-
## Installation
27-
You are able to easily install the *discord-py-slash-command* library by using the given PIP line below:
46+
# Installation
47+
## (Recommended)
48+
We recommend using pip in order to install our library. You are able to do this by typing the following line below:
2849

2950
`pip install -U discord-py-slash-command`
3051

31-
## Examples
32-
### Quick Startup
33-
This is a quick startup method towards using slash commands.
52+
# Examples
53+
## Slash Commands
54+
This example shows a very quick and simplistic solution to implementing a slash command.
55+
3456
```py
35-
import discord
36-
from discord.ext import commands
57+
from discord import Client, Intents, Embed
3758
from discord_slash import SlashCommand, SlashContext
3859

39-
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
60+
bot = Client(intents=Intents.default())
4061
slash = SlashCommand(bot)
4162

4263
@slash.slash(name="test")
43-
async def _test(ctx: SlashContext):
44-
embed = discord.Embed(title="embed test")
45-
await ctx.send(content="test", embeds=[embed])
64+
async def test(ctx: SlashContext):
65+
embed = Embed(title="Embed Test")
66+
await ctx.send(embed=embed)
4667

4768
bot.run("discord_token")
4869
```
4970

50-
### Advanced
51-
This offers implementation of the slash command library in the usage of a cog.
71+
### Cogs
72+
This example serves as an alternative method for using slash commands in a cog instead.
73+
5274
```py
5375
# bot.py
54-
from discord.ext import commands
55-
from discord_slash import SlashCommand
76+
from discord import Client, Intents, Embed
77+
from discord_slash import SlashCommand, SlashContext
5678

57-
bot = commands.Bot(command_prefix="prefix")
58-
slash = SlashCommand(bot, sync_commands=True, sync_on_cog_reload=True)
79+
bot = Client(intents=Intents.default())
80+
slash = SlashCommand(bot)
5981

6082
bot.load_extension("cog")
61-
bot.run("TOKEN")
83+
bot.run("discord_token")
6284

6385
# cog.py
64-
import discord
65-
from discord.ext import commands
86+
from discord import Embed
6687
from discord_slash import cog_ext, SlashContext
6788

6889
class Slash(commands.Cog):
@@ -71,17 +92,65 @@ class Slash(commands.Cog):
7192

7293
@cog_ext.cog_slash(name="test")
7394
async def _test(self, ctx: SlashContext):
74-
embed = discord.Embed(title="embed test")
75-
await ctx.send(content="test", embeds=[embed])
76-
95+
embed = Embed(title="Embed Test")
96+
await ctx.send(embed=embed)
97+
7798
def setup(bot):
7899
bot.add_cog(Slash(bot))
79100
```
80101

102+
## Buttons
103+
This basic example shows how to easily integrate buttons into your commands. Buttons are not limited to
104+
slash commands and may be used in regular discord.py commands as well.
105+
(This example refers off of [slash commands.](#slash-commands))
106+
107+
```py
108+
from discord_slash.utils.manage_components import create_button, create_actionrow
109+
from discord_slash.model import ButtonStyle
110+
111+
buttons = [
112+
create_button(style=ButtonStyle.green, label="A green button"),
113+
create_button(style=ButtonStyle.blue, label="A blue button")
114+
]
115+
action_row = create_actionrow(*buttons)
116+
117+
await ctx.send(components=[action_row])
118+
```
119+
120+
### Advanced
121+
For more advanced use, please refer to our official documentation on [buttons here.](https://discord-py-slash-command.readthedocs.io/en/latest/components.html#responding-to-interactions)
122+
123+
## Selects
124+
This basic example shows how to add selects into our bot. Selects offer the same accessibility as buttons do
125+
in premise of limitations.
126+
(This exmaple refers off of [slash commands.](#slash-commands))
127+
128+
```py
129+
from discord_slash.utils.manage_components import create_select, create_select_option, create_actionrow
130+
131+
select = create_select(
132+
options=[
133+
create_select_option("Lab Coat", value="coat", emoji="🥼"),
134+
create_select_option("Test Tube", value="tube", emoji="🧪"),
135+
create_select_option("Petri Dish", value="dish", emoji="🧫")
136+
],
137+
placeholder="Choose your option",
138+
min_values=1, # the minimum number of options a user must select
139+
max_values=2 # the maximum number of options a user can select
140+
)
141+
action_row = create_actionrow(select)
142+
143+
await ctx.send(components=[action_row])
144+
```
145+
146+
### Advanced
147+
For more advanced use, please refer to our official documentation on [selects here.](https://discord-py-slash-command.readthedocs.io/en/latest/components.html#what-about-selects-dropdowns)
148+
81149
--------
82-
- This library is based on gateway event. If you are looking for webserver based, have a look at this:
150+
151+
- The discord-interactions library is based off of API gateway events. If you are looking for a library webserver-based, please consider:
83152
- [dispike](https://github.com/ms7m/dispike)
84153
- [discord-interactions-python](https://github.com/discord/discord-interactions-python)
85-
- Or for other languages:
154+
- If you are looking for a similar library for other languages, please refer to here:
86155
- [discord-api-docs Community Resources: Interactions](https://discord.com/developers/docs/topics/community-resources#interactions)
87156

0 commit comments

Comments
 (0)