@bot.event | @bot.event | ||||
async def on_ready(): | async def on_ready(): | ||||
# Load Roxbots inbuilt cogs and settings | # 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") | bot.load_extension("roxbot.settings.settings") | ||||
print("settings.py Loaded") | |||||
bot.load_extension("roxbot.err_handle") | bot.load_extension("roxbot.err_handle") | ||||
print("err_handle.py Loaded") | |||||
bot.load_extension("roxbot.logging") | bot.load_extension("roxbot.logging") | ||||
bot.load_extension("roxbot.system") | |||||
print("logging.py Loaded") | |||||
print("") | |||||
print("Discord.py version: " + discord.__version__) | print("Discord.py version: " + discord.__version__) | ||||
print("Client logged in\n") | print("Client logged in\n") | ||||
@roxbot.checks.is_admin_or_mod() | @roxbot.checks.is_admin_or_mod() | ||||
@commands.guild_only() | @commands.guild_only() | ||||
@commands.bot_has_permissions(manage_messages=True) | @commands.bot_has_permissions(manage_messages=True) | ||||
@bot.command() | |||||
@commands.command() | |||||
async def slowmode(self, ctx, seconds): | async def slowmode(self, ctx, seconds): | ||||
"""Puts the current channel in slowmode. | """Puts the current channel in slowmode. | ||||
Usage: | Usage: | ||||
@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) | ||||
@bot.command() | |||||
@commands.command() | |||||
async def purge(self, ctx, limit=0, *, author: roxbot.converters.UserConverter=None): | async def purge(self, ctx, limit=0, *, author: roxbot.converters.UserConverter=None): | ||||
"""Purges messages from the text channel. | """Purges messages from the text channel. | ||||
Limit = Limit of messages to be deleted | Limit = Limit of messages to be deleted | ||||
@commands.has_permissions(kick_members=True) | @commands.has_permissions(kick_members=True) | ||||
@commands.bot_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=""): | async def kick(self, ctx, member: discord.Member, *, reason=""): | ||||
"""Kicks mentioned user. Allows you to give a reason.""" | """Kicks mentioned user. Allows you to give a reason.""" | ||||
try: | try: | ||||
@commands.has_permissions(ban_members=True) | @commands.has_permissions(ban_members=True) | ||||
@commands.bot_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=""): | async def ban(self, ctx, member: discord.Member, *, reason=""): | ||||
"""Bans mentioned user. Allows you to give a reason.""" | """Bans mentioned user. Allows you to give a reason.""" | ||||
try: | try: | ||||
@commands.has_permissions(ban_members=True) | @commands.has_permissions(ban_members=True) | ||||
@commands.bot_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=""): | async def unban(self, ctx, member: roxbot.converters.UserConverter, *, reason=""): | ||||
"""Unbans user with given ID. Allows you to give a reason.""" | """Unbans user with given ID. Allows you to give a reason.""" | ||||
ban = await ctx.guild.get_ban(member) | ban = await ctx.guild.get_ban(member) |
self.bot = bot_client | self.bot = bot_client | ||||
self.croak = {} | 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=""): | async def roll(self, ctx, *, expression=""): | ||||
""" | """ | ||||
Rolls a die using dice expression format. | Rolls a die using dice expression format. | ||||
return await ctx.send(response) | return await ctx.send(response) | ||||
@roxbot.checks.isnt_anal() | @roxbot.checks.isnt_anal() | ||||
@bot.command() | |||||
@commands.command() | |||||
async def spank(self, ctx, *, user: discord.User = None): | async def spank(self, ctx, *, user: discord.User = None): | ||||
""" | """ | ||||
Spanks the mentioned user ;) | Spanks the mentioned user ;) | ||||
return await ctx.send(":peach: :wave: *{} spanks {}*".format(self.bot.user.name, user.name)) | return await ctx.send(":peach: :wave: *{} spanks {}*".format(self.bot.user.name, user.name)) | ||||
@roxbot.checks.isnt_anal() | @roxbot.checks.isnt_anal() | ||||
@bot.command(aliases=["succ"]) | |||||
@commands.command(aliases=["succ"]) | |||||
async def suck(self, ctx, *, user: discord.User = None): | async def suck(self, ctx, *, user: discord.User = None): | ||||
""" | """ | ||||
Sucks the mentioned user ;) | Sucks the mentioned user ;) | ||||
return await ctx.send("You didn't mention someone for me to suck") | 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)) | 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): | async def hug(self, ctx, *, user: discord.User = None): | ||||
""" | """ | ||||
Hugs the mentioned user :3 | Hugs the mentioned user :3 | ||||
return await ctx.send("You didn't mention someone for me to hug") | 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)) | 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): | async def pet(self, ctx, *, user: discord.User = None): | ||||
""" | """ | ||||
Gives headpats to the mentioned user :3 | Gives headpats to the mentioned user :3 | ||||
return await ctx.send("You didn't mention someone for me to headpat") | 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)) | 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): | async def waifurate(self, ctx): | ||||
""" | """ | ||||
Rates the mentioned waifu(s). husbando/spousurate also work. | Rates the mentioned waifu(s). husbando/spousurate also work. | ||||
else: | else: | ||||
return await ctx.send("Oh that's your {}? I rate them a {}/10. {}".format(waifu, rating, emoji)) | 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): | async def coinflip(self, ctx): | ||||
"""Flip a coin""" | """Flip a coin""" | ||||
return await ctx.send("The coin landed on {}!".format(random.choice(["heads", "tails"]))) | return await ctx.send("The coin landed on {}!".format(random.choice(["heads", "tails"]))) | ||||
@bot.command() | |||||
@commands.command() | |||||
async def aesthetics(self, ctx, *, convert): | async def aesthetics(self, ctx, *, convert): | ||||
"""Converts text to be more a e s t h e t i c s""" | """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 | wide_map = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)) # Create dict with fixed width equivalents for chars | ||||
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at) | 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): | async def frogtips(self, ctx): | ||||
"""RETURNS FROG TIPS FOR HOW TO OPERATE YOUR FROG""" | """RETURNS FROG TIPS FOR HOW TO OPERATE YOUR FROG""" | ||||
endpoint = "https://frog.tips/api/1/tips/" | endpoint = "https://frog.tips/api/1/tips/" | ||||
embed.set_footer(text="https://frog.tips") | embed.set_footer(text="https://frog.tips") | ||||
return await ctx.send(embed=embed) | return await ctx.send(embed=embed) | ||||
@bot.command(aliases=["otd"]) | |||||
@commands.command(aliases=["otd"]) | |||||
async def onthisday(self, ctx): | async def onthisday(self, ctx): | ||||
"""Returns a fact that happened on this day.""" | """Returns a fact that happened on this day.""" | ||||
base_url = "http://numbersapi.com/" | base_url = "http://numbersapi.com/" | ||||
embed.set_footer(text=base_url) | embed.set_footer(text=base_url) | ||||
return await ctx.send(embed=embed) | return await ctx.send(embed=embed) | ||||
@bot.command(aliases=["nf"]) | |||||
@commands.command(aliases=["nf"]) | |||||
async def numberfact(self, ctx, number=-54): | async def numberfact(self, ctx, number=-54): | ||||
"""Returns a fact for the positive integer given. A random number is chosen if none is given.""" | """Returns a fact for the positive integer given. A random number is chosen if none is given.""" | ||||
base_url = "http://numbersapi.com/" | base_url = "http://numbersapi.com/" | ||||
embed.set_footer(text=base_url) | embed.set_footer(text=base_url) | ||||
return await ctx.send(embed=embed) | return await ctx.send(embed=embed) | ||||
@bot.command() | |||||
@commands.command() | |||||
@commands.has_permissions(add_reactions=True) | @commands.has_permissions(add_reactions=True) | ||||
@commands.bot_has_permissions(add_reactions=True) | @commands.bot_has_permissions(add_reactions=True) | ||||
async def xkcd(self, ctx, *, query=None): | async def xkcd(self, ctx, *, query=None): |
if prob < random.random(): | if prob < random.random(): | ||||
img_matrix[x][y] = 255 | img_matrix[x][y] = 255 | ||||
noisy = Image.fromarray(img_matrix, "L") | |||||
noisy = Image.fromarray(img_matrix, "L").show() | |||||
noisy = noisy.convert("RGB") | noisy = noisy.convert("RGB") | ||||
mask = Image.new('RGBA', img.size, (0, 0, 0, opacity)) | mask = Image.new('RGBA', img.size, (0, 0, 0, opacity)) | ||||
return Image.composite(noisy, img, mask) | return Image.composite(noisy, img, mask) |
import random | import random | ||||
from discord.ext.commands import bot | |||||
from discord.ext import commands | |||||
import roxbot | import roxbot | ||||
from roxbot import guild_settings as gs | from roxbot import guild_settings as gs | ||||
self.cache[guild.id] = [] | self.cache[guild.id] = [] | ||||
@roxbot.checks.is_nfsw_enabled() | @roxbot.checks.is_nfsw_enabled() | ||||
@bot.command(hidden=True) | |||||
@commands.command(hidden=True) | |||||
async def gelbooru_clone(self, ctx, base_url, post_url, tags): | async def gelbooru_clone(self, ctx, base_url, post_url, tags): | ||||
limit = 150 | limit = 150 | ||||
tags = tags + tag_blacklist(ctx.guild) | tags = tags + tag_blacklist(ctx.guild) | ||||
await roxbot.utils.delete_option(self.bot, ctx, output, self.bot.get_emoji(444410658101002261) or "❌") | await roxbot.utils.delete_option(self.bot, ctx, output, self.bot.get_emoji(444410658101002261) or "❌") | ||||
@roxbot.checks.is_nfsw_enabled() | @roxbot.checks.is_nfsw_enabled() | ||||
@bot.command() | |||||
@commands.command() | |||||
async def e621(self, ctx, *, tags=""): | async def e621(self, ctx, *, tags=""): | ||||
""" | """ | ||||
Returns an image from e621.com and can use tags you provide. | Returns an image from e621.com and can use tags you provide. | ||||
return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url="", tags=tags) | return await ctx.invoke(self.gelbooru_clone, base_url=base_url, post_url="", tags=tags) | ||||
@roxbot.checks.is_nfsw_enabled() | @roxbot.checks.is_nfsw_enabled() | ||||
@bot.command() | |||||
@commands.command() | |||||
async def rule34(self, ctx, *, tags=""): | async def rule34(self, ctx, *, tags=""): | ||||
""" | """ | ||||
Returns an image from rule34.xxx and can use tags you provide. | Returns an image from rule34.xxx and can use tags you provide. | ||||
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) | ||||
@roxbot.checks.is_nfsw_enabled() | @roxbot.checks.is_nfsw_enabled() | ||||
@bot.command() | |||||
@commands.command() | |||||
async def gelbooru(self, ctx, *, tags=""): | async def gelbooru(self, ctx, *, tags=""): | ||||
""" | """ | ||||
Returns an image from gelbooru.com and can use tags you provide. | Returns an image from gelbooru.com and can use tags you provide. |
import random | import random | ||||
import discord | import discord | ||||
from discord.ext import commands | from discord.ext import commands | ||||
from discord.ext.commands import bot | |||||
import roxbot | import roxbot | ||||
def __init__(self, bot_client): | def __init__(self, bot_client): | ||||
self.bot = bot_client | self.bot = bot_client | ||||
@bot.command() | |||||
@commands.command() | |||||
async def avatar(self, ctx, *, user: discord.User = None): | async def avatar(self, ctx, *, user: discord.User = None): | ||||
""" | """ | ||||
Returns a mentioned users avatar | Returns a mentioned users avatar | ||||
await ctx.send(file=discord.File(avaimg)) | await ctx.send(file=discord.File(avaimg)) | ||||
os.remove(avaimg) | os.remove(avaimg) | ||||
@bot.command() | |||||
@commands.command() | |||||
async def info(self, ctx, member: discord.Member = None): | async def info(self, ctx, member: discord.Member = None): | ||||
""" | """ | ||||
Gets info for a mentioned user | Gets info for a mentioned user | ||||
return await ctx.send(embed=embed) | return await ctx.send(embed=embed) | ||||
@commands.guild_only() | @commands.guild_only() | ||||
@bot.command(aliases=["server"]) | |||||
@commands.command(aliases=["server"]) | |||||
async def guild(self, ctx): | async def guild(self, ctx): | ||||
"""Returns info on the current guild(server).""" | """Returns info on the current guild(server).""" | ||||
guild = ctx.guild | guild = ctx.guild | ||||
return await ctx.send(embed=embed) | return await ctx.send(embed=embed) | ||||
@commands.guild_only() | @commands.guild_only() | ||||
@bot.command() | |||||
@commands.command() | |||||
async def role(self, ctx, *, role: discord.Role): | async def role(self, ctx, *, role: discord.Role): | ||||
"""Displays the info on a role""" | """Displays the info on a role""" | ||||
embed = discord.Embed(title="Role '{}'".format(role.name), colour=role.colour.value) | embed = discord.Embed(title="Role '{}'".format(role.name), colour=role.colour.value) | ||||
embed.add_field(name="Managed", value=str(role.managed), inline=False) | embed.add_field(name="Managed", value=str(role.managed), inline=False) | ||||
return await ctx.send(embed=embed) | return await ctx.send(embed=embed) | ||||
@bot.command(enabled=False, hidden=True) | |||||
@commands.command(enabled=False, hidden=True) | |||||
async def upload(self, ctx): | async def upload(self, ctx): | ||||
""" | """ | ||||
Uploads selected file to the host, thanks to the fact that | Uploads selected file to the host, thanks to the fact that | ||||
async def upload_err(self, ctx): | async def upload_err(self, ctx): | ||||
return await ctx.send("File couldn't be uploaded.") | 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): | async def emote(self, ctx, emote: roxbot.converters.EmojiConverter): | ||||
""" | """ | ||||
Uploads the emote given. Useful for downloading emotes. | Uploads the emote given. Useful for downloading emotes. | ||||
except IndexError: | except IndexError: | ||||
return await ctx.send("This command only supports custom emojis at the moment. Sorry.") | 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): | async def lookup(self, ctx, ID: int): | ||||
result = self.bot.get_channel(ID) | result = self.bot.get_channel(ID) | ||||
pass | pass | ||||
@bot.command(hidden=True) | |||||
@commands.command(hidden=True) | |||||
async def inviteme(self, ctx): | async def inviteme(self, ctx): | ||||
"""Returns an invite link to invite the bot to your server.""" | """Returns an invite link to invite the bot to your server.""" | ||||
link = discord.utils.oauth_url(self.bot.user.id, discord.Permissions.all_channel()) | 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)) | 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() | @commands.is_owner() | ||||
async def echo(self, ctx, channel: discord.TextChannel, *, message: str): | async def echo(self, ctx, channel: discord.TextChannel, *, message: str): | ||||
await channel.send(message) | await channel.send(message) |
await ctx.message.attachments[0].save(avaimg) | await ctx.message.attachments[0].save(avaimg) | ||||
else: | else: | ||||
url = url.strip('<>') | url = url.strip('<>') | ||||
roxbot.http.download_file(url, avaimg) | |||||
await roxbot.http.download_file(url, avaimg) | |||||
with open(avaimg, 'rb') as f: | with open(avaimg, 'rb') as f: | ||||
await self.bot.user.edit(avatar=f.read()) | await self.bot.user.edit(avatar=f.read()) | ||||
os.remove(avaimg) | os.remove(avaimg) | ||||
asyncio.sleep(2) | |||||
await asyncio.sleep(2) | |||||
return await ctx.send(":ok_hand:") | return await ctx.send(":ok_hand:") | ||||
@commands.command(aliases=["nick", "nickname"]) | @commands.command(aliases=["nick", "nickname"]) |