├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── snippet-request.md └── workflows │ └── publish.yml ├── .gitignore ├── .vscodeignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── examples ├── aiohttp_example.gif ├── cog_example.gif ├── command_example.gif ├── event_example.gif └── starter_example.gif ├── icon.png ├── package-lock.json ├── package.json └── snippets └── snippets.code-snippets /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | 1. Write '...' 17 | 18 | 2. Press '...' 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | 28 | - OS: [e.g. Windows 10] 29 | 30 | - Visual Studio Code Version [e.g. 1.50] 31 | 32 | - Extension Version [e.g. 1.2.1] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/snippet-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Snippet request 3 | about: Suggest a snippet idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the snippet you'd like** 14 | A clear and concise description of what you want the snippet to have. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - "*" 5 | 6 | name: Deploy Extension 7 | jobs: 8 | deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-node@v1 13 | with: 14 | node-version: 12 15 | - run: npm ci 16 | - name: Publish to Visual Studio Marketplace 17 | uses: HaaLeo/publish-vscode-extension@v0 18 | with: 19 | pat: ${{ secrets.VS_MARKETPLACE_TOKEN }} 20 | registryUrl: https://marketplace.visualstudio.com 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # VSIX File 2 | *.vsix 3 | 4 | # vscode history folder 5 | .history/ 6 | 7 | # vscode settings folder 8 | .vscode/ 9 | 10 | # .py files used for testing 11 | *.py -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | # vscode files 2 | .vscode/** 3 | .vscode-test/** 4 | 5 | # github files 6 | .github/** 7 | .gitignore 8 | .gitattributes 9 | 10 | # testing files 11 | *.py 12 | *.vsix 13 | 14 | # examples 15 | examples/** 16 | 17 | # markdown files 18 | vsc-extension-quickstart.md 19 | LICENSE 20 | CODE_OF_CONDUCT.md 21 | CONTRIBUTING.md -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "discord-py-snippets" extension will be documented in this file. 4 | 5 | ## [1.0.0] 6 | 7 | - Initial release of discord.py-snippets extension 8 | 9 | ## [1.0.1] 10 | 11 | - Fixed some bugs 12 | 13 | ## [1.1.0] 14 | 15 | - Added 3 new snippets, `!gbchk`, `!cgchk` & `!embedhelp` 16 | - Added more info in the readme file 17 | 18 | ## [1.2.0] 19 | 20 | - Added not shadowing command snippets (for function names for commands that are already defined eg. eval) 21 | - Added embed snippets 22 | - embed 23 | - field 24 | - footer 25 | - author 26 | - image 27 | - thumbnail 28 | 29 | ### [1.2.1] 30 | 31 | - Fixed an issue in the `!emb` snippet where there were double commas 32 | 33 | ### [1.2.2] 34 | 35 | - Fixed an issue in the `!emb` snippet where there was a : where there shouldn't be one 36 | 37 | ### [1.3.0] 38 | 39 | - Added Group Template `!grp` 40 | - Added Group command Template `!grpcmd` 41 | - Made event names always start with `on_` 42 | - Made it easier to add commands with aliases 43 | - Changed the command in `!dpstrt` from `test` to `hello` 44 | - Made it easier to know what a value is for 45 | 46 | ### [1.3.1] 47 | 48 | - Fixed a bug in `!cgcmd` where the aliases field would have a unnecessary comma 49 | 50 | ### [1.4.0] 51 | 52 | - Changed the `!cog` snippet to use the current file name as the cog name, thanks to QuaKe 53 | - Added `!owner_only` check 54 | - Added `!nsfw_only` check 55 | - Added `!hasperms` check 56 | - Added `!cooldown` decorator 57 | - Added `!waitforreaction` snippet 58 | - Added `!waitformessage` snippet 59 | 60 | ### [1.5.0] 61 | 62 | - Added UI Category with `!button`, `!cbutton` and `!select` 63 | - Added `!except` snippet 64 | - Fixed indendation in `!embedhelp` 65 | 66 | ### [1.5.1] 67 | 68 | - Added a `on_ready` event in the `!dpstrt` snippet 69 | - Fix LICENSE year 70 | 71 | ### [1.5.2] 72 | 73 | - Small fix 74 | 75 | ### [1.5.3] 76 | 77 | - Fix `!grpcmd` snippet 78 | 79 | ### [1.5.4] 80 | 81 | - Fix `!grpcmd` snippet 82 | 83 | ### [1.6.0] 84 | 85 | - Add `!embpagere` snippet 86 | 87 | ### [1.7.0] 88 | 89 | - Add `!guildonly` snippet 90 | - Fix `!embpagere` snippet 91 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at arianmollik323@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Update the README.md with details of changes to the interface, this includes new environment 13 | variables, exposed ports, useful file locations and container parameters. 14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this 15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). 16 | 17 | ## Code of Conduct 18 | 19 | ### Our Pledge 20 | 21 | In the interest of fostering an open and welcoming environment, we as 22 | contributors and maintainers pledge to making participation in our project and 23 | our community a harassment-free experience for everyone, regardless of age, body 24 | size, disability, ethnicity, gender identity and expression, level of experience, 25 | nationality, personal appearance, race, religion, or sexual identity and 26 | orientation. 27 | 28 | ### Our Standards 29 | 30 | Examples of behavior that contributes to creating a positive environment 31 | include: 32 | 33 | * Using welcoming and inclusive language 34 | * Being respectful of differing viewpoints and experiences 35 | * Gracefully accepting constructive criticism 36 | * Focusing on what is best for the community 37 | * Showing empathy towards other community members 38 | 39 | Examples of unacceptable behavior by participants include: 40 | 41 | * The use of sexualized language or imagery and unwelcome sexual attention or 42 | advances 43 | * Trolling, insulting/derogatory comments, and personal or political attacks 44 | * Public or private harassment 45 | * Publishing others' private information, such as a physical or electronic 46 | address, without explicit permission 47 | * Other conduct which could reasonably be considered inappropriate in a 48 | professional setting 49 | 50 | ### Our Responsibilities 51 | 52 | Project maintainers are responsible for clarifying the standards of acceptable 53 | behavior and are expected to take appropriate and fair corrective action in 54 | response to any instances of unacceptable behavior. 55 | 56 | Project maintainers have the right and responsibility to remove, edit, or 57 | reject comments, commits, code, wiki edits, issues, and other contributions 58 | that are not aligned to this Code of Conduct, or to ban temporarily or 59 | permanently any contributor for other behaviors that they deem inappropriate, 60 | threatening, offensive, or harmful. 61 | 62 | ### Scope 63 | 64 | This Code of Conduct applies both within project spaces and in public spaces 65 | when an individual is representing the project or its community. Examples of 66 | representing a project or community include using an official project e-mail 67 | address, posting via an official social media account, or acting as an appointed 68 | representative at an online or offline event. Representation of a project may be 69 | further defined and clarified by project maintainers. 70 | 71 | ### Enforcement 72 | 73 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 74 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All 75 | complaints will be reviewed and investigated and will result in a response that 76 | is deemed necessary and appropriate to the circumstances. The project team is 77 | obligated to maintain confidentiality with regard to the reporter of an incident. 78 | Further details of specific enforcement policies may be posted separately. 79 | 80 | Project maintainers who do not follow or enforce the Code of Conduct in good 81 | faith may face temporary or permanent repercussions as determined by other 82 | members of the project's leadership. 83 | 84 | ### Attribution 85 | 86 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 87 | available at [http://contributor-covenant.org/version/1/4][version] 88 | 89 | [homepage]: http://contributor-covenant.org 90 | [version]: http://contributor-covenant.org/version/1/4/ 91 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2022 Arian Mollik Wasi 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What is discord-py-snippets 2 | 3 | A simple snippets extension for the [discord.py](https://discordpy.readthedocs.io/en/latest/ "discord.py Documentation") package for [python](https://www.python.org "python.org") 4 | 5 |

6 | 7 | VS Code Marketplace Downloads 8 | 9 | 10 | VS Code Marketplace Installs 11 | 12 | 13 | VS Code Marketplace Rating 14 | 15 | 16 |

17 | 18 | ## Features 19 | 20 | ### Making a cog 21 | 22 | ![Cog Example](https://i.imgur.com/gIWNM5E.gif) 23 | 24 | ### Making a command 25 | 26 | ![Command Example](https://i.imgur.com/jUQZywQ.gif) 27 | 28 | ### Starter Template 29 | 30 | ![Starter Example](https://i.imgur.com/waHtA9I.gif) 31 | 32 | ### Making a event 33 | 34 | ![Event Example](https://i.imgur.com/AcoHPfb.gif) 35 | 36 | ### Using the library aiohttp to use a api in a command 37 | 38 | ![AioHTTP Example](https://i.imgur.com/LVZVq33.gif) 39 | 40 | 50 | 51 | ## All Snippets 52 | 53 | ### Normal Snippets 54 | 55 | | Name | Prefix | Description | 56 | |---------------------------------------------|--------------|---------------------------------------------------------------------------------------------------------------------| 57 | | Starter Template | `!dpstrt` | A starter template | 58 | | Basic Command Template | `!cmd` | A basic command template (Not for cogs) | 59 | | Basic Event Template | `!evt` | A basic event template (Not for cogs) | 60 | | Cog Command Template | `!cgcmd` | A basic command template for cogs | 61 | | Cog Event Template | `!cgevt` | A basic event template for cogs | 62 | | Cog Template | `!cog` | A starter template for a cog | 63 | | aiohttp Template | `!ahtp` | A basic aiohttp web request template (You need to have bot.session defined as a instance of aiohttp.ClientSession) | 64 | | Global Check Template | `gbchk` | A basic global check template | 65 | | Cog Check Template | `!cgchk` | A basic cog check template | 66 | | Embed Help | `!embedhelp` | A custom help command implementation that modifies the default help and uses embed | 67 | | Not Shadowing Command Template | `!unscmd` | A basic command template that doesn't shadow another function (Not for cogs) | 68 | | Cog Not Shadowing Command Template | `!cgunscmd` | A basic command template that doesn't shadow another function for cogs | 69 | | Group Template | `!grp` | A group template (Can be used in cogs) | 70 | | Group Command Template | `!grpcmd` | A basic group command template (Can be used in cogs) | 71 | | Wait for reaction Template | `!waitforreaction` | A wait for template for on_reaction_add 72 | | Wait for message Template | `!waitformessage` | A wait for template for on_message 73 | | Discord based exception | `!except` | A basic exception template based on a discord error 74 | 75 | ### Embed Snippets 76 | 77 | | Name | Prefix | Description | 78 | |---------------------------------------------|---------------|-------------------------------------| 79 | | Embed Template | `!emb` | Makes a Embed | 80 | | Embed Field Template | `!embfield` | Adds a field to a embed | 81 | | Embed Footer Template | `!embfoot` | Adds a footer to a embed | 82 | | Embed Author Template | `!embauthor` | Adds a author to a embed | 83 | | Embed Thumbnail Template | `!embthumb` | Adds a image to a embed | 84 | | Embed Image Template | `!embimg` | Adds a thumbnail to a embed | 85 | | Embed Page Reaction Template | `!embpagere` | Makes a embed with page navigation | 86 | 87 | 88 | ### Check Snippets 89 | 90 | | Name | Prefix | Description | 91 | |---------------------------------------------|--------------|---------------------------------------------------| 92 | | Owner only check Template | `!owneronly` | Sets a command as owner_only | 93 | | NSFW only check Template | `!nsfwonly` | Sets a command as nsfw only | 94 | | Has Permissions check Template | `!hasperms` | makes a command require a permission | 95 | | Guild Only check Template | `!guildonly` | makes a command require the user to be in a guld | 96 | 97 | ### UI 98 | 99 | | Name | Prefix | Description | 100 | |---------------------------------------------|--------------|---------------------------------------| 101 | | Button | `!button` | A basic button | 102 | | Custom Button | `!cbutton` | A button with a custom constructor | 103 | | Select | `!select` | A basic select | 104 | 105 | ## Tips and Tricks 106 | 107 | - Use Tab to navigate between required inputs 108 | - Use Shift+Tab to edit the previous input 109 | - Once a input is focused on, press backspace and then press tab to skip it if you don't want to add that 110 | - Once a input is focused on, press tab to skip and keep the default value 111 | - If you don't want something, you can press backspace to remove it 112 | 113 | ## Known Issues 114 | 115 | There isn't many snippets so any suggestions for snippets would be appreciated 116 | 117 | ## Contribute 118 | 119 | You can open a pull request anytime and I will look into it\ 120 | I suggest seeing the [vscode snippets documentation](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets "VSCode Snippets Documentation") before you open a pull request 121 | 122 | ## Release Notes 123 | 124 | ### 1.0.0 125 | 126 | - Initial release of discord.py-snippets 127 | 128 | ### 1.0.1 129 | 130 | - Fixed some bugs 131 | 132 | ### 1.1.0 133 | 134 | - Added 3 new snippets, `!gbchk`, `cgchk` & `!embedhelp`\ 135 | - Added more info in the readme file 136 | 137 | ### 1.2.0 138 | 139 | - Added not shadowing command snippets (for function names for commands that are already defined) 140 | - Added embed snippets 141 | - embed 142 | - field 143 | - footer 144 | - author 145 | - image 146 | - thumbnail 147 | 148 | ### 1.2.1 149 | 150 | - Fixed a issue in the `!emb` snippet where there were double commas 151 | 152 | ### 1.2.2 153 | 154 | - Fixed a issue in the `!emb` snippet where there was a : where there shouldn't be one 155 | 156 | ### 1.3.0 157 | 158 | - Added Group Template `!grp` 159 | - Added Group command Template `!grpcmd` 160 | - Made event names always start with `on_` 161 | - Made it easier to add commands with aliases 162 | - Changed the command in `!dpstrt` from `test` to `hello` 163 | - Made it easier to know what a value is for 164 | 165 | ### 1.3.1 166 | 167 | - Fixed a bug in `!cgcmd` where the aliases field would have a unnecessary comma 168 | 169 | ### 1.4.0 170 | 171 | - Changed the `!cog` snippet to use the current file name as the cog name, thanks to QuaKe 172 | - Added `!owner_only` check 173 | - Added `!nsfw_only` check 174 | - Added `!hasperms` check 175 | - Added `!cooldown` decorator 176 | - Added `!waitforreaction` snippet 177 | - Added `!waitformessage` snippet 178 | 179 | ### 1.5.0 180 | 181 | - Added UI Category with `!button`, `!cbutton` and `!select` 182 | - Added `!except` snippet 183 | - Fixed indendation in `!embedhelp` 184 | 185 | ### 1.5.1 186 | 187 | - Added a `on_ready` event in the `!dpstrt` snippet 188 | 189 | ### 1.5.1 190 | 191 | - Added a `on_ready` event in the `!dpstrt` snippet 192 | - Fix LICENSE year 193 | 194 | ### 1.5.2 195 | 196 | - Small fix 197 | 198 | ### 1.5.3 199 | 200 | - Fix `!grpcmd` snippet 201 | 202 | ### 1.5.4 203 | 204 | - Fix `!grpcmd` snippet 205 | 206 | ### 1.6.0 207 | 208 | - Add `!embpagere` snippet 209 | 210 | ### 1.7.0 211 | 212 | - Add `!guildonly` snippet 213 | - Fix `!embpagere` snippet 214 | 215 | 216 | ### Extensions in the screenshots 217 | 218 | - [Monokai Pro](https://marketplace.visualstudio.com/items?itemName=monokai.theme-monokai-pro-vscode) by [monokai](https://marketplace.visualstudio.com/publishers/monokai) 219 | 220 | - [Bracket Pair Colorizer](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer) by [CoenraadS](https://marketplace.visualstudio.com/publishers/CoenraadS) 221 | 222 | - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) by [Street Side Software](https://marketplace.visualstudio.com/publishers/streetsidesoftware) 223 | 224 | - [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) by [Microsoft](https://marketplace.visualstudio.com/publishers/Microsoft) 225 | 226 | ----------------------------------------------------------------------------------------------------------- 227 | 228 | **Enjoy!** 229 | -------------------------------------------------------------------------------- /examples/aiohttp_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasi-master/vscode-discord.py-snippets/1617c423455f9f3c1b26def5d8a170730d0de244/examples/aiohttp_example.gif -------------------------------------------------------------------------------- /examples/cog_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasi-master/vscode-discord.py-snippets/1617c423455f9f3c1b26def5d8a170730d0de244/examples/cog_example.gif -------------------------------------------------------------------------------- /examples/command_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasi-master/vscode-discord.py-snippets/1617c423455f9f3c1b26def5d8a170730d0de244/examples/command_example.gif -------------------------------------------------------------------------------- /examples/event_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasi-master/vscode-discord.py-snippets/1617c423455f9f3c1b26def5d8a170730d0de244/examples/event_example.gif -------------------------------------------------------------------------------- /examples/starter_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasi-master/vscode-discord.py-snippets/1617c423455f9f3c1b26def5d8a170730d0de244/examples/starter_example.gif -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasi-master/vscode-discord.py-snippets/1617c423455f9f3c1b26def5d8a170730d0de244/icon.png -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-py-snippets", 3 | "version": "1.5.2", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "discord-py-snippets", 9 | "version": "1.5.2", 10 | "engines": { 11 | "vscode": "^0.10.0" 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-py-snippets", 3 | "displayName": "discord.py Code Snippets", 4 | "description": "Code snippets for the discord.py package in python", 5 | "version": "1.7.0", 6 | "publisher": "WasiMaster", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/wasi-master/vscode-discord.py-snippets" 10 | }, 11 | "icon": "icon.png", 12 | "engines": { 13 | "vscode": "^0.10.0" 14 | }, 15 | "keywords": [ 16 | "discord.py", 17 | "discord.js", 18 | "discord", 19 | "JDA", 20 | "discord bot", 21 | "discord snippets", 22 | "discord.py snippets", 23 | "discord.js snippets", 24 | "discord.py code snippets", 25 | "discord.js code snippets" 26 | ], 27 | "categories": [ 28 | "Snippets" 29 | ], 30 | "contributes": { 31 | "snippets": [{ 32 | "language": "python", 33 | "path": "./snippets/snippets.code-snippets" 34 | }] 35 | } 36 | } -------------------------------------------------------------------------------- /snippets/snippets.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | "discord.py Starter Template": { 3 | "prefix": "!dpstrt", 4 | "body": [ 5 | "import discord", 6 | "from discord.ext import commands", 7 | "", 8 | "", 9 | "bot = commands.Bot(command_prefix=\"${1:!}\")", 10 | "", 11 | "", 12 | "@bot.event", 13 | "async def on_ready():", 14 | " print(f\"Logged in as {bot.user}\")", 15 | "", 16 | "", 17 | "@bot.command()", 18 | "async def hello(ctx):", 19 | " await ctx.send(\"Hello, I am a robot\")", 20 | "", 21 | "bot.run(\"${2:Token}\")", 22 | "" 23 | ], 24 | "description": "A starter template" 25 | }, 26 | "discord.py Basic Command Template": { 27 | "prefix": "!cmd", 28 | "body": [ 29 | "@${1|bot,client|}.command(${2:aliases=[\"$3\"]})", 30 | "async def ${4:command_name}(ctx$5):", 31 | " await ctx.send(\"$0\")" 32 | ], 33 | "description": "A basic command template (Not for cogs)" 34 | }, 35 | "discord.py Not Shadowing Command Template": { 36 | "prefix": "!unscmd", 37 | "body": [ 38 | "@${1|bot,client|}.command(name=\"${2:command_name}\"${3:, aliases=[\"$4\"]})", 39 | "async def _${2:command_name}(ctx$5):", 40 | " await ctx.send(\"$0\")" 41 | ], 42 | "description": "A basic command template that doesn't shadow another function (Not for cogs)" 43 | }, 44 | "discord.py Basic Event Template": { 45 | "prefix": "!evt", 46 | "body": [ 47 | "@${1|bot,client|}.event", 48 | "async def on_$2($3):", 49 | " $0" 50 | ], 51 | "description": "A basic event template (Not for cogs)" 52 | }, 53 | "discord.py Cog Command Template": { 54 | "prefix": "!cgcmd", 55 | "body": [ 56 | "@commands.command(${1:aliases=[\"$2\"]})", 57 | "async def ${3:command_name}(self, ctx$4):", 58 | " await ctx.send(\"$0\")" 59 | ], 60 | "description": "A basic command template for cogs" 61 | }, 62 | "discord.py Cog Not Shadowing Command Template": { 63 | "prefix": "!cgunscmd", 64 | "body": [ 65 | "@commands.command(name=\"${1:command_name}\"${2:, aliases=[\"$3\"]})", 66 | "async def _${1:command_name}(self, ctx$4):", 67 | " await ctx.send(\"$0\")" 68 | ], 69 | "description": "A basic command template that doesn't shadow another function for cogs" 70 | }, 71 | "discord.py Cog Event Template": { 72 | "prefix": "!cgevt", 73 | "body": [ 74 | "@commands.Cog.listener()", 75 | "async def on_$1(self, $2):", 76 | " $0" 77 | ], 78 | "description": "A basic event template for cogs" 79 | }, 80 | "discord.py Cog Template": { 81 | "prefix": "!cog", 82 | "body": [ 83 | "import discord", 84 | "from discord.ext import commands", 85 | "", 86 | "", 87 | "class ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}}(commands.Cog):", 88 | " def __init__(self, bot):", 89 | " self.bot = bot", 90 | "", 91 | " $0", 92 | "", 93 | "def setup(bot):", 94 | " bot.add_cog(${1:CogName}(bot))", 95 | "" 96 | ], 97 | "description": "A starter template for a cog" 98 | }, 99 | "discord.py Group Template": { 100 | "prefix": "!grp", 101 | "body": [ 102 | "@${1|bot,client,commands|}.group(invoke_without_${3|subcommand,command|}=${4|True,False|}, name=\"${5:groupcommand_name}\" ${6:, aliases=[\"$7\"]})", 103 | "async def ${2:group_name}(self, ctx$14):", 104 | " await ctx.send(\"$0\")", 105 | "", 106 | "", 107 | "@${2:group_name}.command(name=\"${8:subcommand_name}\"${9:, aliases=[\"$10\"]})", 108 | "async def $2_${8:subcommand_name}(self, ctx$15):", 109 | " await ctx.send(\"\")", 110 | "", 111 | "", 112 | "@${2:group_name}.command(name=\"${11:subcommand_name}\"${12:, aliases=[\"$13\"]})", 113 | "async def $2_${11:subcommand_name}(self, ctx$16):", 114 | " await ctx.send(\"\")" 115 | ], 116 | "description": "A group template" 117 | }, 118 | "discord.py Group Command Template": { 119 | "prefix": "!grpcmd", 120 | "body": [ 121 | "@${1:group_name}.command(name=\"${2:subcommand_name}\"${3:, aliases=[\"$4\"]})", 122 | "async def $1_${2:subcommand_name}(self, ctx$5):", 123 | " await ctx.send(\"$0\")" 124 | ], 125 | "description": "A group command template that is meant to add more commands to a group" 126 | }, 127 | "aiohttp Basic Usage Template": { 128 | "prefix": "!ahtp", 129 | "body": [ 130 | "async with ${1|bot,client,self.bot,self.client|}.session.get(\"$2\") as r:", 131 | " resp = await r.json()", 132 | " $0" 133 | ], 134 | "description": "You need to have bot.session defined as a instance of aiohttp.ClientSession" 135 | }, 136 | "discord.py Global Check Template": { 137 | "prefix": "!gbchk", 138 | "body": [ 139 | "@${1|bot,client|}.check", 140 | "async def ${2:bot_check}(ctx):", 141 | " $0" 142 | ], 143 | "description": "A basic global check template" 144 | }, 145 | "discord.py Cog Check Template": { 146 | "prefix": "!cgchk", 147 | "body": [ 148 | "async def cog_check(self, ctx):", 149 | " $0", 150 | " if $1:", 151 | " return True", 152 | " else:", 153 | " return False", 154 | ], 155 | "description": "A basic cog check template" 156 | }, 157 | "discord.py Embed Help": { 158 | "prefix": "!embedhelp", 159 | "body": [ 160 | "class ${1:MyNew}Help(commands.MinimalHelpCommand):", 161 | " async def send_pages(self):", 162 | " destination = self.get_destination()", 163 | " for page in self.paginator.pages:", 164 | " embed = discord.Embed(description=page)", 165 | " await destination.send(embed=embed)" 166 | ], 167 | "description": "A custom help command implementation that modifies the default help and uses embed" 168 | }, 169 | "discord.py Embed Template": { 170 | "prefix": "!emb", 171 | "body": [ 172 | "embed = discord.Embed(${1:title=\"$2\",} ${3:description=\"$4\",} ${5:color=$6,} ${7:timestamp=$8,})" 173 | ], 174 | "description": "Makes a Embed" 175 | }, 176 | "discord.py Embed Field Template": { 177 | "prefix": "!embfield", 178 | "body": [ 179 | "${1:embed}.add_field(name=\"$2\", value=\"$3\", inline=${4|True,False|})" 180 | ], 181 | "description": "Adds a field to a embed" 182 | }, 183 | "discord.py Embed Footer Template": { 184 | "prefix": "!embfoot", 185 | "body": [ 186 | "${1:embed}.set_footer(text=\"$2\", ${3:icon_url=\"${4}\"})" 187 | ], 188 | "description": "Adds a footer to a embed" 189 | }, 190 | "discord.py Embed Author Template": { 191 | "prefix": "!embauthor", 192 | "body": [ 193 | "${1:embed}.set_author(name=\"$2\", ${3:url=\"${4}\",} ${5:icon_url=\"${6}\"})" 194 | ], 195 | "description": "Adds a author to a embed" 196 | }, 197 | "discord.py Embed Thumbnail Template": { 198 | "prefix": "!embthumb", 199 | "body": [ 200 | "${1:embed}.set_thumbnail(url=\"$2\")" 201 | ] 202 | }, 203 | "discord.py Embed Image Template": { 204 | "prefix": "!embimg", 205 | "body": [ 206 | "${1:embed}.set_image(url=\"$2\")" 207 | ] 208 | }, 209 | "discord.py Owner Only check template": { 210 | "prefix": "!owneronly", 211 | "body": [ 212 | "@commands.is_owner()" 213 | ] 214 | }, 215 | "discord.py NSFW Only check template": { 216 | "prefix": "!nsfwonly", 217 | "body": [ 218 | "@commands.is_nsfw()" 219 | ] 220 | }, 221 | "discord.py Cooldown decorator template": { 222 | "prefix": "!cooldown", 223 | "body": [ 224 | "@commands.cooldown(${1:rate}, ${2:per}, commands.BucketType.${4|user,default,channel,member,guild,category,role|})" 225 | ] 226 | }, 227 | "discord.py has_permissions template": { 228 | "prefix": "!hasperms", 229 | "body": [ 230 | "@commands.has_permissions(${1:permission_name}=True)" 231 | ] 232 | }, 233 | "discord.py guild_only template": { 234 | "prefix": "!guildonly", 235 | "body": [ 236 | "@commands.guild_only()", 237 | ] 238 | }, 239 | "discord.py wait_for template for on_reaction_add": { 240 | "prefix": "!waitforreaction", 241 | "body": [ 242 | "try:", 243 | " reaction, user = await ${1|bot,client,self.bot,self.client|}.wait_for('reaction_add', check=lambda r, u: ${2:u == ctx.author and r.message.channel.id == ctx.channel.id}, timeout=${3|15,30,45,60,120,300,900|})", 244 | "except asyncio.TimeoutError:", 245 | " return await ctx.send(\"You didn't respond\")", 246 | "else:", 247 | " $0" 248 | ] 249 | }, 250 | "discord.py wait_for template for on_message": { 251 | "prefix": "!waitformessage", 252 | "body": [ 253 | "try:", 254 | " message = await ${1|bot,client,self.bot,self.client|}.wait_for('message', check=lambda m: ${2:m.author == ctx.author and m.channel.id == ctx.channel.id}, timeout=${3|15,30,45,60,120,300,900|})", 255 | "except asyncio.TimeoutError:", 256 | " return await ctx.send(\"You didn't respond\")", 257 | "else:", 258 | " $0" 259 | ] 260 | }, 261 | "discord.py embed page reaction template": { 262 | "prefix": "!embpagere", 263 | "body": [ 264 | "# Variable per page can be taken from the parameter command that you created", 265 | "emoji_nextpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$2\")", 266 | "emoji_backpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$3\")", 267 | "emoji_firstpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$4\")", 268 | "emoji_lastpage = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$5\")", 269 | "emoji_lock = discord.utils.get(${1|bot,client,self.bot|}.emojis, name=\"$6\")", 270 | "${7:formart_lb} = []", 271 | "for x in data:", 272 | " ${7:formart_lb}.append(\"${8:this is for the embed description}\")", 273 | "num_of_${9:embeds} = ceil((len(${7:formart_lb}) + 1) / ${10|perpage,1,2,3,4,5,6,7,8,9,10|})", 274 | "${9:embeds} = []", 275 | "page_format = '(Page {}/{})'", 276 | "for i in range(1, num_of_${9:embeds} + 1):", 277 | " ${9:embeds}.append(discord.Embed(${11:\"this is for the description on each embed\"}).set_footer(text=page_format.format(i, num_of_${9:embeds})))", 278 | "${12:embed_index} = 0", 279 | "for ${13:index}, ${14:element} in enumerate(${7:formart_lb}):", 280 | " ${9:embeds}[${12:embed_index}].add_field(name=f'**{${13:index} + 1}.**', value='{}'.format(${14:element}), inline=${15|True,False|})", 281 | " if (${13:index} + 1) % ${10|perpage,1,2,3,4,5,6,7,8,9,10|} == 0:", 282 | " ${12:embed_index} += 1", 283 | "buttons = [emoji_firstpage,emoji_backpage,emoji_lock,emoji_nextpage,emoji_lastpage]", 284 | "curent = 0", 285 | "msg = await ctx.send(embed=${9:embeds}[curent])", 286 | "for bt in buttons:", 287 | " try:", 288 | " await msg.add_reaction(bt)", 289 | " except:", 290 | " pass", 291 | "while True:", 292 | " try:", 293 | " reaction, user = await ${1|bot,client,self.bot|}.wait_for('reaction_add', check=lambda r, u: ${16:u == ctx.author and r.message.channel.id == ctx.channel.id and r.emoji in buttons}, timeout=${17|15,30,45,60,120,300,900|})", 294 | " except asyncio.TimeoutError:", 295 | " for btn in buttons:", 296 | " try:", 297 | " await msg.clear_reaction(btn)", 298 | " except:", 299 | " pass", 300 | " else:", 301 | " previous_page = curent", 302 | " if reaction.emoji == buttons[0]:", 303 | " curent = 0", 304 | " try:", 305 | " await msg.remove_reaction(str(reaction.emoji), user)", 306 | " except:", 307 | " pass", 308 | " await msg.edit(embed=${9:embeds}[curent])", 309 | " elif reaction.emoji == buttons[1]:", 310 | " if curent > 0:", 311 | " curent -= 1", 312 | " try:", 313 | " await msg.remove_reaction(str(reaction.emoji), user)", 314 | " except:", 315 | " pass", 316 | " if curent != previous_page:", 317 | " await msg.edit(embed=${9:embeds}[curent])", 318 | " elif reaction.emoji == buttons[3]:", 319 | " if curent < num_of_${9:embeds} - 1:", 320 | " curent += 1", 321 | " try:", 322 | " await msg.remove_reaction(str(reaction.emoji), user)", 323 | " except:", 324 | " pass", 325 | " if curent != previous_page:", 326 | " await msg.edit(embed=${9:embeds}[curent])", 327 | " elif reaction.emoji == buttons[4]:", 328 | " curent = num_of_${9:embeds} - 1", 329 | " try:", 330 | " await msg.remove_reaction(str(reaction.emoji), user)", 331 | " except:", 332 | " pass", 333 | " if curent != previous_page:", 334 | " await msg.edit(embed=${9:embeds}[curent])", 335 | " elif reaction.emoji == buttons[2]:", 336 | " await msg.remove_reaction(buttons[2], ctx.author)", 337 | " for btns in buttons:", 338 | " try:", 339 | " await msg.clear_reaction(btns)", 340 | " except:", 341 | " pass", 342 | ] 343 | }, 344 | "discord.py Exception":{ 345 | "prefix": "!except", 346 | "body": [ 347 | "class ${1:My}Error(${2:CommandError}):", 348 | " \"\"\"${3:Error Description}\"\"\"", 349 | "", 350 | " pass" 351 | ], 352 | "description": "Add a basic exception." 353 | }, 354 | "discord.py UI Button":{ 355 | "prefix": "!button", 356 | "body": [ 357 | "class ${1:My}Button(discord.ui.Button):", 358 | "", 359 | " async def callback(self, interaction: discord.Interaction):", 360 | " ${2:return await super().callback(interaction)}" 361 | ], 362 | "description": "Add a basic button." 363 | }, 364 | "discord.py Custom UI Button":{ 365 | "prefix": "!cbutton", 366 | "body": [ 367 | "class ${1:My}Button(discord.ui.Button):", 368 | "", 369 | " def __init__(self, *, style: ButtonStyle = ..., label: Optional[str] = None,", 370 | " disabled: bool = False, custom_id: Optional[str] = None,", 371 | " url: Optional[str] = None, emoji: Optional[Union[str, Emoji, PartialEmoji]] = None,", 372 | " row: Optional[int] = None, ${2:argname}: ${3:_type}):", 373 | " super().__init__(style=style, label=label, disabled=disabled,", 374 | " custom_id=custom_id, url=url, emoji=emoji, row=row, $2=$2)", 375 | "", 376 | " async def callback(self, interaction: discord.Interaction):", 377 | " ${4:return await super().callback(interaction)}", 378 | " $0" 379 | ], 380 | "description": "Add a button with a custom constructor.." 381 | }, 382 | "discord.py UI Select":{ 383 | "prefix": "!select", 384 | "body": [ 385 | "class ${1:My}Select(discord.ui.Select):", 386 | "", 387 | " async def callback(self, interaction: discord.Interaction):", 388 | " ${2:return await super().callback(interaction)}" 389 | ], 390 | "description": "Add a basic select." 391 | }, 392 | "discord.py Custom Context":{ 393 | "prefix": "!ctx", 394 | "body": [ 395 | "from discord.ext import commands", 396 | "", 397 | "", 398 | "class ${1:Context}(commands.Context):", 399 | " async def send(self, ctx: commands.Context):", 400 | " $0" 401 | ] 402 | }, 403 | 404 | } 405 | 406 | --------------------------------------------------------------------------------