Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 3a841e0

Browse files
committed
Initial commit
0 parents  commit 3a841e0

File tree

5 files changed

+566
-0
lines changed

5 files changed

+566
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist/*
2+
*.pyc
3+
__pycache__/
4+
build/*
5+
*.egg*

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 kenny2discord
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
Support slash commands.
3+
4+
Example Usage
5+
=============
6+
7+
.. code-block:: python
8+
9+
from discord.ext import slash
10+
client = slash.SlashBot(
11+
# normal arguments to commands.Bot()
12+
command_prefix='.', description="whatever",
13+
# special option: modify all global commands to be
14+
# actually guild commands for this guild instead,
15+
# for the purposes of testing. Remove this argument
16+
# or set it to None to make global commands be
17+
# properly global - note that they take 1 hour to
18+
# propagate. Useful because commands are
19+
# re-registered every time the bot starts.
20+
debug_guild=7293012031203012
21+
)
22+
23+
msg_opt = slash.Option(
24+
# description of option, shown when filling in
25+
description='Message to send',
26+
# this means that the slash command will not be invoked
27+
# if this argument is not specified
28+
required=True)
29+
30+
@client.slash_cmd() # global slash command
31+
async def repeat( # command name
32+
ctx: slash.Context, # there MUST be one argument annotated with Context
33+
message: msg_opt
34+
):
35+
"""Send a message in the bot's name""" # description of command
36+
await ctx.respond(message, # respond to the interaction
37+
# sends a message without showing the command invocation
38+
rtype=slash.InteractionResponseType.ChannelMessage)
39+
40+
client.run(token)
41+
42+
Notes
43+
=====
44+
* ``slash.Context`` emulates ``commands.Context``, but only to a certain extent.
45+
Notably, ``ctx.message`` does not exist, because slash commands can be run
46+
completely without the involvement of messages. However, channel and author
47+
information is still available.
48+
* All descriptions are **required**.
49+
50+
Not Yet Supported
51+
=================
52+
* Subcommands

0 commit comments

Comments
 (0)