├── requirements.txt ├── bot.py ├── README.md ├── LICENSE ├── cogs ├── help.py └── mod.py └── .gitignore /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.7.4.post0 2 | async-timeout==3.0.1 3 | attrs==21.2.0 4 | chardet==4.0.0 5 | discord==1.0.1 6 | discord.py==1.7.3 7 | idna==3.2 8 | multidict==5.1.0 9 | typing-extensions==3.10.0.0 10 | yarl==1.6.3 11 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | import discord 2 | import os 3 | from discord.ext import commands 4 | 5 | TOKEN = "You're bot token" 6 | PREFIX = "You're bot prefix" 7 | 8 | bot = commands.AutoShardedBot(command_prefix=PREFIX) 9 | bot.remove_command('help') 10 | 11 | @bot.event 12 | async def on_ready(): 13 | print('Bot is ready') 14 | activity = discord.Activity(type=discord.ActivityType.listening, name=F"{PREFIX}help") 15 | await bot.change_presence(status=discord.Status.dnd, activity=activity) 16 | 17 | 18 | for fn in os.listdir('./cogs'): 19 | if fn.endswith('.py'): 20 | bot.load_extension(f"cogs.{fn[:-3]}") 21 | 22 | bot.run(TOKEN) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord.py-Moderation-Bot 2 | 3 | # Installion 4 | ### Open a terminal or cmd (Depending on you're operating system) 5 | ### Type: ```git clone https://github.com/Discord-py-Projects/Discord.py-Moderation-Bot.git``` 6 | ### Type if you're on mac/linux: pip3 install -r requirements.txt Type if you're on windows: pip install requirements.txt 7 | ### Last open bot.py and replace the variable TOKEN with you're bot token and PREFIX with you're bot prefix 8 | ### Bam! You have a discord moderation bot, type in: {prefix}help to see commmands 9 | 10 | --- 11 | 12 | # About 13 | ### The leader of this organatizion is ![PythonSytaxError](https://github.com/PythonSyntaxError) And currently looking for other developers. We make discord.py bots for samples for bigger projects. I started this to help other discord.py devs to have a reliable source to get bot code from. We don't care about you putting us in too you're contribtions file but would be highly appreactiated! Thank you for using our code 14 | 15 | --- 16 | 17 | # Applications 18 | ### If you would like to join our team, Please contact us at pythonsytaxerror@protonmail.com 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Discord-py-Projects 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 | -------------------------------------------------------------------------------- /cogs/help.py: -------------------------------------------------------------------------------- 1 | import discord 2 | import datetime 3 | from discord.ext import commands 4 | import bot 5 | 6 | class Help(commands.Cog): 7 | def __init__(self, bot): 8 | self.bot = bot 9 | 10 | 11 | @commands.command() 12 | @commands.cooldown(1, 5, commands.BucketType.guild) 13 | async def help(self, ctx): 14 | embed = discord.Embed(title="Help!", description="How to use the commands!", timestamp=datetime.datetime.utcnow(), colour=discord.Colour.blue()) 15 | embed.add_field(name=f"{bot.PREFIX}ping", value="This command is too show the latency of the bot", inline=True) 16 | embed.add_field(name=f"{bot.PREFIX}purge", value=f"Syntax: {bot.PREFIX}purge (amount of messages), This command is too delete certant amount of messages in a channel!", inline=True) 17 | embed.add_field(name=f"{bot.PREFIX}tempmute", value=f"Syntax: {bot.PREFIX}tempmute (member) (time) (time delay(example: s, m, h, d)) (reason), This command is to temperaly mute a member!", inline=True) 18 | embed.add_field(name=f"{bot.PREFIX}mute", value=f"Syntax: {bot.PREFIX}mute (member) (reason), This command is to permentaly mute a member untill unmuted with a command", inline=True) 19 | embed.add_field(name=f"{bot.PREFIX}unmute", value=f"Syntax: {bot.PREFIX}unmute (member), This command is to unmute a member forcefully", inline=True) 20 | embed.add_field(name=f"{bot.PREFIX}kick", value=f"Syntax: {bot.PREFIX}kick (member) (reason, This command is to kick a member from you're guild! They still can rejoin if given an invite)", inline=True) 21 | embed.add_field(name=f"{bot.PREFIX}tempban", value=f"Syntax: {bot.PREFIX}tempban (member) (time) (time delay(example: s, m, h, d)) (reason), This command is to temperaly ban a member untill time is up or unban command is called on the member", inline=True) 22 | embed.add_field(name=f"{bot.PREFIX}ban", value=f"Syntax: {bot.PREFIX}ban (member) (reason), This command is to permentaly mute a member untill unbannedd with a command", inline=True) 23 | embed.add_field(name=f"{bot.PREFIX}unban", value=f"Syntax: {bot.PREFIX}unban (member), This command is to unban a member forcefully", inline=True) 24 | await ctx.reply(embed=embed) 25 | 26 | def setup(bot): 27 | bot.add_cog(Help(bot)) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /cogs/mod.py: -------------------------------------------------------------------------------- 1 | import discord 2 | import os 3 | import datetime 4 | import asyncio 5 | from discord.ext import commands 6 | 7 | 8 | class Mod(commands.Cog): 9 | def __init__(self, bot): 10 | self.bot = bot 11 | 12 | @commands.command() 13 | @commands.cooldown(1, 5, commands.BucketType.guild) 14 | async def ping(self, ctx): 15 | embed = discord.Embed(title=f"🏓Pong! {round(self.bot.latency * 1000)}ms", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 16 | await ctx.reply(embed=embed) 17 | 18 | @commands.command() 19 | @commands.has_permissions(manage_messages=True) 20 | @commands.cooldown(1, 5, commands.BucketType.guild) 21 | async def purge(self, ctx, amount=6): 22 | await ctx.channel.purge(limit=amount) 23 | embed = discord.Embed(title=f"{amount} messages has been purged!", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 24 | await ctx.reply(embed=embed) 25 | 26 | @commands.command() 27 | @commands.has_permissions(manage_messages=True) 28 | @commands.cooldown(1, 5, commands.BucketType.guild) 29 | async def tempmute(self, ctx, member: discord.Member, time, d, reason=None): 30 | guild = ctx.guild 31 | role = discord.utils.get(guild.roles, name="Muted") 32 | 33 | 34 | 35 | 36 | for channel in guild.channels: 37 | await channel.set_permissions(role, speak=False, send_messages=False, read_message_history=True, read_messages=False) 38 | await member.add_roles(role) 39 | embed = discord.Embed(title="Muted!", description=f"{member.mention} has been muted", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 40 | embed.add_field(name="Reason:", value=reason, inline=False) 41 | embed.add_field(name="Time left for the mute:", value=f"{time}{d}", inline=False) 42 | await ctx.reply(embed=embed) 43 | if d == "s": 44 | await asyncio.sleep(int(time)) 45 | if d == "m": 46 | await asyncio.sleep(int(time*60)) 47 | if d == "h": 48 | await asyncio.sleep(int(time*60*60)) 49 | if d == "d": 50 | await asyncio.sleep(int(time*60*60*24)) 51 | await member.remove_roles(role) 52 | embed = discord.Embed(title="Unmuted", description=f"Unmuted {member.mention} ", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 53 | await ctx.reply(embed=embed) 54 | 55 | 56 | @commands.command() 57 | @commands.has_permissions(manage_messages=True) 58 | @commands.cooldown(1, 5, commands.BucketType.guild) 59 | async def mute(self, ctx, member: discord.Member, *, reason=None): 60 | guild = ctx.guild 61 | mutedRole = discord.utils.get(guild.roles, name="Muted") 62 | 63 | if not mutedRole: 64 | mutedRole = await guild.create_role(name="Muted") 65 | 66 | for channel in guild.channels: 67 | await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False) 68 | embed = discord.Embed(title="Muted", description=f"{member.mention} was muted ", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 69 | embed.add_field(name="Reason:", value=reason, inline=False) 70 | await ctx.reply(embed=embed) 71 | await member.add_roles(mutedRole, reason=reason) 72 | await member.send(f"You have been muted from: {guild.name} Reason: {reason}") 73 | 74 | 75 | @commands.command() 76 | @commands.cooldown(1, 5, commands.BucketType.guild) 77 | @commands.has_permissions(manage_messages=True) 78 | async def unmute(self, ctx, member: discord.Member): 79 | mutedRole = discord.utils.get(ctx.guild.roles, name="Muted") 80 | 81 | await member.remove_roles(mutedRole) 82 | await member.send(f"You have unmuted from: {ctx.guild.name}") 83 | embed = discord.Embed(title="Unmute", description=f"Unmuted {member.mention}", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 84 | await ctx.reply(embed=embed) 85 | 86 | @commands.command() 87 | @commands.has_permissions(kick_members=True) 88 | @commands.cooldown(1, 5, commands.BucketType.guild) 89 | async def kick(self, ctx, member: discord.Member, reason="No Reason"): 90 | if member == None: 91 | embed = discord.Embed(f"{ctx.message.author}, Please enter a valid user!") 92 | await ctx.reply(embed=embed) 93 | 94 | else: 95 | guild = ctx.guild 96 | embed = discord.Embed(title="Kicked!", description=f"{member.mention} has been kicked!!", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 97 | embed.add_field(name="Reason: ", value=reason, inline=False) 98 | await ctx.reply(embed=embed) 99 | await guild.kick(user=member) 100 | 101 | @commands.command() 102 | @commands.has_permissions(kick_members=True) 103 | @commands.cooldown(1, 5, commands.BucketType.guild) 104 | async def tempban(self, ctx, member: discord.Member, time, d, *, reason="No Reason"): 105 | if member == None: 106 | embed = discord.Embed(f"{ctx.message.author}, Please enter a valid user!") 107 | await ctx.reply(embed=embed) 108 | 109 | 110 | else: 111 | guild = ctx.guild 112 | embed = discord.Embed(title="Banned!", description=f"{member.mention} has been banned!", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 113 | embed.add_field(name="Reason: ", value=reason, inline=False) 114 | embed.add_field(name="Time left for the ban:", value=f"{time}{d}", inline=False) 115 | await ctx.reply(embed=embed) 116 | await guild.ban(user=member) 117 | 118 | if d == "s": 119 | await asyncio.sleep(int(time)) 120 | await guild.unban(user=member) 121 | if d == "m": 122 | await asyncio.sleep(int(time*60)) 123 | await guild.unban(user=member) 124 | if d == "h": 125 | await asyncio.sleep(int(time*60*60)) 126 | await guild.unban(user=member) 127 | if d == "d": 128 | await asyncio.sleep(time*60*60*24) 129 | await guild.unban(int(user=member)) 130 | 131 | @commands.command() 132 | @commands.has_permissions(kick_members=True) 133 | @commands.cooldown(1, 5, commands.BucketType.guild) 134 | async def ban(self, ctx, member: discord.Member, reason="No Reason"): 135 | if member == None: 136 | embed = discord.Embed(f"{ctx.message.author}, Please enter a valid user!") 137 | await ctx.reply(embed=embed) 138 | else: 139 | guild = ctx.guild 140 | embed = discord.Embed(title="Banned!", description=f"{member.mention} has been banned!", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 141 | embed.add_field(name="Reason: ", value=reason, inline=False) 142 | await ctx.reply(embed=embed) 143 | await guild.ban(user=member) 144 | 145 | 146 | 147 | @commands.command() 148 | @commands.has_permissions(kick_members=True) 149 | @commands.cooldown(1, 5, commands.BucketType.guild) 150 | async def unban(self, ctx, user: discord.User): 151 | if user == None: 152 | embed = discord.Embed(f"{ctx.message.author}, Please enter a valid user!") 153 | await ctx.reply(embed=embed) 154 | 155 | else: 156 | guild = ctx.guild 157 | embed = discord.Embed(title="Unbanned!", description=f"{user.display_name} has been unbanned!", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow()) 158 | await ctx.reply(embed=embed) 159 | await guild.unban(user=user) 160 | 161 | 162 | 163 | def setup(bot): 164 | bot.add_cog(Mod(bot)) --------------------------------------------------------------------------------