First official build of bot!

Co-authored-by: iakrules <64628083+iakrules@noreply.github.com>
This commit is contained in:
rzmk 2021-08-01 14:24:02 -04:00
parent 953c89ead0
commit 2b8e2345f9
32 changed files with 1164 additions and 383 deletions

View file

@ -0,0 +1,64 @@
import discord
from discord.ext import commands
class EmbedCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# Commands
@commands.command()
async def embed(self, ctx, *, data):
"""Produces a customizable embed"""
# Split arguments into a list
data = data.split("%%")
# Set default channel to current channel where command is used
channel = ctx.channel
# Remove [''] surrounding possible channel argument input (slice value to just channel ID)
possible_channel = data[0].rstrip()[2:-1]
# Set channel if channel argument is given
try:
channel = await commands.TextChannelConverter().convert(ctx, possible_channel)
data.pop(0)
except Exception as e:
pass
# Check if user has permission to send in given channel
if not ctx.guild.get_member(ctx.author.id).permissions_in(channel).send_messages:
return await ctx.send(f"You don't have permission to send messages to {channel.mention}!")
# Add possible empty list values to deter IndexError for embed
data += [""] * (3-len(data))
# Create and send embed
embed = discord.Embed(
title=f"{data[0]}",
description=f"{data[1]}",
color=ctx.guild.get_member(ctx.bot.user.id).color
)
embed.set_footer(
text=f"{data[2]}"
)
await channel.send(embed=embed)
@embed.error
async def embed_error(self, ctx, error):
await ctx.send(
"Type the command in the following format:```.embed #channel_name %% title %% description %% footer```"
)
embed = discord.Embed(
title="Title",
description="Description",
color=ctx.guild.get_member(ctx.bot.user.id).color
)
embed.set_footer(
text="Footer"
)
await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(EmbedCog(bot))

View file

@ -1,31 +1,31 @@
import discord
from discord.ext import commands
class ModerationCog(commands.Cog):
def __init__(self, client):
self.client = client
# Commands
@commands.command()
@commands.has_permissions(kick_members = True)
async def kick(self, ctx, member : commands.MemberConverter, *, reason="No reason provided."):
"""Kick a user from the server"""
try:
await member.kick(reason=reason)
await ctx.send(member.mention + " has been kicked.")
except:
await ctx.send(f"Unable to kick {member.mention}.\nIs {member.mention} at the same role level or higher than {self.client.user.name}?")
@commands.command()
@commands.has_permissions(ban_members = True)
async def ban(self, ctx, member : commands.MemberConverter, *, reason="No reason provided."):
"""Ban a user from the server"""
try:
await member.ban(reason=reason)
await ctx.send(member.mention + " has been banned.")
except:
await ctx.send(f"Unable to ban {member.mention}.\nIs {member.mention} at the same role level or higher than {self.client.user.name}?")
def setup(client):
client.add_cog(ModerationCog(client))
import discord
from discord.ext import commands
class ModerationCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# Commands
@commands.command()
@commands.has_permissions(kick_members = True)
async def kick(self, ctx, member : commands.MemberConverter, *, reason="No reason provided."):
"""Kick a user from the server"""
try:
await member.kick(reason=reason)
await ctx.send(member.mention + " has been kicked.")
except:
await ctx.send(f"Unable to kick {member.mention}.\nIs {member.mention} at the same role level or higher than {self.bot.user.name}?")
@commands.command()
@commands.has_permissions(ban_members = True)
async def ban(self, ctx, member : commands.MemberConverter, *, reason="No reason provided."):
"""Ban a user from the server"""
try:
await member.ban(reason=reason)
await ctx.send(member.mention + " has been banned.")
except:
await ctx.send(f"Unable to ban {member.mention}.\nIs {member.mention} at the same role level or higher than {self.bot.user.name}?")
def setup(bot):
bot.add_cog(ModerationCog(bot))

View file

@ -0,0 +1,18 @@
import discord
from discord.ext import commands
class PruneCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# Commands
@commands.command(aliases=['clear', 'prune'])
@commands.has_permissions(manage_messages=True)
async def purge(self, ctx, amount=10):
"""Removes a number of messages (10 by default)"""
await ctx.channel.purge(limit=amount+1)
await ctx.send(f'`{amount}` messages deleted.', delete_after=3)
def setup(bot):
bot.add_cog(PruneCog(bot))