Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Warn system (not ready, snaky has to finish), Mute/Unmute, Ban/Mute S…
Browse files Browse the repository at this point in the history
…erver List, Rename all the cogs names
  • Loading branch information
devbutlazy committed Nov 5, 2023
1 parent 09e7f4e commit b0ddf49
Show file tree
Hide file tree
Showing 15 changed files with 1,087 additions and 470 deletions.
File renamed without changes.
480 changes: 240 additions & 240 deletions src/cogs/economy.py → src/cogs/EconomyCog.py

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
572 changes: 572 additions & 0 deletions src/cogs/ModerationCog.py

Large diffs are not rendered by default.

212 changes: 106 additions & 106 deletions src/cogs/settings.py → src/cogs/SettingsCog.py
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
from disnake import Message, Embed
from disnake.ext import commands

from src.utils import main_db


# from disnake.ext.ipc import Server, ClientPayload


class Settings(commands.Cog):
"""Helper commands to set up the bot."""

EMOJI = "<:settings:1169685352114552922>️"

def __init__(self, bot) -> None:
self.bot = bot
self.settings_db = main_db

async def cog_load(self) -> None:
await self.settings_db.fetch_and_cache_all()

# @Server.route()
# async def get_prefix(self, data: ClientPayload) -> Dict[str, str]:
# prefix = await self.settings_db.get_prefix(data.guild_id)
#
# return {
# "message": f"Current prefix is {prefix}",
# "prefix": prefix,
# "status": "OK",
# }
#
# @Server.route()
# async def set_prefix(self, data: ClientPayload) -> Dict[str, str]:
# current_prefix = await self.settings_db.get_prefix(data.guild_id)
#
# if current_prefix == data.prefix:
# return {
# "message": f"Prefix already set to {data.prefix}",
# "prefix": current_prefix,
# "status": "ALREADY_IN_DB",
# }
#
# await self.settings_db.set_prefix(data.guild_id, data.prefix)
# return {
# "message": f"Successfully set prefix to {data.prefix}",
# "prefix": data.prefix,
# "status": "OK",
# }

@commands.command()
async def set_prefix(self, ctx: commands.Context, prefix: str) -> Message:
"""Set current prefix to another one"""
if prefix is None or prefix == "":
return await ctx.reply("Please enter a prefix!")
elif len(prefix) >= 5:
return await ctx.reply("Your prefix is too long!")
else:
await self.settings_db.set_prefix(ctx.guild.id, prefix)
return await ctx.reply(f"Successfully set prefix to {prefix}")

@commands.command()
async def command_disable(self, ctx: commands.Context, command: str) -> Message:
"""Disable command for this guild (required administrator privileges)"""

# first, try to get command from name
command_name = ctx.bot.get_command(command)
if command_name is None:
# try to get command from alias
for cmd in ctx.bot.commands:
if command in cmd.aliases:
command_name = cmd
break

if command_name and command_name != ctx.command:
if isinstance(command_name, commands.Group):
for command in command_name.commands:
await self.settings_db.add_command(
guild_id=ctx.guild.id, command=command.name
)
await self.settings_db.add_command(
guild_id=ctx.guild.id, command=command_name.name
)
return await ctx.reply(
embed=Embed(
title="Information",
description=f"Successfully disabled command "
f"{'group' if isinstance(command_name, commands.Group) else ''} "
f"{command_name.name}",
)
)
elif command_name == ctx.command:
return await ctx.reply(
embed=Embed(
title="Error", description=f"You can't disable this command"
)
)
else:
return await ctx.reply(
embed=Embed(
title="Error", description=f"Could not find command {command}"
)
)


def setup(bot: commands.Bot) -> None:
bot.add_cog(Settings(bot=bot))
from disnake import Message, Embed
from disnake.ext import commands

from src.utils import main_db


# from disnake.ext.ipc import Server, ClientPayload


class Settings(commands.Cog):
"""Helper commands to set up the bot."""

EMOJI = "<:settings:1169685352114552922>️"

def __init__(self, bot) -> None:
self.bot = bot
self.settings_db = main_db

async def cog_load(self) -> None:
await self.settings_db.fetch_and_cache_all()

# @Server.route()
# async def get_prefix(self, data: ClientPayload) -> Dict[str, str]:
# prefix = await self.settings_db.get_prefix(data.guild_id)
#
# return {
# "message": f"Current prefix is {prefix}",
# "prefix": prefix,
# "status": "OK",
# }
#
# @Server.route()
# async def set_prefix(self, data: ClientPayload) -> Dict[str, str]:
# current_prefix = await self.settings_db.get_prefix(data.guild_id)
#
# if current_prefix == data.prefix:
# return {
# "message": f"Prefix already set to {data.prefix}",
# "prefix": current_prefix,
# "status": "ALREADY_IN_DB",
# }
#
# await self.settings_db.set_prefix(data.guild_id, data.prefix)
# return {
# "message": f"Successfully set prefix to {data.prefix}",
# "prefix": data.prefix,
# "status": "OK",
# }

@commands.command()
async def set_prefix(self, ctx: commands.Context, prefix: str) -> Message:
"""Set current prefix to another one"""
if prefix is None or prefix == "":
return await ctx.reply("Please enter a prefix!")
elif len(prefix) >= 5:
return await ctx.reply("Your prefix is too long!")
else:
await self.settings_db.set_prefix(ctx.guild.id, prefix)
return await ctx.reply(f"Successfully set prefix to {prefix}")

@commands.command()
async def command_disable(self, ctx: commands.Context, command: str) -> Message:
"""Disable command for this guild (required administrator privileges)"""

# first, try to get command from name
command_name = ctx.bot.get_command(command)
if command_name is None:
# try to get command from alias
for cmd in ctx.bot.commands:
if command in cmd.aliases:
command_name = cmd
break

if command_name and command_name != ctx.command:
if isinstance(command_name, commands.Group):
for command in command_name.commands:
await self.settings_db.add_command(
guild_id=ctx.guild.id, command=command.name
)
await self.settings_db.add_command(
guild_id=ctx.guild.id, command=command_name.name
)
return await ctx.reply(
embed=Embed(
title="Information",
description=f"Successfully disabled command "
f"{'group' if isinstance(command_name, commands.Group) else ''} "
f"{command_name.name}",
)
)
elif command_name == ctx.command:
return await ctx.reply(
embed=Embed(
title="Error", description=f"You can't disable this command"
)
)
else:
return await ctx.reply(
embed=Embed(
title="Error", description=f"Could not find command {command}"
)
)


def setup(bot: commands.Bot) -> None:
bot.add_cog(Settings(bot=bot))
4 changes: 2 additions & 2 deletions src/cogs/basic.py → src/cogs/UtilityCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
startup = datetime.datetime.now()


class BasicUtility(commands.Cog):
class Utility(commands.Cog):
"""Utility commands"""

EMOJI = "<:globe:1169690501063123065>"
Expand Down Expand Up @@ -442,4 +442,4 @@ async def lock(


def setup(bot: commands.Bot):
bot.add_cog(BasicUtility(bot=bot))
bot.add_cog(Utility(bot=bot))
120 changes: 0 additions & 120 deletions src/cogs/moderation.py

This file was deleted.

2 changes: 2 additions & 0 deletions src/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .database.invite import InviteTrackerDatabase
from .database.logger import LoggerDatabase
from .database.tickets import TicketDatabase
from .database.warns import WarnDatabase

economy = Economy("economy")
main_db = MainDatabase("bot")
Expand All @@ -12,3 +13,4 @@
logger = LoggerDatabase("logger")
backups = BackupsDatabase("backups")
invites = InviteTrackerDatabase("invites")
warns = WarnDatabase("warns")
Loading

0 comments on commit b0ddf49

Please sign in to comment.