├── LICENSE ├── README.md ├── cogs └── ping.py ├── main.py └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Xeift 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 | # Basic-Pycord-Cog-Slash-Command-Discord-Bot-Template 2 | A simple slash command Discord bot using Pycord with cog. Hope this repo helps you. 3 | -------------------------------------------------------------------------------- /cogs/ping.py: -------------------------------------------------------------------------------- 1 | import discord 2 | from discord.commands import slash_command 3 | from discord.ext import commands 4 | 5 | class ping(commands.Cog): 6 | 7 | def __init__(self,bot): 8 | self.bot = bot 9 | 10 | @slash_command(guild_ids=[936236815545954384],name='ping',description='return bot latency') 11 | async def ping( 12 | self, 13 | ctx: discord.ApplicationContext 14 | ): 15 | await ctx.respond(f"pong! ({self.bot.latency*1000:.2f} ms)") 16 | def setup(bot): 17 | bot.add_cog(ping(bot)) 18 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import discord 2 | # import asyncio 3 | 4 | bot = discord.Bot(intents=discord.Intents.all(),) 5 | 6 | @bot.event 7 | async def on_ready(): 8 | print(f'We have logged in as {bot.user}') 9 | # while True: 10 | # await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='A nice game')) 11 | # await asyncio.sleep(60) 12 | 13 | 14 | extensions = [# load cogs 15 | 'cogs.ping', 16 | ] 17 | 18 | if __name__ == '__main__': # import cogs from cogs folder 19 | for extension in extensions: 20 | bot.load_extension(extension) 21 | 22 | bot.run('YOUR_BOT_TOKEN_FROM_DEV_PORTAL') # bot token -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xeift/Basic-Pycord-Cog-Slash-Command-Discord-Bot-Template/9fe5533c677a48f2f937399aa018f8eb70c33c13/requirements.txt --------------------------------------------------------------------------------