Browse Source

moved over all command wrappers to commands.command instead of bot.command as the latter now breaks the program. And its cleaner.

tags/v2.0.0
Roxie Gibson 5 years ago
parent
commit
5ee6a4671a
7 changed files with 45 additions and 36 deletions
  1. +11
    -1
      main.py
  2. +5
    -5
      roxbot/cogs/admin.py
  3. +12
    -12
      roxbot/cogs/fun.py
  4. +1
    -1
      roxbot/cogs/image.py
  5. +5
    -5
      roxbot/cogs/nsfw.py
  6. +9
    -10
      roxbot/cogs/util.py
  7. +2
    -2
      roxbot/system.py

+ 11
- 1
main.py View File

@@ -76,11 +76,21 @@ bot = commands.Bot(
@bot.event
async def on_ready():
# Load Roxbots inbuilt cogs and settings
print("Loading Bot internals...")

bot.load_extension("roxbot.system")
print("system.py Loaded")

bot.load_extension("roxbot.settings.settings")
print("settings.py Loaded")

bot.load_extension("roxbot.err_handle")
print("err_handle.py Loaded")

bot.load_extension("roxbot.logging")
bot.load_extension("roxbot.system")
print("logging.py Loaded")

print("")
print("Discord.py version: " + discord.__version__)
print("Client logged in\n")


+ 5
- 5
roxbot/cogs/admin.py View File

@@ -78,7 +78,7 @@ class Admin:
@roxbot.checks.is_admin_or_mod()
@commands.guild_only()
@commands.bot_has_permissions(manage_messages=True)
@bot.command()
@commands.command()
async def slowmode(self, ctx, seconds):
"""Puts the current channel in slowmode.
Usage:
@@ -107,7 +107,7 @@ class Admin:
@commands.has_permissions(manage_messages=True)
@commands.bot_has_permissions(manage_messages=True, read_message_history=True)
@commands.cooldown(1, 5)
@bot.command()
@commands.command()
async def purge(self, ctx, limit=0, *, author: roxbot.converters.UserConverter=None):
"""Purges messages from the text channel.
Limit = Limit of messages to be deleted
@@ -252,7 +252,7 @@ class Admin:

@commands.has_permissions(kick_members=True)
@commands.bot_has_permissions(kick_members=True)
@bot.command()
@commands.command()
async def kick(self, ctx, member: discord.Member, *, reason=""):
"""Kicks mentioned user. Allows you to give a reason."""
try:
@@ -263,7 +263,7 @@ class Admin:

@commands.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@bot.command()
@commands.command()
async def ban(self, ctx, member: discord.Member, *, reason=""):
"""Bans mentioned user. Allows you to give a reason."""
try:
@@ -274,7 +274,7 @@ class Admin:

@commands.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@bot.command()
@commands.command()
async def unban(self, ctx, member: roxbot.converters.UserConverter, *, reason=""):
"""Unbans user with given ID. Allows you to give a reason."""
ban = await ctx.guild.get_ban(member)

+ 12
- 12
roxbot/cogs/fun.py View File

@@ -42,7 +42,7 @@ class Fun:
self.bot = bot_client
self.croak = {}

@bot.command() # Terra made this and it just work's but im too scared to clean it up so i hope it doesn't break
@commands.command() # Terra made this and it just work's but im too scared to clean it up so i hope it doesn't break
async def roll(self, ctx, *, expression=""):
"""
Rolls a die using dice expression format.
@@ -189,7 +189,7 @@ class Fun:
return await ctx.send(response)

@roxbot.checks.isnt_anal()
@bot.command()
@commands.command()
async def spank(self, ctx, *, user: discord.User = None):
"""
Spanks the mentioned user ;)
@@ -202,7 +202,7 @@ class Fun:
return await ctx.send(":peach: :wave: *{} spanks {}*".format(self.bot.user.name, user.name))

@roxbot.checks.isnt_anal()
@bot.command(aliases=["succ"])
@commands.command(aliases=["succ"])
async def suck(self, ctx, *, user: discord.User = None):
"""
Sucks the mentioned user ;)
@@ -214,7 +214,7 @@ class Fun:
return await ctx.send("You didn't mention someone for me to suck")
return await ctx.send(":eggplant: :sweat_drops: :tongue: *{} sucks {}*".format(self.bot.user.name, user.name))

@bot.command()
@commands.command()
async def hug(self, ctx, *, user: discord.User = None):
"""
Hugs the mentioned user :3
@@ -226,7 +226,7 @@ class Fun:
return await ctx.send("You didn't mention someone for me to hug")
return await ctx.send(":blush: *{} hugs {}*".format(self.bot.user.name, user.name))

@bot.command(aliases=["headpat", "pat"])
@commands.command(aliases=["headpat", "pat"])
async def pet(self, ctx, *, user: discord.User = None):
"""
Gives headpats to the mentioned user :3
@@ -238,7 +238,7 @@ class Fun:
return await ctx.send("You didn't mention someone for me to headpat")
return await ctx.send("Nyaa! :3 *{} gives headpats to {}*".format(self.bot.user.name, user.name))

@bot.command(aliases=["wf", "wr", "husbandorate", "hr", "spousurate", "sr"])
@commands.command(aliases=["wf", "wr", "husbandorate", "hr", "spousurate", "sr"])
async def waifurate(self, ctx):
"""
Rates the mentioned waifu(s). husbando/spousurate also work.
@@ -276,12 +276,12 @@ class Fun:
else:
return await ctx.send("Oh that's your {}? I rate them a {}/10. {}".format(waifu, rating, emoji))

@bot.command(aliases=["cf"])
@commands.command(aliases=["cf"])
async def coinflip(self, ctx):
"""Flip a coin"""
return await ctx.send("The coin landed on {}!".format(random.choice(["heads", "tails"])))

@bot.command()
@commands.command()
async def aesthetics(self, ctx, *, convert):
"""Converts text to be more a e s t h e t i c s"""
wide_map = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)) # Create dict with fixed width equivalents for chars
@@ -303,7 +303,7 @@ class Fun:
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@bot.command(aliases=["ft", "frog"])
@commands.command(aliases=["ft", "frog"])
async def frogtips(self, ctx):
"""RETURNS FROG TIPS FOR HOW TO OPERATE YOUR FROG"""
endpoint = "https://frog.tips/api/1/tips/"
@@ -316,7 +316,7 @@ class Fun:
embed.set_footer(text="https://frog.tips")
return await ctx.send(embed=embed)

@bot.command(aliases=["otd"])
@commands.command(aliases=["otd"])
async def onthisday(self, ctx):
"""Returns a fact that happened on this day."""
base_url = "http://numbersapi.com/"
@@ -334,7 +334,7 @@ class Fun:
embed.set_footer(text=base_url)
return await ctx.send(embed=embed)

@bot.command(aliases=["nf"])
@commands.command(aliases=["nf"])
async def numberfact(self, ctx, number=-54):
"""Returns a fact for the positive integer given. A random number is chosen if none is given."""
base_url = "http://numbersapi.com/"
@@ -357,7 +357,7 @@ class Fun:
embed.set_footer(text=base_url)
return await ctx.send(embed=embed)

@bot.command()
@commands.command()
@commands.has_permissions(add_reactions=True)
@commands.bot_has_permissions(add_reactions=True)
async def xkcd(self, ctx, *, query=None):

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

@@ -154,7 +154,7 @@ class ImageEditor:
if prob < random.random():
img_matrix[x][y] = 255

noisy = Image.fromarray(img_matrix, "L")
noisy = Image.fromarray(img_matrix, "L").show()
noisy = noisy.convert("RGB")
mask = Image.new('RGBA', img.size, (0, 0, 0, opacity))
return Image.composite(noisy, img, mask)

+ 5
- 5
roxbot/cogs/nsfw.py View File

@@ -26,7 +26,7 @@ SOFTWARE.


import random
from discord.ext.commands import bot
from discord.ext import commands

import roxbot
from roxbot import guild_settings as gs
@@ -47,7 +47,7 @@ class NFSW():
self.cache[guild.id] = []

@roxbot.checks.is_nfsw_enabled()
@bot.command(hidden=True)
@commands.command(hidden=True)
async def gelbooru_clone(self, ctx, base_url, post_url, tags):
limit = 150
tags = tags + tag_blacklist(ctx.guild)
@@ -77,7 +77,7 @@ class NFSW():
await roxbot.utils.delete_option(self.bot, ctx, output, self.bot.get_emoji(444410658101002261) or "❌")

@roxbot.checks.is_nfsw_enabled()
@bot.command()
@commands.command()
async def e621(self, ctx, *, tags=""):
"""
Returns an image from e621.com and can use tags you provide.
@@ -86,7 +86,7 @@ class NFSW():
return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url="", tags=tags)

@roxbot.checks.is_nfsw_enabled()
@bot.command()
@commands.command()
async def rule34(self, ctx, *, tags=""):
"""
Returns an image from rule34.xxx and can use tags you provide.
@@ -96,7 +96,7 @@ class NFSW():
return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url=post_url, tags=tags)

@roxbot.checks.is_nfsw_enabled()
@bot.command()
@commands.command()
async def gelbooru(self, ctx, *, tags=""):
"""
Returns an image from gelbooru.com and can use tags you provide.

+ 9
- 10
roxbot/cogs/util.py View File

@@ -29,7 +29,6 @@ import os
import random
import discord
from discord.ext import commands
from discord.ext.commands import bot

import roxbot

@@ -41,7 +40,7 @@ class Util():
def __init__(self, bot_client):
self.bot = bot_client

@bot.command()
@commands.command()
async def avatar(self, ctx, *, user: discord.User = None):
"""
Returns a mentioned users avatar
@@ -62,7 +61,7 @@ class Util():
await ctx.send(file=discord.File(avaimg))
os.remove(avaimg)

@bot.command()
@commands.command()
async def info(self, ctx, member: discord.Member = None):
"""
Gets info for a mentioned user
@@ -114,7 +113,7 @@ class Util():
return await ctx.send(embed=embed)

@commands.guild_only()
@bot.command(aliases=["server"])
@commands.command(aliases=["server"])
async def guild(self, ctx):
"""Returns info on the current guild(server)."""
guild = ctx.guild
@@ -151,7 +150,7 @@ class Util():
return await ctx.send(embed=embed)

@commands.guild_only()
@bot.command()
@commands.command()
async def role(self, ctx, *, role: discord.Role):
"""Displays the info on a role"""
embed = discord.Embed(title="Role '{}'".format(role.name), colour=role.colour.value)
@@ -162,7 +161,7 @@ class Util():
embed.add_field(name="Managed", value=str(role.managed), inline=False)
return await ctx.send(embed=embed)

@bot.command(enabled=False, hidden=True)
@commands.command(enabled=False, hidden=True)
async def upload(self, ctx):
"""
Uploads selected file to the host, thanks to the fact that
@@ -201,7 +200,7 @@ class Util():
async def upload_err(self, ctx):
return await ctx.send("File couldn't be uploaded.")

@bot.command(aliases=["emoji"])
@commands.command(aliases=["emoji"])
async def emote(self, ctx, emote: roxbot.converters.EmojiConverter):
"""
Uploads the emote given. Useful for downloading emotes.
@@ -227,18 +226,18 @@ class Util():
except IndexError:
return await ctx.send("This command only supports custom emojis at the moment. Sorry.")

@bot.command()
@commands.command()
async def lookup(self, ctx, ID: int):
result = self.bot.get_channel(ID)
pass

@bot.command(hidden=True)
@commands.command(hidden=True)
async def inviteme(self, ctx):
"""Returns an invite link to invite the bot to your server."""
link = discord.utils.oauth_url(self.bot.user.id, discord.Permissions.all_channel())
return await ctx.send("WARNING: This is only for Roxie to use atm. Here is a link to invite me to your server! <{}>".format(link))

@bot.command()
@commands.command()
@commands.is_owner()
async def echo(self, ctx, channel: discord.TextChannel, *, message: str):
await channel.send(message)

+ 2
- 2
roxbot/system.py View File

@@ -107,11 +107,11 @@ class System:
await ctx.message.attachments[0].save(avaimg)
else:
url = url.strip('<>')
roxbot.http.download_file(url, avaimg)
await roxbot.http.download_file(url, avaimg)
with open(avaimg, 'rb') as f:
await self.bot.user.edit(avatar=f.read())
os.remove(avaimg)
asyncio.sleep(2)
await asyncio.sleep(2)
return await ctx.send(":ok_hand:")

@commands.command(aliases=["nick", "nickname"])

Loading…
Cancel
Save