@@ -0,0 +1,22 @@ | |||
from Roxbot import checks | |||
from Roxbot.load_config import * | |||
from Roxbot.logging import log | |||
from Roxbot.settings import guild_settings | |||
def blacklisted(user): | |||
with open("Roxbot/settings/blacklist.txt", "r") as fp: | |||
for line in fp.readlines(): | |||
if str(user.id)+"\n" == line: | |||
return True | |||
return False | |||
__description__ = """RoxBot, A Discord Bot made by a filthy Mercy Main. Built with love (and discord.py) by Roxxers#7443. | |||
[Github link](https://github.com/RainbowDinoaur/roxbot) | |||
[Changelog](https://github.com/RainbowDinoaur/roxbot#v100) | |||
[Found a bug or need to report an issue? Report it here](https://github.com/RainbowRoxxers/roxbot/issues/new) | |||
[Say Thanks](https://saythanks.io/to/Roxxers)""" | |||
__author__ = "Roxanne Gibson" | |||
__version__ = "1.6.1" |
@@ -4,12 +4,12 @@ import datetime | |||
from discord.ext import commands | |||
from discord.ext.commands import bot | |||
from Roxbot import checks, load_config | |||
from Roxbot.settings import guild_settings as gs | |||
import Roxbot as roxbot | |||
gs = roxbot.guild_settings | |||
def _is_admin_or_mod(message): | |||
if message.author.id == load_config.owner: | |||
def _is_admin_or_mod(message): # TODO: Remove this function and find a better solution thank. | |||
if message.author.id == roxbot.owner: | |||
return True | |||
else: | |||
admin_roles = gs.get(message.channel.guild).perm_roles["admin"] | |||
@@ -50,31 +50,31 @@ class Admin(): | |||
else: | |||
pass | |||
@roxbot.checks.is_admin_or_mod() | |||
@commands.guild_only() | |||
@checks.is_admin_or_mod() | |||
@commands.bot_has_permissions(manage_messages=True) | |||
@bot.command() | |||
async def slowmode(self, ctx, time): | |||
async def slowmode(self, ctx, seconds): | |||
"""Puts the current channel in slowmode. | |||
Usage: | |||
;slowmode [time/"off"] | |||
time = time of 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""" | |||
if time == "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_channels.pop(ctx.channel.id) | |||
self.users.pop(ctx.channel.id) | |||
return await ctx.send("Slowmode off") | |||
elif time.isdigit() and not self.slow_mode: # Turn Slow Mode On | |||
elif seconds.isdigit() and not self.slow_mode: # Turn Slow Mode On | |||
self.users[ctx.channel.id] = {} | |||
self.slow_mode_channels[ctx.channel.id] = int(time) | |||
self.slow_mode_channels[ctx.channel.id] = int(seconds) | |||
self.slow_mode = True | |||
return await ctx.send("Slowmode on :snail: ({} seconds)".format(time)) | |||
return await ctx.send("Slowmode on :snail: ({} seconds)".format(seconds)) | |||
elif time.isdigit and self.slow_mode: # Change value of Slow Mode timer | |||
self.slow_mode_channels[ctx.channel.id] = int(time) | |||
return await ctx.send("Slowmode set to :snail: ({} seconds)".format(time)) | |||
elif seconds.isdigit and self.slow_mode: # Change value of Slow Mode timer | |||
self.slow_mode_channels[ctx.channel.id] = int(seconds) | |||
return await ctx.send("Slowmode set to :snail: ({} seconds)".format(seconds)) | |||
else: | |||
pass | |||
@@ -95,7 +95,7 @@ class Admin(): | |||
messages = await ctx.channel.purge(limit=limit, check=predicate) | |||
return await ctx.send("{} message(s) purged from chat.".format(len(messages))) | |||
@checks.is_admin_or_mod() | |||
@roxbot.checks.is_admin_or_mod() | |||
@commands.group(case_insensitive=True) | |||
async def warn(self, ctx): | |||
"""Group of commands handling warnings""" | |||
@@ -103,7 +103,7 @@ class Admin(): | |||
return await ctx.send('Missing Argument') | |||
@warn.command() | |||
async def add(self, ctx, user: discord.User = None, *, warning = ""): | |||
async def add(self, ctx, user: discord.User=None, *, warning=""): | |||
"""Adds a warning to a user.""" | |||
# Warning in the settings is a dictionary of user ids. The user ids are equal to a list of dictionaries. | |||
settings = gs.get(ctx.guild) | |||
@@ -115,7 +115,7 @@ class Admin(): | |||
} | |||
user_id = str(user.id) | |||
if not user_id in settings.warnings: | |||
if user_id not in settings.warnings: | |||
settings.warnings[user_id] = [] | |||
settings.warnings[user_id].append(warning_dict) | |||
@@ -133,7 +133,7 @@ class Admin(): | |||
"""Lists all or just the warnings for one user.""" | |||
settings = gs.get(ctx.guild) | |||
if user == None: | |||
if user is None: | |||
output = "" | |||
for member in settings.warnings: | |||
# Remove users with no warning here instead of remove cause im lazy | |||
@@ -154,7 +154,7 @@ class Admin(): | |||
if not settings.warnings[user_id]: | |||
settings.warnings.pop(user_id) | |||
settings.update(settings.warnings, "warnings") | |||
if not user_id in settings.warnings: | |||
if user_id not in settings.warnings: | |||
return await ctx.send("This user doesn't have any warning on record.") | |||
em = discord.Embed(title="Warnings for {}".format(str(user)), colour=0XDEADBF) | |||
@@ -168,12 +168,12 @@ class Admin(): | |||
warned_by = warning["warned-by"] | |||
date = datetime.datetime.fromtimestamp(warning["date"]).strftime('%c') | |||
warn_reason = warning["warning"] | |||
em.add_field(name="Warning %s"%x, value="Warned by: {}\nTime: {}\nReason: {}".format(warned_by, date, warn_reason)) | |||
em.add_field(name="Warning %s" % x, value="Warned by: {}\nTime: {}\nReason: {}".format(warned_by, date, warn_reason)) | |||
x += 1 | |||
return await ctx.send(embed=em) | |||
@warn.command() | |||
async def remove(self, ctx, user: discord.User = None, index = None): | |||
async def remove(self, ctx, user: discord.User=None, index=None): | |||
"""Removes one or all of the warnings for a user.""" | |||
user_id = str(user.id) | |||
settings = gs.get(ctx.guild) | |||
@@ -209,7 +209,7 @@ class Admin(): | |||
@commands.has_permissions(kick_members=True) | |||
@commands.bot_has_permissions(kick_members=True) | |||
@bot.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.""" | |||
try: | |||
await member.kick(reason=reason) | |||
@@ -220,7 +220,7 @@ class Admin(): | |||
@commands.has_permissions(ban_members=True) | |||
@commands.bot_has_permissions(ban_members=True) | |||
@bot.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.""" | |||
try: | |||
await member.ban(reason=reason, delete_message_days=0) | |||
@@ -231,7 +231,7 @@ class Admin(): | |||
@commands.has_permissions(ban_members=True) | |||
@commands.bot_has_permissions(ban_members=True) | |||
@bot.command() | |||
async def unban(self, ctx, member_id:int, *, reason = ""): | |||
async def unban(self, ctx, member_id: int, *, reason=""): | |||
"""Unbans user with given ID. Allows you to give a reason.""" | |||
mem = None | |||
for ban in await ctx.guild.bans(): | |||
@@ -245,5 +245,6 @@ class Admin(): | |||
except discord.Forbidden: | |||
return await ctx.send("I can't kick the owner or users higher or equal to me.") | |||
def setup(bot_client): | |||
bot_client.add_cog(Admin(bot_client)) |
@@ -1,15 +1,7 @@ | |||
import discord | |||
from Roxbot import checks, load_config | |||
from discord.ext.commands import group | |||
from Roxbot.settings import guild_settings | |||
def blacklisted(user): | |||
with open("Roxbot/blacklist.txt", "r") as fp: | |||
for line in fp.readlines(): | |||
if str(user.id)+"\n" == line: | |||
return True | |||
return False | |||
import Roxbot as roxbot | |||
class CustomCommands(): | |||
@@ -19,11 +11,11 @@ class CustomCommands(): | |||
async def on_message(self, message): | |||
if isinstance(message.channel, discord.DMChannel): | |||
return | |||
settings = guild_settings.get(message.guild) | |||
settings = roxbot.guild_settings.get(message.guild) | |||
msg = message.content.lower() | |||
channel = message.channel | |||
if blacklisted(message.author) or type(message.channel) != discord.TextChannel: | |||
if roxbot.blacklisted(message.author) or type(message.channel) != discord.TextChannel: | |||
return | |||
if message.author == self.bot.user: | |||
return | |||
@@ -37,16 +29,16 @@ class CustomCommands(): | |||
return await channel.send(settings.custom_commands["0"][command]) | |||
@group(pass_context=True, aliases=["cc"]) | |||
@checks.is_owner_or_admin() | |||
@roxbot.checks.is_owner_or_admin() | |||
async def custom(self, ctx): | |||
"A group of commands to manage custom commands for your server." | |||
""""A group of commands to manage custom commands for your server.""" | |||
if ctx.invoked_subcommand is None: | |||
return await ctx.send('Missing Argument') | |||
@custom.command(pass_context=True) | |||
async def add(self, ctx, command, output, prefix_required = "0"): | |||
"Adds a custom command to the list of custom commands." | |||
settings = guild_settings.get(ctx.guild) | |||
async def add(self, ctx, command, output, prefix_required="0"): | |||
"""Adds a custom command to the list of custom commands.""" | |||
settings = roxbot.guild_settings.get(ctx.guild) | |||
command = command.lower() | |||
output = output | |||
zero = settings.custom_commands["0"] | |||
@@ -71,8 +63,8 @@ class CustomCommands(): | |||
@custom.command(pass_context=True) | |||
async def edit(self, ctx, command, edit): | |||
"Edits an existing custom command." | |||
settings = guild_settings.get(ctx.guild) | |||
""""Edits an existing custom command.""" | |||
settings = roxbot.guild_settings.get(ctx.guild) | |||
zero = settings.custom_commands["0"] | |||
one = settings.custom_commands["1"] | |||
@@ -92,8 +84,8 @@ class CustomCommands(): | |||
@custom.command(pass_context=True) | |||
async def remove(self, ctx, command): | |||
"Removes a custom command." | |||
settings = guild_settings.get(ctx.guild) | |||
""""Removes a custom command.""" | |||
settings = roxbot.guild_settings.get(ctx.guild) | |||
command = command.lower() | |||
if command in settings.custom_commands["1"]: | |||
settings.custom_commands["1"].pop(command) | |||
@@ -106,24 +98,23 @@ class CustomCommands(): | |||
else: | |||
return await ctx.send("Custom Command doesn't exist.") | |||
@custom.command(pass_context=True) | |||
async def list(self, ctx, debug="0"): | |||
"Lists all custom commands for this server." | |||
""""Lists all custom commands for this server.""" | |||
if debug != "0" and debug != "1": | |||
debug = "0" | |||
settings = guild_settings.get(ctx.guild) | |||
l = settings.custom_commands | |||
settings = roxbot.guild_settings.get(ctx.guild) | |||
cc = settings.custom_commands | |||
listzero = "" | |||
listone = "" | |||
for command in l["0"]: | |||
for command in cc["0"]: | |||
if debug == "1": | |||
command += " - {}".format(l["0"][command]) | |||
command += " - {}".format(cc["0"][command]) | |||
listzero = listzero + "- " + command + "\n" | |||
for command in l["1"]: | |||
for command in cc["1"]: | |||
if debug == "1": | |||
command += " - {}".format(l["1"][command]) | |||
command += " - {}".format(cc["1"][command]) | |||
listone = listone + "- " + command + "\n" | |||
if not listone: | |||
listone = "There are no commands setup.\n" | |||
@@ -132,10 +123,11 @@ class CustomCommands(): | |||
# TODO: Sort out a way to shorten this if it goes over 2000 characters. | |||
em = discord.Embed(title="Here is the list of Custom Commands", color=load_config.embedcolour) | |||
em = discord.Embed(title="Here is the list of Custom Commands", color=roxbot.embedcolour) | |||
em.add_field(name="Commands that require Prefix:", value=listone, inline=False) | |||
em.add_field(name="Commands that don't:", value=listzero, inline=False) | |||
return await ctx.send(embed=em) | |||
def setup(bot_client): | |||
bot_client.add_cog(CustomCommands(bot_client)) | |||
bot_client.add_cog(CustomCommands(bot_client)) |
@@ -4,17 +4,15 @@ import discord | |||
import requests | |||
from discord.ext.commands import bot | |||
from Roxbot import checks | |||
from Roxbot.settings import guild_settings | |||
from Roxbot.logging import log | |||
import Roxbot | |||
class Fun: | |||
def __init__(self, bot_client): | |||
self.bot = bot_client | |||
@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 | |||
async def roll(self, ctx, expression = ""): | |||
@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 | |||
async def roll(self, ctx, expression=""): | |||
""" | |||
Rolls a die using dice expression format. | |||
Usage: | |||
@@ -145,7 +143,7 @@ class Fun: | |||
if i < (times-1): response += '\n' | |||
return await ctx.send(response) | |||
@checks.isnt_anal() | |||
@Roxbot.checks.isnt_anal() | |||
@bot.command() | |||
async def spank(self, ctx, *, user: discord.User = None): | |||
""" | |||
@@ -158,7 +156,7 @@ class Fun: | |||
return await ctx.send("You didn't mention someone for me to spank") | |||
return await ctx.send(":peach: :wave: *{} spanks {}*".format(self.bot.user.name, user.name)) | |||
@checks.isnt_anal() | |||
@Roxbot.checks.isnt_anal() | |||
@bot.command(aliases=["succ"]) | |||
async def suck(self, ctx, *, user: discord.User = None): | |||
""" | |||
@@ -246,9 +244,9 @@ class Fun: | |||
converted = str(convert).translate(WIDE_MAP) | |||
await ctx.send(converted) | |||
logging = guild_settings.get(ctx.guild).logging | |||
logging = Roxbot.guild_settings.get(ctx.guild).logging | |||
log_channel = self.bot.get_channel(logging["channel"]) | |||
await log(ctx.guild, log_channel, "aesthetics", User=ctx.author, Argument_Given=convert, Channel=ctx.channel, Channel_Mention=ctx.channel.mention) | |||
await Roxbot.log(ctx.guild, log_channel, "aesthetics", User=ctx.author, Argument_Given=convert, Channel=ctx.channel, Channel_Mention=ctx.channel.mention) | |||
@bot.command(aliases=["ft", "frog"]) | |||
async def frogtips(self, ctx): |
@@ -1,5 +1,5 @@ | |||
import discord | |||
from Roxbot.settings import guild_settings | |||
from Roxbot import guild_settings | |||
class JoinLeave(): | |||
@@ -42,4 +42,4 @@ class JoinLeave(): | |||
def setup(Bot): | |||
Bot.add_cog(JoinLeave(Bot)) | |||
Bot.add_cog(JoinLeave(Bot)) |
@@ -1,8 +1,9 @@ | |||
import random | |||
from Roxbot import checks | |||
import requests | |||
from discord.ext.commands import bot | |||
from Roxbot.settings import guild_settings as gs | |||
from Roxbot import checks | |||
from Roxbot import guild_settings as gs | |||
class NFSW(): | |||
def __init__(self, bot_client): | |||
@@ -15,12 +16,11 @@ class NFSW(): | |||
return blacklist | |||
def gelbooru_clone(self, ctx, base_url, tags): | |||
# Maybe a page randomiser | |||
limit = 200 | |||
tags = tags + self.tag_blacklist(ctx) | |||
url = base_url + '/index.php?page=dapi&s=post&q=index&json=1&tags=' + tags + '&limit=' + str(limit) | |||
req = requests.get(url, headers={'User-agent': 'RoxBot Discord Bot'}) | |||
if str(req.content) == "b''": # This is to catch any errors if the tags don't return anything because I can't do my own error handling in commands. | |||
if str(req.content) == "b''": # This is to catch any errors if the tags don't return anything because I can't do my own error handling in commands. | |||
post = None | |||
return post | |||
post = random.choice(req.json()) | |||
@@ -37,7 +37,7 @@ class NFSW(): | |||
limit = 150 | |||
url = base_url + 'post/index.json?tags=' + tags + '&limit=' + str(limit) | |||
req = requests.get(url, headers = {'User-agent': 'RoxBot Discord Bot'}) | |||
if str(req.content) == "b'[]'": # This is to catch any errors if the tags don't return anything because I can't do my own error handling in commands. | |||
if str(req.content) == "b'[]'": # This is to catch any errors if the tags don't return anything because I can't do my own error handling in commands. | |||
return await ctx.send("Nothing was found. *psst, check the tags you gave me.*") | |||
post = random.choice(req.json()) | |||
return await ctx.send(post["file_url"]) |
@@ -6,15 +6,8 @@ from lxml import html | |||
from bs4 import BeautifulSoup | |||
from discord.ext.commands import bot | |||
from Roxbot import checks | |||
from Roxbot.logging import log | |||
from Roxbot.settings import guild_settings | |||
# Warning, this cog sucks so much but hopefully it works and doesn't break the bot too much. | |||
# Just lazily edited old code and bodged it into this one. | |||
# There is redundant code here that if removed would make it easier. | |||
# Edit, cleaned up a lot more. But it still is a bit dodgy, when discord allows for the video object to be used in embeds, then we need to convert the cog to output embeds. | |||
import Roxbot as roxbot | |||
from Roxbot import guild_settings | |||
def _imgur_removed(url): | |||
@@ -92,12 +85,13 @@ def parse_url(url): | |||
else: | |||
return False | |||
class Reddit(): | |||
def __init__(self, bot_client): | |||
self.bot = bot_client | |||
self.post_cache = {} | |||
for guild in self.bot.guilds: | |||
self.post_cache[guild.id] = [("","")] | |||
self.post_cache[guild.id] = [("", "")] | |||
@bot.command() | |||
async def subreddit(self, ctx, subreddit): | |||
@@ -135,10 +129,8 @@ class Reddit(): | |||
title = "**{}** \nby /u/{} from /r/{}\n".format(unescape(choice["title"]), unescape(choice["author"]),subreddit) | |||
break | |||
# Check if post is NSFW, and if it is and this channel doesn't past the NSFW check, then return with the error message. | |||
if choice["over_18"] and not checks.nsfw_predicate(ctx): | |||
if choice["over_18"] and not roxbot.checks.nsfw_predicate(ctx): | |||
return await ctx.send("This server/channel doesn't have my NSFW stuff enabled. This extends to posting NFSW content from Reddit.") | |||
if not url: # If no image posts could be found with the for loop. | |||
return await ctx.send("I couldn't find any images from that subreddit.") | |||
@@ -159,7 +151,7 @@ class Reddit(): | |||
# Only log the command when it is this command being used. Not the inbuilt commands. | |||
logging = guild_settings.get(ctx.guild).logging | |||
log_channel = self.bot.get_channel(logging["channel"]) | |||
await log(ctx.guild, log_channel, "subreddit", User=ctx.author, Subreddit=subreddit, Returned="<{}>".format(url), Channel=ctx.channel, Channel_Mention=ctx.channel.mention) | |||
await roxbot.log(ctx.guild, log_channel, "subreddit", User=ctx.author, Subreddit=subreddit, Returned="<{}>".format(url), Channel=ctx.channel, Channel_Mention=ctx.channel.mention) | |||
# Not using a embed here because we can't use video in rich embeds but they work in embeds now :/ | |||
return await ctx.send(title + text + url) |
@@ -1,14 +1,14 @@ | |||
import discord | |||
from discord.ext import commands | |||
from Roxbot import load_config | |||
from Roxbot.settings import guild_settings as gs | |||
import Roxbot | |||
from Roxbot import guild_settings as gs | |||
class SelfAssign(): | |||
def __init__(self, Bot): | |||
self.bot = Bot | |||
self.embed_colour = load_config.embedcolour | |||
self.embed_colour = Roxbot.embedcolour | |||
@commands.command(pass_context=True) | |||
async def listroles(self, ctx): | |||
@@ -19,8 +19,7 @@ class SelfAssign(): | |||
""" | |||
settings = gs.get(ctx.guild) | |||
if not settings.self_assign["enabled"]: | |||
embed = discord.Embed(colour=discord.Colour(self.embed_colour), | |||
description="SelfAssignable roles are not enabled on this server") | |||
embed = discord.Embed(colour=discord.Colour(self.embed_colour), description="SelfAssignable roles are not enabled on this server") | |||
return await ctx.send(embed=embed) | |||
roles = [] | |||
for role in settings.self_assign["roles"]: | |||
@@ -28,8 +27,7 @@ class SelfAssign(): | |||
if role == serverrole.id: | |||
roles.append("**"+serverrole.name+"**") | |||
roles = '\n'.join(roles) | |||
embed = discord.Embed(colour=self.embed_colour, | |||
description="The self-assignable roles for this server are: \n"+roles) | |||
embed = discord.Embed(colour=self.embed_colour, description="The self-assignable roles for this server are: \n"+roles) | |||
return await ctx.send(embed=embed) | |||
@commands.command(pass_context=True) | |||
@@ -49,8 +47,7 @@ class SelfAssign(): | |||
raise commands.MissingRequiredArgument(Parameter("Role", False)) | |||
if not settings.self_assign["enabled"]: | |||
embed = discord.Embed(colour=discord.Colour(self.embed_colour), | |||
description="SelfAssignable roles are not enabled on this server") | |||
embed = discord.Embed(colour=discord.Colour(self.embed_colour), description="SelfAssignable roles are not enabled on this server") | |||
return await ctx.send(embed=embed) | |||
member = ctx.author | |||
@@ -80,8 +77,7 @@ class SelfAssign(): | |||
raise commands.MissingRequiredArgument(Parameter("role", False)) | |||
if not settings.self_assign["enabled"]: | |||
embed = discord.Embed(colour=discord.Colour(self.embed_colour), | |||
description="SelfAssignable roles are not enabled on this server") | |||
embed = discord.Embed(colour=discord.Colour(self.embed_colour), description="SelfAssignable roles are not enabled on this server") | |||
return await ctx.send(embed=embed) | |||
member = ctx.author |
@@ -1,6 +1,5 @@ | |||
# -*- coding: utf-8 -*- | |||
from Roxbot import checks | |||
import discord | |||
import asyncio | |||
import requests | |||
@@ -10,6 +9,8 @@ from random import shuffle | |||
from collections import OrderedDict | |||
from discord.ext import commands | |||
from Roxbot import checks | |||
class Trivia: | |||
""" |
@@ -1,15 +1,8 @@ | |||
from discord import ActivityType | |||
from discord.ext import commands | |||
from Roxbot import checks | |||
from Roxbot.settings import guild_settings | |||
import Roxbot | |||
def blacklisted(user): | |||
with open("Roxbot/blacklist.txt", "r") as fp: | |||
for line in fp.readlines(): | |||
if str(user.id)+"\n" == line: | |||
return True | |||
return False | |||
class Twitch(): | |||
""" | |||
@@ -20,8 +13,8 @@ class Twitch(): | |||
async def on_member_update(self, member_b, member_a): | |||
"""Twitch Shilling Part""" | |||
twitch = guild_settings.get(member_b.guild).twitch | |||
if blacklisted(member_b) or not twitch["enabled"]: | |||
twitch = Roxbot.guild_settings.get(member_b.guild).twitch | |||
if Roxbot.blacklisted(member_b) or not twitch["enabled"]: | |||
return | |||
if member_a.activitiy: | |||
@@ -29,10 +22,10 @@ class Twitch(): | |||
if not twitch["whitelist"]["enabled"] or member_a.id in twitch["whitelist"]["list"]: | |||
channel = self.bot.get_channel(twitch["channel"]) | |||
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.group() | |||
@checks.is_admin_or_mod() | |||
@Roxbot.checks.is_admin_or_mod() | |||
async def whitelist(self, ctx): | |||
"""Command group that handles the twitch cog's whitelist.""" | |||
if ctx.invoked_subcommand is None: | |||
@@ -43,7 +36,7 @@ class Twitch(): | |||
"""Enables the twitch shilling whitelist. Repeat the command to disable. | |||
Usage: | |||
;whitelist enable""" | |||
settings = guild_settings.get(ctx.guild) | |||
settings = Roxbot.guild_settings.get(ctx.guild) | |||
if not settings.twitch["whitelist"]["enabled"]: | |||
settings.twitch["whitelist"]["enabled"] = 1 | |||
settings.update(settings.twitch, "twitch") | |||
@@ -54,10 +47,13 @@ class Twitch(): | |||
return await ctx.send("Whitelist for Twitch shilling has been disabled.") | |||
@whitelist.command() | |||
async def edit(self, ctx, option, mentions = None): | |||
async def edit(self, ctx, option, mentions=None): | |||
"""Adds or removes users to the whitelist. Exactly the same as the blacklist command in usage.""" | |||
# TODO: This is all horribly outdated useage and needs to be rewritten. | |||
whitelist_count = 0 | |||
settings = guild_settings.get(ctx.guild) | |||
settings = Roxbot.guild_settings.get(ctx.guild) | |||
if not ctx.message.mentions and option != 'list': | |||
return await ctx.send("You haven't mentioned anyone to whitelist.") |
@@ -6,9 +6,8 @@ import youtube_dl | |||
from math import ceil | |||
from discord.ext import commands | |||
from Roxbot import checks | |||
from Roxbot.load_config import owner | |||
from Roxbot.settings import guild_settings | |||
import Roxbot | |||
from Roxbot import guild_settings | |||
def _clear_cache(): | |||
@@ -22,7 +21,7 @@ def volume_perms(): | |||
def predicate(ctx): | |||
gs = guild_settings.get(ctx.guild) | |||
if gs.voice["need_perms"]: # Had to copy the admin or mod code cause it wouldn't work ;-; | |||
if ctx.message.author.id == owner: | |||
if ctx.message.author.id == Roxbot.owner: | |||
return True | |||
else: | |||
admin_roles = gs.perm_roles["admin"] | |||
@@ -179,7 +178,7 @@ class Voice: | |||
self.now_playing[guild.id] = None | |||
self.queue_logic[guild.id] = None | |||
@checks.is_admin_or_mod() | |||
@Roxbot.checks.is_admin_or_mod() | |||
@commands.command() | |||
async def join(self, ctx, *, channel: discord.VoiceChannel = None): | |||
"""Joins the voice channel your in.""" | |||
@@ -214,7 +213,7 @@ class Voice: | |||
guild = ctx.guild | |||
# Checks if invoker is in voice with the bot. Skips admins and mods and owner. | |||
if not checks._is_admin_or_mod(ctx) or from_queue: | |||
if not Roxbot.checks._is_admin_or_mod(ctx) or from_queue: | |||
if not ctx.author.voice: | |||
raise commands.CommandError("You're not in the same voice channel as Roxbot.") | |||
if ctx.author.voice.channel != ctx.voice_client.channel: | |||
@@ -238,7 +237,7 @@ class Voice: | |||
video = video["entries"][0] | |||
# Duration limiter handling | |||
if video.get("duration", 1) > voice["max_length"] and not checks._is_admin_or_mod(ctx): | |||
if video.get("duration", 1) > voice["max_length"] and not Roxbot.checks._is_admin_or_mod(ctx): | |||
raise commands.CommandError("Cannot play video, duration is bigger than the max duration allowed.") | |||
# Actual playing stuff section. | |||
@@ -350,7 +349,7 @@ class Voice: | |||
"""Skips or votes to skip the current video. Use option "--force" if your an admin and """ | |||
voice = guild_settings.get(ctx.guild).voice | |||
if ctx.voice_client.is_playing(): | |||
if voice["skip_voting"] and not (option == "--force" and checks._is_admin_or_mod(ctx)): # Admin force skipping | |||
if voice["skip_voting"] and not (option == "--force" and Roxbot.checks._is_admin_or_mod(ctx)): # Admin force skipping | |||
if ctx.author in self.skip_votes[ctx.guild.id]: | |||
return await ctx.send("You have already voted to skip the current track.") | |||
else: | |||
@@ -401,7 +400,7 @@ class Voice: | |||
embed = discord.Embed(title="Queue", description=output, colour=0xDEADBF) | |||
return await ctx.send(embed=embed) | |||
@checks.is_admin_or_mod() | |||
@Roxbot.checks.is_admin_or_mod() | |||
@commands.command() | |||
async def remove(self, ctx, index): | |||
"""Removes a item from the queue with the given index. Can also input all to delete all queued items.""" | |||
@@ -427,7 +426,7 @@ class Voice: | |||
except IndexError: | |||
raise commands.CommandError("Valid Index not given.") | |||
@checks.is_admin_or_mod() | |||
@Roxbot.checks.is_admin_or_mod() | |||
@commands.command(alaises=["disconnect"]) | |||
async def stop(self, ctx): | |||
"""Stops and disconnects the bot from voice.""" |
@@ -7,16 +7,6 @@ command_prefix = settings["Roxbot"]["Command_Prefix"] | |||
token = settings["Roxbot"]["Token"] | |||
owner = int(settings["Roxbot"]["OwnerID"]) | |||
tat_token = settings["Roxbot"]["Tatsumaki_Token"] | |||
__description__ = """RoxBot, A Discord Bot made by a filthy Mercy Main. Built with love (and discord.py) by Roxxers#7443. | |||
[Github link](https://github.com/RainbowDinoaur/roxbot) | |||
[Changelog](https://github.com/RainbowDinoaur/roxbot#v100) | |||
[Found a bug or need to report an issue? Report it here](https://github.com/RainbowRoxxers/roxbot/issues/new) | |||
[Say Thanks](https://saythanks.io/to/Roxxers)""" | |||
__author__ = "Roxanne Gibson" | |||
__version__ = "1.6.1" | |||
embedcolour = 0xDEADBF | |||
# IF YOU ARE TESTING OR NOT IN THE GSS DISCORD, REMOVE "cogs.gss" FROM THE LIST |
@@ -1,12 +1,11 @@ | |||
import discord | |||
from Roxbot.settings import guild_settings | |||
from Roxbot.load_config import embedcolour | |||
import Roxbot | |||
async def log(guild, channel, command_name, **kwargs): | |||
logging = guild_settings.get(guild).logging | |||
logging = Roxbot.guild_settings.get(guild).logging | |||
if logging["enabled"]: | |||
embed = discord.Embed(title="{} command logging".format(command_name), colour=embedcolour) | |||
embed = discord.Embed(title="{} command logging".format(command_name), colour=Roxbot.embedcolour) | |||
for key, value in kwargs.items(): | |||
embed.add_field(name=key, value=value) | |||
return await channel.send(embed=embed) | |||
@@ -17,10 +16,10 @@ class Logging: | |||
self.bot = bot_client | |||
async def on_member_join(self, member): | |||
logging = guild_settings.get(member.guild).logging | |||
logging = Roxbot.guild_settings.get(member.guild).logging | |||
if logging["enabled"]: | |||
channel = self.bot.get_channel(logging["channel"]) | |||
embed = discord.Embed(title="{} joined the server".format(member), colour=embedcolour) | |||
embed = discord.Embed(title="{} joined the server".format(member), colour=Roxbot.embedcolour) | |||
embed.add_field(name="ID", value=member.id) | |||
embed.add_field(name="Mention", value=member.mention) | |||
embed.add_field(name="Date Account Created", value="{:%a %Y/%m/%d %H:%M:%S} UTC".format(member.created_at)) | |||
@@ -30,10 +29,10 @@ class Logging: | |||
async def on_member_remove(self, member): | |||
# TODO: Add some way of detecting whether a user left/was kicked or was banned. | |||
logging = guild_settings.get(member.guild).logging | |||
logging = Roxbot.guild_settings.get(member.guild).logging | |||
if logging["enabled"]: | |||
channel = self.bot.get_channel(logging["channel"]) | |||
embed = discord.Embed(description="{} left the server".format(member), colour=embedcolour) | |||
embed = discord.Embed(description="{} left the server".format(member), colour=Roxbot.embedcolour) | |||
return await channel.send(embed=embed) | |||
@@ -6,9 +6,9 @@ import os.path | |||
import datetime | |||
import discord | |||
from discord.ext import commands | |||
from Roxbot import load_config | |||
from Roxbot.settings import guild_settings as gs | |||
import Roxbot | |||
from Roxbot import guild_settings as gs | |||
# Sets up Logging that discord.py does on its own | |||
logger = logging.getLogger('discord') | |||
@@ -18,19 +18,13 @@ handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(me | |||
logger.addHandler(handler) | |||
bot = commands.Bot( | |||
command_prefix=load_config.command_prefix, | |||
description=load_config.__description__, | |||
owner_id=load_config.owner, | |||
activity=discord.Game(name="v{}".format(load_config.__version__), type=0), | |||
command_prefix=Roxbot.command_prefix, | |||
description=Roxbot.__description__, | |||
owner_id=Roxbot.owner, | |||
activity=discord.Game(name="v{}".format(Roxbot.__version__), type=0), | |||
case_insensitive=True | |||
) | |||
def blacklisted(user): | |||
with open("Roxbot/blacklist.txt", "r") as fp: | |||
for line in fp.readlines(): | |||
if str(user.id)+"\n" == line: | |||
return True | |||
return False | |||
@bot.event | |||
async def on_ready(): | |||
@@ -45,7 +39,7 @@ async def on_ready(): | |||
# Load Extension Cogs | |||
print("Cogs Loaded:") | |||
for cog in load_config.cogs: | |||
for cog in Roxbot.cogs: | |||
bot.load_extension(cog) | |||
print(cog.split(".")[2]) | |||
print("") | |||
@@ -58,14 +52,17 @@ async def on_ready(): | |||
# In the next two functions, I was gunna user bot.settings for something but I don't think it's possible. | |||
# So while I don't use it, the function still will do their jobs of adding and removing the settings. | |||
@bot.event | |||
async def on_guild_join(guild): | |||
gs.add_guild(guild) | |||
@bot.event | |||
async def on_guild_remove(guild): | |||
gs.remove_guild(guild) | |||
@bot.event | |||
async def on_message(message): | |||
""" | |||
@@ -73,23 +70,24 @@ async def on_message(message): | |||
:param message: | |||
:return: | |||
""" | |||
if blacklisted(message.author): | |||
if Roxbot.blacklisted(message.author): | |||
return | |||
return await bot.process_commands(message) | |||
@bot.command() | |||
async def about(ctx): | |||
""" | |||
Outputs info about RoxBot, showing uptime, how to report issues, what settings where set in prefs.ini and credits. | |||
""" | |||
owner = bot.get_user(load_config.owner) | |||
em = discord.Embed(title="About Roxbot", colour=load_config.embedcolour, description=load_config.__description__) | |||
owner = bot.get_user(Roxbot.owner) | |||
em = discord.Embed(title="About Roxbot", colour=Roxbot.embedcolour, description=Roxbot.__description__) | |||
em.set_thumbnail(url=bot.user.avatar_url) | |||
em.add_field(name="Command Prefix", value=load_config.command_prefix) | |||
em.add_field(name="Command Prefix", value=Roxbot.command_prefix) | |||
em.add_field(name="Owner", value=str(owner)) | |||
em.add_field(name="Owner ID", value=load_config.owner) | |||
em.add_field(name="Bot Version", value=load_config.__version__) | |||
em.add_field(name="Author", value=load_config.__author__) | |||
em.add_field(name="Owner ID", value=Roxbot.owner) | |||
em.add_field(name="Bot Version", value=Roxbot.__version__) | |||
em.add_field(name="Author", value=Roxbot.__author__) | |||
em.add_field(name="Discord.py version", value=discord.__version__) | |||
em.set_footer(text="RoxBot is licensed under the MIT License") | |||
@@ -102,7 +100,7 @@ async def about(ctx): | |||
if __name__ == "__main__": | |||
# Pre-Boot checks | |||
if not os.path.isfile("Roxbot/preferences.ini"): | |||
if not os.path.isfile("Roxbot/settings/preferences.ini"): | |||
print( | |||
"PREFERENCE FILE MISSING. Something has gone wrong. Please make sure there is a file called 'preferences.ini' in the settings folder") | |||
exit(0) | |||
@@ -112,4 +110,4 @@ if __name__ == "__main__": | |||
fp.write("{}") | |||
start_time = time.time() | |||
bot.run(load_config.token) | |||
bot.run(Roxbot.token) |