Browse Source

Lots of small changes to improve speed and make sure commands are explicit in being guild only

tags/v2.0.0
Roxie Gibson 5 years ago
parent
commit
ad85a060c7
7 changed files with 13 additions and 6 deletions
  1. +2
    -0
      roxbot/cogs/admin.py
  2. +4
    -3
      roxbot/cogs/joinleave.py
  3. +1
    -0
      roxbot/cogs/nsfw.py
  4. +1
    -1
      roxbot/cogs/reddit.py
  5. +1
    -1
      roxbot/cogs/selfassign.py
  6. +2
    -0
      roxbot/cogs/twitch.py
  7. +2
    -1
      roxbot/cogs/voice.py

+ 2
- 0
roxbot/cogs/admin.py View File

;slowmode [time/"off"] ;slowmode [time/"off"]
seconds = number of seconds for the cooldown between messages a user has. seconds = number of seconds for the cooldown between messages a user has.
off = turns off slowmode for this channel""" off = turns off slowmode for this channel"""
# TODO: Edit this when api is avalible for discord's new slowmode feature.
if seconds == "off" and self.slow_mode: # Turn Slow Mode off if seconds == "off" and self.slow_mode: # Turn Slow Mode off
self.slow_mode = False self.slow_mode = False
self.slow_mode_channels.pop(ctx.channel.id) self.slow_mode_channels.pop(ctx.channel.id)
else: else:
pass pass


@commands.guild_only()
@commands.has_permissions(manage_messages=True) @commands.has_permissions(manage_messages=True)
@commands.bot_has_permissions(manage_messages=True, read_message_history=True) @commands.bot_has_permissions(manage_messages=True, read_message_history=True)
@commands.cooldown(1, 5) @commands.cooldown(1, 5)

+ 4
- 3
roxbot/cogs/joinleave.py View File

colour=roxbot.EmbedColours.pink) colour=roxbot.EmbedColours.pink)
em.set_thumbnail(url=member.avatar_url) em.set_thumbnail(url=member.avatar_url)


channel = self.bot.get_channel(settings["greets"]["welcome-channel"])
channel = member.guild.get_channel(settings["greets"]["welcome-channel"])
return await channel.send(embed=em) return await channel.send(embed=em)


async def on_member_remove(self, member): async def on_member_remove(self, member):
if not settings["goodbyes"]["enabled"]: if not settings["goodbyes"]["enabled"]:
return return
else: else:
channel = self.bot.get_channel(channel)
channel = member.guild.get_channel(channel)
return await channel.send(embed=discord.Embed( return await channel.send(embed=discord.Embed(
description="{}#{} has left or been beaned.".format(member.name, member.discriminator), colour=roxbot.EmbedColours.pink)) description="{}#{} has left or been beaned.".format(member.name, member.discriminator), colour=roxbot.EmbedColours.pink))


@commands.guild_only()
@commands.has_permissions(manage_messages=True) @commands.has_permissions(manage_messages=True)
@commands.command() @commands.command()
async def greets(self, ctx, setting, channel: typing.Optional[discord.TextChannel] = None, *, text: str): async def greets(self, ctx, setting, channel: typing.Optional[discord.TextChannel] = None, *, text: str):
return await ctx.send("No valid option given.") return await ctx.send("No valid option given.")
return settings.update(greets, "greets") return settings.update(greets, "greets")


@commands.guild_only()
@commands.has_permissions(manage_messages=True) @commands.has_permissions(manage_messages=True)
@commands.command() @commands.command()
async def goodbyes(self, ctx, setting, *, channel: typing.Optional[discord.TextChannel] = None): async def goodbyes(self, ctx, setting, *, channel: typing.Optional[discord.TextChannel] = None):

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

post_url = "https://simg3.gelbooru.com/images/" post_url = "https://simg3.gelbooru.com/images/"
return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url=post_url, tags=tags) return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url=post_url, tags=tags)


@commands.guild_only()
@commands.has_permissions(manage_channels=True) @commands.has_permissions(manage_channels=True)
@commands.command() @commands.command()
async def nsfw(self, ctx, setting, *, changes=None): async def nsfw(self, ctx, setting, *, changes=None):

+ 1
- 1
roxbot/cogs/reddit.py View File

if ctx.invoked_with == "subreddit" and isinstance(ctx.channel, discord.TextChannel): if ctx.invoked_with == "subreddit" and isinstance(ctx.channel, discord.TextChannel):
# Only log the command when it is this command being used. Not the inbuilt commands. # Only log the command when it is this command being used. Not the inbuilt commands.
logging = guild_settings.get(ctx.guild)["logging"] logging = guild_settings.get(ctx.guild)["logging"]
log_channel = self.bot.get_channel(logging["channel"])
log_channel = ctx.guild.get_channel(logging["channel"])
await roxbot.log( await roxbot.log(
ctx.guild, ctx.guild,
log_channel, log_channel,

+ 1
- 1
roxbot/cogs/selfassign.py View File

sa["roles"].remove(role.id) sa["roles"].remove(role.id)
return settings.update(sa, "self_assign") return settings.update(sa, "self_assign")


@commands.has_permissions(manage_roles=True)
@commands.guild_only() @commands.guild_only()
@commands.has_permissions(manage_roles=True)
@commands.command(aliases=["sa"]) @commands.command(aliases=["sa"])
async def selfassign(self, ctx, setting, *, role: discord.Role): async def selfassign(self, ctx, setting, *, role: discord.Role):
"""Edits settings for self assign cog. Requires Manage Roles permission. """Edits settings for self assign cog. Requires Manage Roles permission.

+ 2
- 0
roxbot/cogs/twitch.py View File

return await channel.send(":video_game:** {} is live!** :video_game:\n{}\n{}".format( return await channel.send(":video_game:** {} is live!** :video_game:\n{}\n{}".format(
member_a.name, member_a.game.name, member_a.game.url)) member_a.name, member_a.game.name, member_a.game.url))


@commands.guild_only()
@commands.group(aliases=["wl"]) @commands.group(aliases=["wl"])
@commands.has_permissions(manage_channels=True) @commands.has_permissions(manage_channels=True)
async def whitelist(self, ctx): async def whitelist(self, ctx):
elif option == 'list': elif option == 'list':
return await ctx.send(settings["twitch"]["whitelist"]["list"]) return await ctx.send(settings["twitch"]["whitelist"]["list"])


@commands.guild_only()
@commands.has_permissions(manage_channels=True) @commands.has_permissions(manage_channels=True)
@commands.command() @commands.command()
async def twitch(self, ctx, setting, *, channel: discord.TextChannel = None): async def twitch(self, ctx, setting, *, channel: discord.TextChannel = None):

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

Duration: {1} Duration: {1}
Queued by: {0.queued_by}""".format(now_playing, duration) Queued by: {0.queued_by}""".format(now_playing, duration)
image = np.thumbnail_url image = np.thumbnail_url
footer_text="{}/{} | Volume: {}%".format(time_played, duration, int(now_playing.volume * 100))
footer_text = "{}/{} | Volume: {}%".format(time_played, duration, int(now_playing.volume * 100))
return cls( return cls(
title=title, title=title,
url=np.webpage_url, url=np.webpage_url,
except AttributeError: except AttributeError:
raise commands.CommandError("I'm not playing anything.") raise commands.CommandError("I'm not playing anything.")


@commands.guild_only()
@commands.has_permissions(manage_channels=True) @commands.has_permissions(manage_channels=True)
@commands.command() @commands.command()
async def voice(self, ctx, setting=None, change=None): async def voice(self, ctx, setting=None, change=None):

Loading…
Cancel
Save