@@ -3,75 +3,20 @@ DiscTools
33
44About
55-----
6- This library is about discord.py helper classes, functions and alternatives, which can not (& should not) be included in discord.py library .
6+ This library is about discord.py helper classes, functions and alternatives.
77
88Installation
99------------
10- Can be simply done with ``pip install DiscTools ``.
11- Or you can get the freshly harvested code by ``pip install git+https://github.com/TEEN-BOOM/DiscTools.git@master#egg=DiscTools ``
10+ ``pip install DiscTools ``
11+ Or you can install the dev version by ``pip install git+https://github.com/TEEN-BOOM/DiscTools.git@master#egg=DiscTools ``
1212
1313
1414Example
1515-------
1616A basic Bot using DiscTools
1717
18- .. code-block :: python3
19-
20- import disctools
21- from discord.ext import commands
22- import logging
23-
24- logging.basicConfig(
25- format='%(asctime)s | %(name)s | %(levelname)s:: %(message)s',
26- datefmt="[%X]",
27- level=logging.INFO
28- )
29- Bot = disctools.Bot("~")
30-
31- @Bot.inject(name="Test", invoke_without_subcommand=False)
32- class test(disctools.CCmd):
33- async def main(self, ctx):
34- await ctx.send("PASS")
35-
36- async def subcommand_before_invoke(self, ctx):
37- await ctx.send("Test before hook PASS")
38-
39- async def subcommand_after_invoke(self, ctx):
40- await ctx.send("Test after hook PASS")
41-
42- @disctools.inject()
43- class First(disctools.Command):
44- # Usage: `[p]Test First Hi!`
45- async def pre_invoke(self, parent, ctx):
46- return await ctx.send("Preparing...")
47-
48- async def main(self, parent, ctx, *, msg: str = "PASS"):
49- return await ctx.send(msg)
50-
51- async def post_invoke(self, parent, ctx):
52- return await ctx.send("Exiting...")
53-
54- class Second(disctools.ICommand, aliases=["s"]):
55- # Usage: `[p]Test [Second|s] Hi!`
56- async def main(self, parent, ctx, *, msg: str = "PASS"):
57- """Interact with discord here, you may write everything here."""
58- return await ctx.send(self.logic(msg))
59-
60- async def logic(self, msg):
61- """Platform agnostic implementation of the command
62-
63- This is not enforced but recommended; it's easier to migrate from discord
64- if the need arises in future"""
65- return msg
66-
67- # You may do this but, without disctools.Command you lose the self argument.
68- @commands.command(cls=disctools.Command, name="Third")
69- async def third(self, ctx, *, msg: str = "PASS"):
70- return await ctx.send(msg)
71-
72- Bot.run("<TOKEN>")
73-
74-
18+ .. literalinclude :: ../examples/basic.py
19+ :language: python3
7520
7621 .. toctree ::
7722 :maxdepth: 2
0 commit comments