Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #36 from parafoxia/develop
Browse files Browse the repository at this point in the history
Merge to release rc.2
  • Loading branch information
parafoxia authored Aug 28, 2020
2 parents 29386ac + 24a46dc commit 3f27970
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ I would greatly prefer if you invited Solaris to your server [here](https://disc

Solaris was also not designed with universal compatibility in mind. If you want to include sections of Solaris' code in your own program, you will likely need to make significant modifications. Make sure you abide by the terms of the license, which you can find in LICENSE.

**Note:** As of v1.0.0-beta.3, these instructions haven't been fully tested. If they are wrong, open an issue.
**Note:** As of v1.0.0-rc.2, these instructions haven't been fully tested. If they are wrong, open an issue.

## Running with Docker
**Warning**: Docker functionality in Solaris was designed specifically with Debian 10 Buster in mind. If you are using another OS, you may need to modify the Dockerfile.
Expand Down
41 changes: 4 additions & 37 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Solaris-Bot"
version = "1.0.0-rc.1"
version = "1.0.0-rc.2"
description = "A Discord bot designed to make your server a safer and better place."

license = "GPLv3"
Expand All @@ -17,7 +17,7 @@ aiofiles = "^0.5.0"
aiosqlite = "^0.13.0"
apscheduler = "^3.6.3"
beautifultable = "^1.0.0"
"discord.py" = "1.3.4"
"discord.py" = "^1.4.1"
psutil = "^5.7.0"
pygount = "^1.2.3"
python-dotenv = "^0.14.0"
Expand Down
42 changes: 33 additions & 9 deletions solaris/utils/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# Ethan Henderson
# parafoxia@carberra.xyz

import re

import discord
from discord.ext import commands

Expand All @@ -25,34 +27,56 @@

class User(commands.Converter):
async def convert(self, ctx, arg):
return await ctx.bot.grab_user(arg)
if (user := await ctx.bot.grab_user(arg)) is None:
raise commands.BadArgument
return user


class Channel(commands.Converter):
async def convert(self, ctx, arg):
return await ctx.bot.grab_channel(arg)
if (channel := await ctx.bot.grab_channel(arg)) is None:
raise commands.BadArgument
return channel


class Guild(commands.Converter):
async def convert(self, ctx, arg):
return await ctx.bot.grab_guild(arg)
if (guild := await ctx.bot.grab_guild(arg)) is None:
raise commands.BadArgument
return guild


class Command(commands.Converter):
async def convert(self, ctx, arg):
# False indicates command doesn't exist.
# TODO: Re-write this to match the convention above. Will probs need to rework how
# `commands.BadArgument` is handled.
return ctx.bot.get_command(arg) or False


class SearchedMember(commands.Converter):
async def convert(self, ctx, arg):
return discord.utils.get(
ctx.guild.members,
name=str(Search(arg, [m.display_name for m in ctx.guild.members]).best(min_accuracy=0.75)),
)
if (
member := discord.utils.get(
ctx.guild.members,
name=str(Search(arg, [m.display_name for m in ctx.guild.members]).best(min_accuracy=0.75)),
)
) is None:
raise commands.BadArgument
return member


class BannedUser(commands.Converter):
async def convert(self, ctx, arg):
if ctx.guild.me.guild_permissions.ban_members:
return next(filter(lambda u: str(u) == arg, [e.user for e in await ctx.guild.bans()]))
banned = [e.user for e in await ctx.guild.bans()]
if banned:
if re.match(r"[0-9]{17,22}", arg) is not None:
if (user := discord.utils.get(banned, id=int(arg))) is None:
raise commands.BadArgument
return user
elif (match := re.match(r"([\s\S]{2,32})#([0-9]{4})", arg)) is not None:
if (user := discord.utils.get(banned, name=match.group(1), discriminator=match.group(2))) is None:
raise commands.BadArgument
return user
else:
raise commands.BadArgument
8 changes: 8 additions & 0 deletions solaris/utils/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ async def system__adminrole(bot, channel, value):
The role used to denote which members can configure Solaris. Alongside server administrators, only members with this role can use any of Solaris' configuration commands. Upon selecting a new channel, Solaris will delete the one that was created during the first time setup should it still exist."""
if not isinstance(value, discord.Role):
await channel.send(f"{bot.cross} The admin role must be a Discord role in this server.")
elif any(v.name == "@everyone" for v in values):
await channel.send(f"{bot.cross} The everyone role can not be used as the admin role.")
elif value.position > channel.guild.me.top_role.position:
await channel.send(
f"{bot.cross} The given role can not be used as the admin role as it is above Solaris' top role in the role hierarchy."
Expand Down Expand Up @@ -142,6 +144,8 @@ async def gateway__blockingrole(bot, channel, value):
await channel.send(f"{bot.cross} This can not be done as the gateway module is currently active.")
elif not isinstance(value, discord.Role):
await channel.send(f"{bot.cross} The blocking role must be a Discord role in this server.")
elif any(v.name == "@everyone" for v in values):
await channel.send(f"{bot.cross} The everyone role can not be used as the blocking role.")
elif value.position >= channel.guild.me.top_role.position:
await channel.send(
f"{bot.cross} The given role can not be used as the blocking role as it is above Solaris' top role in the role hierarchy."
Expand Down Expand Up @@ -171,6 +175,8 @@ async def gateway__memberroles(bot, channel, values):
await channel.send(f"{bot.cross} You can only set up to {MAX_MEMBER_ROLES} member roles.")
elif not all(isinstance(v, discord.Role) for v in values):
await channel.send(f"{bot.cross} All member roles must be Discord roles in this server.")
elif any(v.name == "@everyone" for v in values):
await channel.send(f"{bot.cross} The everyone role can not be used as a member role.")
elif any(v == br for v in values):
await channel.send(f"{bot.cross} No member roles can be the same as the blocking role.")
elif any(v.position > channel.guild.me.top_role.position for v in values):
Expand Down Expand Up @@ -206,6 +212,8 @@ async def gateway__exceptionroles(bot, channel, values):
await channel.send(f"{bot.cross} You can only set up to {MAX_EXCEPTION_ROLES} exception roles.")
elif not all(isinstance(v, discord.Role) for v in values):
await channel.send(f"{bot.cross} All exception roles must be Discord roles in this server.")
elif any(v.name == "@everyone" for v in values):
await channel.send(f"{bot.cross} The everyone role can not be used as an exception role.")
elif any(v == br for v in values):
await channel.send(f"{bot.cross} No exception roles can be the same as the blocking role.")
else:
Expand Down

0 comments on commit 3f27970

Please sign in to comment.