Browse Source

Refactor: Some of the UX and outputs. Also changelog text.

tags/v2.0.0
Roxie Gibson 5 years ago
parent
commit
c3d34c19cb
5 changed files with 61 additions and 33 deletions
  1. +3
    -2
      CHANGELOG.md
  2. +52
    -27
      roxbot/cogs/admin.py
  3. +3
    -3
      roxbot/cogs/customcommands.py
  4. +2
    -1
      roxbot/cogs/image.py
  5. +1
    -0
      roxbot/cogs/voice.py

+ 3
- 2
CHANGELOG.md View File

**WARNING** It is not recommended to use any release before v2.0.0. All previous versions are logged and released as pre-releases and are only here as a historical record for myself. All post-v2.0.0 releases are finished products that are stable. **WARNING** It is not recommended to use any release before v2.0.0. All previous versions are logged and released as pre-releases and are only here as a historical record for myself. All post-v2.0.0 releases are finished products that are stable.


## v2.0.0 ## v2.0.0
- More better open source stuff - pls pr me
- easy setup and get that wiki going
With this update, I wanted Roxbot to reach an almost finished state. The base of the program should be complete and functional. This update brings a lot of internal changes that should make development of Roxbot easier for others and myself. It also should make her a lot more stable. Still expect updates with new features, bug fixes, and UX changes. Maybe just at a slower rate.

Roxbot should be easier for users to setup too with this update. I have made full documentation of how she works and how to contribute to the project to make this easier. As well as a setup script.


### Big and Breaking Changes ### Big and Breaking Changes
- All settings have been decentralised between servers and cogs. All changes to the settings have been moved to independant commands. This doesn't effect custom commands or warnings. - All settings have been decentralised between servers and cogs. All changes to the settings have been moved to independant commands. This doesn't effect custom commands or warnings.

+ 52
- 27
roxbot/cogs/admin.py View File

ERROR_WARN_SL_NEG = "number_of_warnings can only be a positive integer." ERROR_WARN_SL_NEG = "number_of_warnings can only be a positive integer."


OK_MOD_ACTION = "{} with reason: '{}'" OK_MOD_ACTION = "{} with reason: '{}'"
WARN_MOD_LACK_PERMS = "I can't kick the owner or users higher or equal to me."
WARN_MOD_LACK_PERMS = "Cannot kick owner or users higher or equal to me role hierarchy."
WARN_UNBAN_NOTFOUND = "User is not banned." WARN_UNBAN_NOTFOUND = "User is not banned."


def __init__(self, bot_client): def __init__(self, bot_client):
0 turns off slowmode for this channel""" 0 turns off slowmode for this channel"""
if seconds == 0: # Turn Slow Mode off if seconds == 0: # Turn Slow Mode off
await ctx.channel.edit(slowmode_delay=seconds, reason="{} requested to turn off slowmode.".format(ctx.author)) await ctx.channel.edit(slowmode_delay=seconds, reason="{} requested to turn off slowmode.".format(ctx.author))
return await ctx.send(self.OK_SLOWMODE_OFF)
embed = discord.Embed(description=self.OK_SLOWMODE_OFF, colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)


elif 0 < seconds <= 120 and ctx.channel.slowmode_delay == 0: # Turn Slow Mode On elif 0 < seconds <= 120 and ctx.channel.slowmode_delay == 0: # Turn Slow Mode On
await ctx.channel.edit(slowmode_delay=seconds, reason="{} requested slowmode with a timer of {}".format(ctx.author, seconds)) await ctx.channel.edit(slowmode_delay=seconds, reason="{} requested slowmode with a timer of {}".format(ctx.author, seconds))
return await ctx.send(self.OK_SLOWMODE_ON.format(seconds))
embed = discord.Embed(description=self.OK_SLOWMODE_ON.format(seconds), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)


elif 0 < seconds <= 120 and ctx.channel.slowmode_delay > 0: # Change value of Slow Mode timer elif 0 < seconds <= 120 and ctx.channel.slowmode_delay > 0: # Change value of Slow Mode timer
await ctx.channel.edit(slowmode_delay=seconds, reason="{} requested slowmode timer be changed to {}".format(ctx.author, seconds)) await ctx.channel.edit(slowmode_delay=seconds, reason="{} requested slowmode timer be changed to {}".format(ctx.author, seconds))
return await ctx.send(self.OK_SLOWMODE_CHANGED.format(seconds))
embed = discord.Embed(description=self.OK_SLOWMODE_CHANGED.format(seconds), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)
elif seconds < 0 or seconds > 120: elif seconds < 0 or seconds > 120:
raise commands.BadArgument(self.ERROR_SLOWMODE_SECONDS) raise commands.BadArgument(self.ERROR_SLOWMODE_SECONDS)


else: else:
predicate = lambda message: message.id != ctx.message.id predicate = lambda message: message.id != ctx.message.id
messages = await ctx.channel.purge(limit=limit, check=predicate) messages = await ctx.channel.purge(limit=limit, check=predicate)
return await ctx.send(self.OK_PURGE_CONFIRMATION.format(len(messages)))
embed = discord.Embed(description=self.OK_PURGE_CONFIRMATION.format(len(messages)), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)


@commands.guild_only() @commands.guild_only()
@commands.has_permissions(kick_members=True) @commands.has_permissions(kick_members=True)
async def warn(self, ctx): async def warn(self, ctx):
"""Group of commands handling . Requires the Kick Members permission.""" """Group of commands handling . Requires the Kick Members permission."""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
return await ctx.send('Missing Argument')
raise commands.CommandNotFound(ctx.subcommand_passed)


@warn.command() @warn.command()
async def add(self, ctx, user: discord.User=None, *, warning=""): async def add(self, ctx, user: discord.User=None, *, warning=""):


warn_limit = 10 warn_limit = 10
if len(warnings[user_id]) > warn_limit: if len(warnings[user_id]) > warn_limit:
return await ctx.send(self.WARN_WARN_ADD_LIMIT_REACHED.format(warn_limit))
embed = discord.Embed(description=self.WARN_WARN_ADD_LIMIT_REACHED.format(warn_limit), colour=roxbot.EmbedColours.red)
return await ctx.send()


warnings[user_id].append(warning_dict) warnings[user_id].append(warning_dict)
settings["admin"]["warnings"] = warnings settings["admin"]["warnings"] = warnings
if amount_warnings >= warning_limit > 0: if amount_warnings >= warning_limit > 0:
await ctx.author.send(self.OK_WARN_ADD_USER_LIMIT_DM.format(str(user), amount_warnings, warning_limit)) await ctx.author.send(self.OK_WARN_ADD_USER_LIMIT_DM.format(str(user), amount_warnings, warning_limit))


return await ctx.send(self.OK_WARN_ADD.format(str(user)))
embed = discord.Embed(description=self.OK_WARN_ADD.format(str(user)), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)


@warn.command() @warn.command()
async def list(self, ctx, *, user: roxbot.converters.User=None): async def list(self, ctx, *, user: roxbot.converters.User=None):
paginator.add_line("{}: {} Warning(s)".format(str(member_obj), len(warnings[member]))) paginator.add_line("{}: {} Warning(s)".format(str(member_obj), len(warnings[member])))
else: else:
paginator.add_line("{}: {} Warning(s)".format(member, len(warnings[member]))) paginator.add_line("{}: {} Warning(s)".format(member, len(warnings[member])))
# This is in case we have removed some users from the list.
settings["admin"]["warnings"] = warnings settings["admin"]["warnings"] = warnings
settings.update(settings["admin"], "admin") settings.update(settings["admin"], "admin")

if len(paginator.pages) <= 0: if len(paginator.pages) <= 0:
return await ctx.send(self.OK_WARN_LIST_NO_WARNINGS)
embed = discord.Embed(description=self.OK_WARN_LIST_NO_WARNINGS, colour=roxbot.EmbedColours.orange)
return await ctx.send(embed=embed)
for page in paginator.pages: for page in paginator.pages:
await ctx.send(page)
await ctx.send(embed=discord.Embed(description=page, colour=roxbot.EmbedColours.pink))
else: else:
user_id = str(user.id) user_id = str(user.id)


if not warnings.get(user_id): if not warnings.get(user_id):
return await ctx.send(self.OK_WARN_LIST_USER_NO_WARNINGS)
embed = discord.Embed(description=self.OK_WARN_LIST_USER_NO_WARNINGS, colour=roxbot.EmbedColours.orange)
return await ctx.send(embed=embed)


em = discord.Embed(title="Warnings for {}".format(str(user)), colour=roxbot.EmbedColours.pink) em = discord.Embed(title="Warnings for {}".format(str(user)), colour=roxbot.EmbedColours.pink)
em.set_thumbnail(url=user.avatar_url) em.set_thumbnail(url=user.avatar_url)


settings["admin"]["warnings"] = warnings settings["admin"]["warnings"] = warnings
settings.update(settings["admin"], "admin") settings.update(settings["admin"], "admin")
return await ctx.send(self.OK_WARN_REMOVE_REMOVED_WARNING.format(index+1, str(user)))
embed = discord.Embed(description=self.OK_WARN_REMOVE_REMOVED_WARNING.format(index+1, str(user)), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)


except Exception as e: except Exception as e:
embed = discord.Embed(colour=roxbot.EmbedColours.red)
if isinstance(e, IndexError): if isinstance(e, IndexError):
return await ctx.send(self.ERROR_WARN_REMOVE_INDEXERROR.format(len(settings["warnings"][user_id])))
embed.description = self.ERROR_WARN_REMOVE_INDEXERROR.format(len(settings["warnings"][user_id]))
elif isinstance(e, KeyError): elif isinstance(e, KeyError):
return await ctx.send(self.WARN_WARN_REMOVE_USER_NOT_FOUND.format(str(user)))
embed.description = self.WARN_WARN_REMOVE_USER_NOT_FOUND.format(str(user))
elif isinstance(e, ValueError): elif isinstance(e, ValueError):
return await ctx.send(self.ERROR_WARN_REMOVE_VALUEERROR)
embed.description = self.ERROR_WARN_REMOVE_VALUEERROR
else: else:
raise e raise e
return ctx.send(embed=embed)
else: else:
try: try:
warnings.pop(user_id) warnings.pop(user_id)
settings["admin"]["warnings"] = warnings settings["admin"]["warnings"] = warnings
settings.update(settings["admin"], "admin") settings.update(settings["admin"], "admin")
return await ctx.send(self.OK_WARN_REMOVE_REMOVED_WARNINGS.format(str(user)))
embed = discord.Embed(description=self.OK_WARN_REMOVE_REMOVED_WARNINGS.format(str(user)), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)
except KeyError: except KeyError:
return await ctx.send(self.WARN_WARN_REMOVE_USER_NOT_FOUND.format(str(user)))
embed = discord.Embed(description=self.WARN_WARN_REMOVE_USER_NOT_FOUND.format(str(user)), colour=roxbot.EmbedColours.orange)
return await ctx.send(embed=embed)


@commands.bot_has_permissions(ban_members=True) @commands.bot_has_permissions(ban_members=True)
@warn.command() @warn.command()
settings["admin"]["warnings"].pop(user) settings["admin"]["warnings"].pop(user)
count += 1 count += 1
settings.update(settings["admin"], "admin") settings.update(settings["admin"], "admin")
return await ctx.send(self.OK_WARN_PRUNE_PRUNED.format(count))
embed = discord.Embed(description=self.OK_WARN_PRUNE_PRUNED.format(count), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)


@warn.command(aliases=["set_limits", "sl", "setlimit", "setlimits"]) @warn.command(aliases=["set_limits", "sl", "setlimit", "setlimits"])
async def set_limit(self, ctx, number_of_warnings: int): async def set_limit(self, ctx, number_of_warnings: int):
admin["warning_limit"] = number_of_warnings admin["warning_limit"] = number_of_warnings
settings.update(admin, "admin") settings.update(admin, "admin")
if number_of_warnings == 0: if number_of_warnings == 0:
return await ctx.send(self.OK_WARN_SL_SET_ZERO)
embed = discord.Embed(description=self.OK_WARN_SL_SET_ZERO, colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)
else: else:
return await ctx.send(self.OK_WARN_SL_SET.format(number_of_warnings))
embed = discord.Embed(description=self.OK_WARN_SL_SET.format(number_of_warnings), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)


@commands.guild_only() @commands.guild_only()
@commands.has_permissions(kick_members=True) @commands.has_permissions(kick_members=True)
"""Kicks mentioned user. Allows you to give a reason. Requires the Kick Members permission.""" """Kicks mentioned user. Allows you to give a reason. Requires the Kick Members permission."""
try: try:
await member.kick(reason=reason) await member.kick(reason=reason)
return await ctx.send(self.OK_MOD_ACTION.format("Kicked", member, reason))
embed = discord.Embed(description=self.OK_MOD_ACTION.format("Kicked", member, reason), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)
except discord.Forbidden: except discord.Forbidden:
return await ctx.send(self.WARN_MOD_LACK_PERMS)
embed = discord.Embed(description=self.WARN_MOD_LACK_PERMS, colour=roxbot.EmbedColours.red)
return await ctx.send(embed=embed)


@commands.guild_only() @commands.guild_only()
@commands.has_permissions(ban_members=True) @commands.has_permissions(ban_members=True)
"""Bans mentioned user. Allows you to give a reason. Requires the Ban Members permission.""" """Bans mentioned user. Allows you to give a reason. Requires the Ban Members permission."""
try: try:
await member.ban(reason=reason, delete_message_days=0) await member.ban(reason=reason, delete_message_days=0)
return await ctx.send(self.OK_MOD_ACTION.format("Banned", member, reason))
embed = discord.Embed(description=self.OK_MOD_ACTION.format("Banned", member, reason), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)
except discord.Forbidden: except discord.Forbidden:
return await ctx.send(self.WARN_MOD_LACK_PERMS)
embed = discord.Embed(description=self.WARN_MOD_LACK_PERMS, colour=roxbot.EmbedColours.red)
return await ctx.send(embed=embed)


@commands.guild_only() @commands.guild_only()
@commands.has_permissions(ban_members=True) @commands.has_permissions(ban_members=True)
ban = await ctx.guild.get_ban(member) ban = await ctx.guild.get_ban(member)
mem = ban.user mem = ban.user
if mem is None: if mem is None:
return await ctx.send(self.WARN_UNBAN_NOTFOUND)
embed = discord.Embed(description=self.WARN_UNBAN_NOTFOUND, colour=roxbot.EmbedColours.red)
return await ctx.send(embed=embed)
try: try:
await ctx.guild.unban(mem, reason=reason) await ctx.guild.unban(mem, reason=reason)
return await ctx.send(self.OK_MOD_ACTION.format("Unbanned", mem, reason))
embed = discord.Embed(description=self.OK_MOD_ACTION.format("Unbanned", mem, reason), colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)
except discord.Forbidden: except discord.Forbidden:
return await ctx.send(self.WARN_MOD_LACK_PERMS)
embed = discord.Embed(description=self.WARN_MOD_LACK_PERMS, colour=roxbot.EmbedColours.red)
return await ctx.send(embed=embed)




def setup(bot_client): def setup(bot_client):

+ 3
- 3
roxbot/cogs/customcommands.py View File

return command return command


@staticmethod @staticmethod
def _embed_values(command_output):
def _cc_to_embed(command_output):
# discord.Embed.Empty is used by discord.py to denote when a field is empty. Hence why it is the fallback here # discord.Embed.Empty is used by discord.py to denote when a field is empty. Hence why it is the fallback here
title = command_output.get("title", discord.Embed.Empty) title = command_output.get("title", discord.Embed.Empty)
desc = command_output.get("description", discord.Embed.Empty) desc = command_output.get("description", discord.Embed.Empty)


elif command in settings["custom_commands"]["2"]: elif command in settings["custom_commands"]["2"]:
command_output = self._get_output(settings["custom_commands"]["2"][command]) command_output = self._get_output(settings["custom_commands"]["2"][command])
embed = self._embed_values(command_output)
embed = self._cc_to_embed(command_output)
return await channel.send(embed=embed) return await channel.send(embed=embed)
else: else:
for command in settings["custom_commands"]["0"]: for command in settings["custom_commands"]["0"]:
Requires the Manage Messages permission. Requires the Manage Messages permission.
""" """
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
return await ctx.send('Missing Argument')
raise commands.CommandNotFound(ctx.subcommand_passed)


@commands.has_permissions(manage_messages=True) @commands.has_permissions(manage_messages=True)
@custom.command() @custom.command()

+ 2
- 1
roxbot/cogs/image.py View File

async def pride(self, ctx): async def pride(self, ctx):
"""A collection of filters that show simple LGBT pride flags over the image provided. """A collection of filters that show simple LGBT pride flags over the image provided.
The filters work with either your pfp, someone elses', or an image provided either by attachment or URL.""" The filters work with either your pfp, someone elses', or an image provided either by attachment or URL."""
pass
if ctx.invoked_subcommand is None:
raise commands.CommandNotFound(ctx.subcommand_passed)


@pride.command() @pride.command()
async def lgbt(self, ctx, image: roxbot.converters.AvatarURL=None): async def lgbt(self, ctx, image: roxbot.converters.AvatarURL=None):

+ 1
- 0
roxbot/cogs/voice.py View File

@commands.command() @commands.command()
async def volume(self, ctx, volume): async def volume(self, ctx, volume):
"""Changes the player's volume. Only accepts integers representing x% between 0-100% or "show", which will show the current volume.""" """Changes the player's volume. Only accepts integers representing x% between 0-100% or "show", which will show the current volume."""
# FIXME: This option shit is fucking disgusting pls fix
try: try:
volume = int(volume) volume = int(volume)
except ValueError: except ValueError:

Loading…
Cancel
Save