Skip to content

Commit 6f3f3f3

Browse files
committed
Template v2.3
Made the kick command actually kick Added a template cog to create cogs easily
1 parent 820fa1d commit 6f3f3f3

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Python Discord Bot Template
2-
[![Python Versions](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-orange)](https://github.com/kkrypt0nn/Python-Discord-Bot-Template) [![Project Version](https://img.shields.io/badge/version-v2.0-blue)](https://github.com/kkrypt0nn/Python-Discord-Bot-Template)
2+
[![Python Versions](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-orange)](https://github.com/kkrypt0nn/Python-Discord-Bot-Template) [![Project Version](https://img.shields.io/badge/version-v2.3-blue)](https://github.com/kkrypt0nn/Python-Discord-Bot-Template)
33

44
This repository is a template that everyone can use for the start of their discord bot.
55

66
When I first started creating my discord bot it took me a while to get everything setup and working with cogs and more. I would've been happy if there were any template existing. But there wasn't any existing template. That's why I decided to create my own template to let <b>you</b> guys create your discord bot in an easy way.
77

88
Please note that this template is not supposed to be the best template, but a good template to start learning how discord.py works and to make your own bot in a simple way. You're
99

10-
If you play to use this template to makw your own template or bot, please give me credits, it would be greatly appreciated.
10+
If you play to use this template to make your own template or bot, please give me credits, it would be greatly appreciated.
1111

1212
## Authors
1313
* **[Krypton (@kkrypt0nn)](https://github.com/kkrypt0nn)** - The only and one developer

UPDATES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Updates List
22
Here is the list of all the updates that I made on this template.
33

4+
### Version 2.3
5+
* Made the kick command actually kick
6+
* Added a template cog to create cogs easily
7+
48
### Version 2.2
59
* Fixed the purge command
610
* Made the error embeds actually red...

bot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
""""
2-
Copyright © Krypton 2020 - https://github.com/kkrypt0nn
2+
Copyright © Krypton 2021 - https://github.com/kkrypt0nn
33
Description:
44
This is a template to create your own discord bot in python.
55
6-
Version: 2.2
6+
Version: 2.3
77
"""
88

99
import discord, asyncio, os, platform, sys

cogs/moderation.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import os, sys, discord
22
from discord.ext import commands
3-
if not os.path.isfile("config.py"):
4-
sys.exit("'config.py' not found! Please add it and try again.")
5-
else:
6-
import config
73

84
class moderation(commands.Cog, name="moderation"):
95
def __init__(self, bot):
@@ -25,6 +21,7 @@ async def kick(self, context, member: discord.Member, *args):
2521
else:
2622
try:
2723
reason = " ".join(args)
24+
await member.kick(reason=reason)
2825
embed = discord.Embed(
2926
title="User Kicked!",
3027
description=f"**{member}** was kicked by **{context.message.author}**!",
@@ -65,13 +62,13 @@ async def nick(self, context, member: discord.Member, *, name: str):
6562
try:
6663
if name.lower() == "!reset":
6764
name = None
65+
await member.change_nickname(name)
6866
embed = discord.Embed(
6967
title="Changed Nickname!",
7068
description=f"**{member}'s** new nickname is **{name}**!",
7169
color=0x00FF00
7270
)
7371
await context.send(embed=embed)
74-
await member.change_nickname(name)
7572
except:
7673
embed = discord.Embed(
7774
title="Error!",
@@ -103,6 +100,7 @@ async def ban(self, context, member: discord.Member, *args):
103100
await context.send(embed=embed)
104101
else:
105102
reason = " ".join(args)
103+
await member.ban(reason=reason)
106104
embed = discord.Embed(
107105
title="User Banned!",
108106
description=f"**{member}** was banned by **{context.message.author}**!",
@@ -114,7 +112,6 @@ async def ban(self, context, member: discord.Member, *args):
114112
)
115113
await context.send(embed=embed)
116114
await member.send(f"You were banned by **{context.message.author}**!\nReason: {reason}")
117-
await member.ban(reason=reason)
118115
except:
119116
embed = discord.Embed(
120117
title="Error!",

cogs/template.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os, sys, discord
2+
from discord.ext import commands
3+
4+
# Only if you want to use variables that are in the config.py file.
5+
if not os.path.isfile("config.py"):
6+
sys.exit("'config.py' not found! Please add it and try again.")
7+
else:
8+
import config
9+
10+
# Here we name the cog and create a new class for the cog.
11+
class Template(commands.Cog, name="template"):
12+
def __init__(self, bot):
13+
self.bot = bot
14+
15+
# Here you can just add your own commands, you'll always need to provide "self" as first parameter.
16+
@commands.command(name="testcommand")
17+
async def testcommand(self, context):
18+
# Do your stuff here
19+
20+
# Don't forget to remove "pass", that's just because there's no content in the method.
21+
pass
22+
23+
# And then we finally add the cog to the bot so that it can load, unload, reload and use it's content.
24+
def setup(bot):
25+
bot.add_cog(Template(bot))

0 commit comments

Comments
 (0)