Browse Source

renamed Roxbot to roxbot for ease of use.

tags/v1.7.0
Roxie Gibson 6 years ago
parent
commit
5fe2c02c18
26 changed files with 167 additions and 167 deletions
  1. +0
    -40
      Roxbot/load_config.py
  2. +21
    -21
      main.py
  3. +4
    -4
      roxbot/__init__.py
  4. +0
    -0
      roxbot/cache/.gitignore
  5. +2
    -2
      roxbot/checks.py
  6. +3
    -3
      roxbot/cogs/admin.py
  7. +9
    -9
      roxbot/cogs/customcommands.py
  8. +14
    -14
      roxbot/cogs/fun.py
  9. +3
    -3
      roxbot/cogs/gss.py
  10. +4
    -4
      roxbot/cogs/joinleave.py
  11. +2
    -2
      roxbot/cogs/nsfw.py
  12. +2
    -2
      roxbot/cogs/reddit.py
  13. +6
    -6
      roxbot/cogs/selfassign.py
  14. +9
    -9
      roxbot/cogs/trivia.py
  15. +6
    -6
      roxbot/cogs/twitch.py
  16. +4
    -4
      roxbot/cogs/util.py
  17. +23
    -23
      roxbot/cogs/voice.py
  18. +6
    -6
      roxbot/err_handle.py
  19. +3
    -3
      roxbot/guild_settings.py
  20. +0
    -0
      roxbot/http.py
  21. +40
    -0
      roxbot/load_config.py
  22. +1
    -1
      roxbot/logging.py
  23. +0
    -0
      roxbot/settings/backups/.gitignore
  24. +0
    -0
      roxbot/settings/blacklist.txt
  25. +0
    -0
      roxbot/settings/preferences_example.ini
  26. +5
    -5
      roxbot/settings/settings.py

+ 0
- 40
Roxbot/load_config.py View File

@@ -1,40 +0,0 @@
from enum import Enum
import configparser


settings = configparser.ConfigParser()
settings.read("Roxbot/settings/preferences.ini")

command_prefix = settings["Roxbot"]["Command_Prefix"]
token = settings["Roxbot"]["Token"]
owner = int(settings["Roxbot"]["OwnerID"])
tat_token = settings["Roxbot"]["Tatsumaki_Token"]


class EmbedColours(Enum):
pink = 0xDEADBF
yellow = 0xFDDF86
blue = 0x6F90F5
frog_green = 0x4C943D # Used for FROGTIPS
red = 0xe74c3c # Used for on_error
dark_red = 0x992d22 # Used for on_command_error
triv_green = 0x1fb600 # Used for the correct answer in trivia
gold = 0xd4af3a # Used for displaying the winner in trivia


# REMEMBER TO UNCOMMENT THE GSS LINE, ROXIE

cogs = [
"Roxbot.cogs.admin",
"Roxbot.cogs.customcommands",
"Roxbot.cogs.fun",
"Roxbot.cogs.joinleave",
"Roxbot.cogs.nsfw",
"Roxbot.cogs.reddit",
"Roxbot.cogs.selfassign",
"Roxbot.cogs.trivia",
"Roxbot.cogs.twitch",
"Roxbot.cogs.util",
"Roxbot.cogs.voice",
#"Roxbot.cogs.gss"
]

+ 21
- 21
main.py View File

@@ -7,8 +7,8 @@ import datetime
import discord
from discord.ext import commands

import Roxbot
from Roxbot 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,10 +18,10 @@ handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(me
logger.addHandler(handler)

bot = commands.Bot(
command_prefix=Roxbot.command_prefix,
description=Roxbot.__description__,
owner_id=Roxbot.owner,
activity=discord.Game(name="v{}".format(Roxbot.__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
)

@@ -29,9 +29,9 @@ bot = commands.Bot(
@bot.event
async def on_ready():
# Load Roxbots inbuilt cogs and settings
bot.load_extension("Roxbot.settings.settings")
bot.load_extension("Roxbot.err_handle")
bot.load_extension("Roxbot.logging")
bot.load_extension("roxbot.settings.settings")
bot.load_extension("roxbot.err_handle")
bot.load_extension("roxbot.logging")
bot.settings = gs.get_all(bot.guilds)

print("Discord.py version: " + discord.__version__)
@@ -39,7 +39,7 @@ async def on_ready():

# Load Extension Cogs
print("Cogs Loaded:")
for cog in Roxbot.cogs:
for cog in roxbot.cogs:
bot.load_extension(cog)
print(cog.split(".")[2])
print("")
@@ -70,7 +70,7 @@ async def on_message(message):
:param message:
:return:
"""
if Roxbot.blacklisted(message.author):
if roxbot.blacklisted(message.author):
return
return await bot.process_commands(message)

@@ -80,14 +80,14 @@ 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(Roxbot.owner)
em = discord.Embed(title="About Roxbot", colour=Roxbot.EmbedColours.pink, description=Roxbot.__description__)
owner = bot.get_user(roxbot.owner)
em = discord.Embed(title="About roxbot", colour=roxbot.EmbedColours.pink, description=roxbot.__description__)
em.set_thumbnail(url=bot.user.avatar_url)
em.add_field(name="Command Prefix", value=Roxbot.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=Roxbot.owner)
em.add_field(name="Bot Version", value=Roxbot.__version__)
em.add_field(name="Author", value=Roxbot.__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")

@@ -100,14 +100,14 @@ async def about(ctx):

if __name__ == "__main__":
# Pre-Boot checks
if not os.path.isfile("Roxbot/settings/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)

if not os.path.isfile("Roxbot/settings/servers.json"):
with open("Roxbot/settings/servers.json", "w") as fp:
if not os.path.isfile("roxbot/settings/servers.json"):
with open("roxbot/settings/servers.json", "w") as fp:
fp.write("{}")

start_time = time.time()
bot.run(Roxbot.token)
bot.run(roxbot.token)

Roxbot/__init__.py → roxbot/__init__.py View File

@@ -1,10 +1,10 @@
from Roxbot import checks, http, guild_settings
from Roxbot.load_config import *
from Roxbot.logging import log
from roxbot import checks, http, guild_settings
from roxbot.load_config import *
from roxbot.logging import log


def blacklisted(user):
with open("Roxbot/settings/blacklist.txt", "r") as fp:
with open("roxbot/settings/blacklist.txt", "r") as fp:
for line in fp.readlines():
if str(user.id)+"\n" == line:
return True

Roxbot/cache/.gitignore → roxbot/cache/.gitignore View File


Roxbot/checks.py → roxbot/checks.py View File

@@ -1,6 +1,6 @@
from discord.ext import commands
from Roxbot.load_config import owner
from Roxbot import guild_settings as gs
from roxbot.load_config import owner
from roxbot import guild_settings as gs


def is_owner_or_admin():

Roxbot/cogs/admin.py → roxbot/cogs/admin.py View File

@@ -4,8 +4,8 @@ import datetime
from discord.ext import commands
from discord.ext.commands import bot

import Roxbot as roxbot
from Roxbot import guild_settings as gs
import roxbot
from roxbot import guild_settings as gs


def _is_admin_or_mod(message):
@@ -84,7 +84,7 @@ class Admin():
async def purge(self, ctx, limit=0, *, author: discord.User = None):
"""Purges messages from the text channel.
Limit = Limit of messages to be deleted
Author (optional) = If given, Roxbot will selectively only delete this user's messages."""
Author (optional) = If given, roxbot will selectively only delete this user's messages."""
# Sadly I cant find an elegant way for the bot to be able to purge members that have left.
if author:
predicate = lambda message: message.author.id == author.id and message.id != ctx.message.id

Roxbot/cogs/customcommands.py → roxbot/cogs/customcommands.py View File

@@ -1,7 +1,7 @@
import discord
from discord.ext.commands import group

import Roxbot
import roxbot


class CustomCommands():
@@ -11,11 +11,11 @@ class CustomCommands():
async def on_message(self, message):
if isinstance(message.channel, discord.DMChannel):
return
settings = Roxbot.guild_settings.get(message.guild)
settings = roxbot.guild_settings.get(message.guild)
msg = message.content.lower()
channel = message.channel

if Roxbot.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
@@ -29,7 +29,7 @@ class CustomCommands():
return await channel.send(settings.custom_commands["0"][command])

@group(pass_context=True, aliases=["cc"])
@Roxbot.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."""
if ctx.invoked_subcommand is None:
@@ -38,7 +38,7 @@ class CustomCommands():
@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 = Roxbot.guild_settings.get(ctx.guild)
settings = roxbot.guild_settings.get(ctx.guild)
command = command.lower()
output = output
zero = settings.custom_commands["0"]
@@ -64,7 +64,7 @@ class CustomCommands():
@custom.command(pass_context=True)
async def edit(self, ctx, command, edit):
""""Edits an existing custom command."""
settings = Roxbot.guild_settings.get(ctx.guild)
settings = roxbot.guild_settings.get(ctx.guild)
zero = settings.custom_commands["0"]
one = settings.custom_commands["1"]

@@ -85,7 +85,7 @@ class CustomCommands():
@custom.command(pass_context=True)
async def remove(self, ctx, command):
""""Removes a custom command."""
settings = Roxbot.guild_settings.get(ctx.guild)
settings = roxbot.guild_settings.get(ctx.guild)
command = command.lower()
if command in settings.custom_commands["1"]:
settings.custom_commands["1"].pop(command)
@@ -103,7 +103,7 @@ class CustomCommands():
""""Lists all custom commands for this server."""
if debug != "0" and debug != "1":
debug = "0"
settings = Roxbot.guild_settings.get(ctx.guild)
settings = roxbot.guild_settings.get(ctx.guild)
cc = settings.custom_commands
listzero = ""
listone = ""
@@ -123,7 +123,7 @@ 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=Roxbot.EmbedColours.pink)
em = discord.Embed(title="Here is the list of Custom Commands", color=roxbot.EmbedColours.pink)
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)

Roxbot/cogs/fun.py → roxbot/cogs/fun.py View File

@@ -3,7 +3,7 @@ import random
import discord
from discord.ext.commands import bot

import Roxbot
import roxbot


class Fun:
@@ -142,27 +142,27 @@ class Fun:
if i < (times-1): response += '\n'
return await ctx.send(response)

@Roxbot.checks.isnt_anal()
@roxbot.checks.isnt_anal()
@bot.command()
async def spank(self, ctx, *, user: discord.User = None):
"""
Spanks the mentioned user ;)
Usage:
{command_prefix}spank @Roxbot#4170
{command_prefix}spank Roxbot
{command_prefix}spank @roxbot#4170
{command_prefix}spank roxbot
"""
if not user:
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))

@Roxbot.checks.isnt_anal()
@roxbot.checks.isnt_anal()
@bot.command(aliases=["succ"])
async def suck(self, ctx, *, user: discord.User = None):
"""
Sucks the mentioned user ;)
Usage:
{command_prefix}suck @Roxbot#4170
{command_prefix}suck Roxbot
{command_prefix}suck @roxbot#4170
{command_prefix}suck roxbot
"""
if not user:
return await ctx.send("You didn't mention someone for me to suck")
@@ -173,7 +173,7 @@ class Fun:
"""
Hugs the mentioned user :3
Usage:
{command_prefix}hug @Roxbot#4170
{command_prefix}hug @roxbot#4170
{command_prefix}hug Roxbott
"""
if not user:
@@ -185,8 +185,8 @@ class Fun:
"""
Gives headpats to the mentioned user :3
Usage:
{command_prefix}pet @Roxbot#4170
{command_prefix}pet Roxbot
{command_prefix}pet @roxbot#4170
{command_prefix}pet roxbot
"""
if not user:
return await ctx.send("You didn't mention someone for me to headpat")
@@ -243,17 +243,17 @@ class Fun:
converted = str(convert).translate(WIDE_MAP)
await ctx.send(converted)

logging = Roxbot.guild_settings.get(ctx.guild).logging
logging = roxbot.guild_settings.get(ctx.guild).logging
log_channel = self.bot.get_channel(logging["channel"])
await Roxbot.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):
"""RETURNS FROG TIPS FOR HOW TO OPERATE YOUR FROG"""
endpoint = "https://frog.tips/api/1/tips/"
croak = await Roxbot.http.api_request(endpoint)
croak = await roxbot.http.api_request(endpoint)
tip = random.choice(croak["tips"])
embed = discord.Embed(title="Frog Tip #{}".format(tip["number"]), description=tip["tip"], colour=Roxbot.EmbedColours.frog_green)
embed = discord.Embed(title="Frog Tip #{}".format(tip["number"]), description=tip["tip"], colour=roxbot.EmbedColours.frog_green)
embed.set_author(name="HOW TO OPERATE YOUR FROG")
embed.set_footer(text="https://frog.tips")
return await ctx.send(embed=embed)

Roxbot/cogs/gss.py → roxbot/cogs/gss.py View File

@@ -4,7 +4,7 @@ import discord
from discord.ext import commands
from discord.ext.commands import bot

import Roxbot
import roxbot


def is_gss():
@@ -21,7 +21,7 @@ def is_not_nsfw_disabled():
async def tatsumaki_api_call(member, guild):
base = "https://api.tatsumaki.xyz/"
url = base + "guilds/" + str(guild.id) + "/members/" + str(member.id) + "/stats"
return await Roxbot.http.api_request(url, headers={"Authorization": Roxbot.tat_token})
return await roxbot.http.api_request(url, headers={"Authorization": roxbot.tat_token})


class GaySoundsShitposts():
@@ -36,7 +36,7 @@ class GaySoundsShitposts():
# Just in case some cunt looks at the source code and thinks they can give themselves Admin.
if role.id not in self.acceptable_roles:
return False
settings = Roxbot.guild_settings.get(ctx.guild)
settings = roxbot.guild_settings.get(ctx.guild)
member = ctx.author
required_score = settings.gss["required_score"]
days = int(settings.gss["required_days"])

Roxbot/cogs/joinleave.py → roxbot/cogs/joinleave.py View File

@@ -1,6 +1,6 @@
import discord
import Roxbot
from Roxbot import guild_settings
import roxbot
from roxbot import guild_settings


class JoinLeave():
@@ -22,7 +22,7 @@ class JoinLeave():
em = discord.Embed(
title="Welcome to {}!".format(member.guild),
description='Hey {}! Welcome to **{}**! {}'.format(member.mention, member.guild, message),
colour=Roxbot.EmbedColours.pink)
colour=roxbot.EmbedColours.pink)
em.set_thumbnail(url=member.avatar_url)

channel = self.bot.get_channel(settings.greets["welcome-channel"])
@@ -39,7 +39,7 @@ class JoinLeave():
else:
channel = self.bot.get_channel(channel)
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))


def setup(Bot):

Roxbot/cogs/nsfw.py → roxbot/cogs/nsfw.py View File

@@ -1,8 +1,8 @@
import random
from discord.ext.commands import bot

import Roxbot as roxbot
from Roxbot import guild_settings as gs
import roxbot
from roxbot import guild_settings as gs


def tag_blacklist(guild):

Roxbot/cogs/reddit.py → roxbot/cogs/reddit.py View File

@@ -3,8 +3,8 @@ from html import unescape
from bs4 import BeautifulSoup
from discord.ext.commands import bot

import Roxbot as roxbot
from Roxbot import guild_settings
import roxbot
from roxbot import guild_settings


async def _imgur_removed(url):

Roxbot/cogs/selfassign.py → roxbot/cogs/selfassign.py View File

@@ -1,8 +1,8 @@
import discord
from discord.ext import commands

import Roxbot
from Roxbot import guild_settings as gs
import roxbot
from roxbot import guild_settings as gs


class SelfAssign():
@@ -18,7 +18,7 @@ class SelfAssign():
"""
settings = gs.get(ctx.guild)
if not settings.self_assign["enabled"]:
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
embed = discord.Embed(colour=roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
return await ctx.send(embed=embed)
roles = []
for role in settings.self_assign["roles"]:
@@ -26,7 +26,7 @@ class SelfAssign():
if role == serverrole.id:
roles.append("**"+serverrole.name+"**")
roles = '\n'.join(roles)
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="The self-assignable roles for this server are: \n"+roles)
embed = discord.Embed(colour=roxbot.EmbedColours.pink, description="The self-assignable roles for this server are: \n"+roles)
return await ctx.send(embed=embed)

@commands.command(pass_context=True)
@@ -46,7 +46,7 @@ class SelfAssign():
raise commands.MissingRequiredArgument(Parameter("Role", False))

if not settings.self_assign["enabled"]:
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
embed = discord.Embed(colour=roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
return await ctx.send(embed=embed)

member = ctx.author
@@ -76,7 +76,7 @@ class SelfAssign():
raise commands.MissingRequiredArgument(Parameter("role", False))

if not settings.self_assign["enabled"]:
embed = discord.Embed(colour=Roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
embed = discord.Embed(colour=roxbot.EmbedColours.pink, description="SelfAssignable roles are not enabled on this server")
return await ctx.send(embed=embed)

member = ctx.author

Roxbot/cogs/trivia.py → roxbot/cogs/trivia.py View File

@@ -8,14 +8,14 @@ from random import shuffle
from collections import OrderedDict
from discord.ext import commands

from Roxbot import http, checks, EmbedColours
from roxbot import http, checks, EmbedColours


class Trivia:
"""
Trivia is based off the lovely https://opentdb.com made by PixelTail Games.

This cog requires the bot account to be in the Roxbot Emoji Server to work.
This cog requires the bot account to be in the roxbot Emoji Server to work.
"""
def __init__(self, bot_client):
# Get emoji objects here for the reactions. Basically to speedup the reactions for the game.
@@ -213,10 +213,10 @@ class Trivia:

@commands.group(aliases=["tr"], case_insensitive=True)
async def trivia(self, ctx):
"""Command group for the Roxbot Trivia game."""
"""Command group for the roxbot Trivia game."""
if ctx.invoked_subcommand == self.start and ctx.channel.id not in self.games:
embed = discord.Embed(colour=EmbedColours.pink)
embed.set_footer(text="Roxbot Trivia uses the Open Trivia DB, made and maintained by Pixeltail Games LLC. Find out more at https://opentdb.com/")
embed.set_footer(text="roxbot Trivia uses the Open Trivia DB, made and maintained by Pixeltail Games LLC. Find out more at https://opentdb.com/")
embed.set_image(url="https://i.imgur.com/yhRVl9e.png")
await ctx.send(embed=embed)
elif ctx.invoked_subcommand == None:
@@ -226,13 +226,13 @@ class Trivia:
async def about(self, ctx):
"""He;p using the trivia game."""
embed = discord.Embed(
title="About Roxbot Trivia",
description="Roxbot Trivia is a trivia game in *your* discord server. It's heavily inspired by Tower Unite's trivia game. (and even uses the same questions database!) To start, just type `{}trivia start`.".format(self.bot.command_prefix),
title="About roxbot Trivia",
description="roxbot Trivia is a trivia game in *your* discord server. It's heavily inspired by Tower Unite's trivia game. (and even uses the same questions database!) To start, just type `{}trivia start`.".format(self.bot.command_prefix),
colour=EmbedColours.pink)
embed.add_field(name="How to Play", value="Once the game has started, questions will be asked and you will be given 20 seconds to answer them. To answer, react with the corrosponding emoji. Roxbot will only accept your first answer. Score is calculated by how quickly you can answer correctly, so make sure to be as quick as possible to win! Person with the most score at the end wins. Glhf!")
embed.add_field(name="How to Play", value="Once the game has started, questions will be asked and you will be given 20 seconds to answer them. To answer, react with the corrosponding emoji. roxbot will only accept your first answer. Score is calculated by how quickly you can answer correctly, so make sure to be as quick as possible to win! Person with the most score at the end wins. Glhf!")
embed.add_field(name="Can I have shorter or longer games?", value="Yes! You can change the length of the game by adding either short (5 questions) or long (15 questions) at the end of the start command. `{}trivia start short`. The default is 10 and this is the medium option.".format(self.bot.command_prefix))
embed.add_field(name="Can I play with friends?", value="Yes! Trivia is best with friends. How else would friendships come to their untimely demise? You can only join a game during the 20 second waiting period after a game is started. Just type `{0}trivia join` and you're in! You can leave a game at anytime (even if its just you) by doing `{0}trivia leave`. If no players are in a game, the game will end and no one will win ;-;".format(self.bot.command_prefix))
embed.set_footer(text="Roxbot Trivia uses the Open Trivia DB, made and maintained by Pixeltail Games LLC. Find out more at https://opentdb.com/")
embed.set_footer(text="roxbot Trivia uses the Open Trivia DB, made and maintained by Pixeltail Games LLC. Find out more at https://opentdb.com/")
embed.set_image(url="https://i.imgur.com/yhRVl9e.png")
return await ctx.send(embed=embed)

@@ -268,7 +268,7 @@ class Trivia:
self.games[channel.id] = game

# Waiting for players
await ctx.send(embed=discord.Embed(description="Starting Roxbot Trivia! Starting in 20 seconds...", colour=self.trivia_colour))
await ctx.send(embed=discord.Embed(description="Starting roxbot Trivia! Starting in 20 seconds...", colour=self.trivia_colour))
await asyncio.sleep(20)

# Get questions

Roxbot/cogs/twitch.py → roxbot/cogs/twitch.py View File

@@ -1,7 +1,7 @@
from discord import ActivityType
from discord.ext import commands

import Roxbot
import roxbot


class Twitch():
@@ -13,8 +13,8 @@ class Twitch():

async def on_member_update(self, member_b, member_a):
"""Twitch Shilling Part"""
twitch = Roxbot.guild_settings.get(member_b.guild).twitch
if Roxbot.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:
@@ -25,7 +25,7 @@ class Twitch():
member_a.name, member_a.game.name, member_a.game.url))

@commands.group()
@Roxbot.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:
@@ -36,7 +36,7 @@ class Twitch():
"""Enables the twitch shilling whitelist. Repeat the command to disable.
Usage:
;whitelist enable"""
settings = Roxbot.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")
@@ -53,7 +53,7 @@ class Twitch():
# TODO: This is all horribly outdated useage and needs to be rewritten.

whitelist_count = 0
settings = Roxbot.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.")

Roxbot/cogs/util.py → roxbot/cogs/util.py View File

@@ -3,7 +3,7 @@ import discord
from discord.ext import commands
from discord.ext.commands import bot

import Roxbot
import roxbot


class Util():
@@ -30,7 +30,7 @@ class Util():
else:
avaimg = '{0.name}.png'.format(user)

await Roxbot.http.download_file(url, avaimg)
await roxbot.http.download_file(url, avaimg)
await ctx.send(file=discord.File(avaimg))
os.remove(avaimg)

@@ -159,7 +159,7 @@ class Util():
for attachment in ctx.message.attachments:
name = attachment.url.split("/")[-1]
# Download File
await Roxbot.http.download_file(attachment.url, name)
await roxbot.http.download_file(attachment.url, name)
# Upload file
#with open(name, 'rb') as f:
# answer = requests.post(url=site + "upload.php", files={'files[]': (name, f.read())})
@@ -192,7 +192,7 @@ class Util():
emoji_id = emote[2]
url = "https://cdn.discordapp.com/emojis/{}".format(emoji_id)

await Roxbot.http.download_file(url, imgname)
await roxbot.http.download_file(url, imgname)
await ctx.send(file=discord.File(imgname))
os.remove(imgname)


Roxbot/cogs/voice.py → roxbot/cogs/voice.py View File

@@ -6,22 +6,22 @@ import youtube_dl
from math import ceil
from discord.ext import commands

import Roxbot
from Roxbot import guild_settings
import roxbot
from roxbot import guild_settings


def _clear_cache():
"""Clears the cache folder for the music bot. Ignores the ".gitignore" file to avoid deleting versioned files."""
for file in os.listdir("Roxbot/cache"):
for file in os.listdir("roxbot/cache"):
if file != ".gitignore":
os.remove("Roxbot/cache/{}".format(file))
os.remove("roxbot/cache/{}".format(file))


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 == Roxbot.owner:
if ctx.message.author.id == roxbot.owner:
return True
else:
admin_roles = gs.perm_roles["admin"]
@@ -41,7 +41,7 @@ youtube_dl.utils.bug_reports_message = lambda: ''

ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': './Roxbot/cache/%(extractor)s-%(id)s-%(title)s.%(ext)s',
'outtmpl': './roxbot/cache/%(extractor)s-%(id)s-%(title)s.%(ext)s',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
@@ -166,7 +166,7 @@ class Voice:
duration = self._format_duration(np.duration)
time_played = self._format_duration(np.source.timer/1000)

embed = discord.Embed(title=title, colour=Roxbot.EmbedColours.pink, url=np.webpage_url)
embed = discord.Embed(title=title, colour=roxbot.EmbedColours.pink, url=np.webpage_url)
embed.description = "Uploaded by: [{0.uploader}]({0.uploader_url})\nURL: [Here]({0.webpage_url})\nDuration: {1}\nQueued by: {0.queued_by}".format(np, duration)
embed.set_image(url=np.thumbnail_url)
embed.set_footer(text="Timer: {}/{}".format(time_played, duration))
@@ -180,7 +180,7 @@ class Voice:
self.now_playing[guild.id] = None
self.queue_logic[guild.id] = None

@Roxbot.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."""
@@ -189,7 +189,7 @@ class Voice:
try:
channel = ctx.author.voice.channel
except AttributeError:
raise commands.CommandError("Failed to join voice channel. Please specify a channel or join one for Roxbot to join.")
raise commands.CommandError("Failed to join voice channel. Please specify a channel or join one for roxbot to join.")

# Join VoiceChannel
if ctx.voice_client is not None:
@@ -215,11 +215,11 @@ class Voice:
guild = ctx.guild

# Checks if invoker is in voice with the bot. Skips admins and mods and owner.
if not Roxbot.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.")
raise commands.CommandError("You're not in the same voice channel as roxbot.")
if ctx.author.voice.channel != ctx.voice_client.channel:
raise commands.CommandError("You're not in the same voice channel as Roxbot.")
raise commands.CommandError("You're not in the same voice channel as roxbot.")

# For internal speed. This should make the playlist management quicker when play is being invoked internally.
if isinstance(url, dict):
@@ -239,7 +239,7 @@ class Voice:
video = video["entries"][0]

# Duration limiter handling
if video.get("duration", 1) > voice["max_length"] and not Roxbot.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.
@@ -268,7 +268,7 @@ class Voice:
# Sleep because if not, queued up things will send first and probably freak out users or something
while self.am_queuing[guild.id] is True:
await asyncio.sleep(0.5)
embed = discord.Embed(description='Added "{}" to queue'.format(video.get("title")), colour=Roxbot.EmbedColours.pink)
embed = discord.Embed(description='Added "{}" to queue'.format(video.get("title")), colour=roxbot.EmbedColours.pink)
await ctx.send(embed=embed)

@commands.cooldown(1, 0.5, commands.BucketType.guild)
@@ -287,14 +287,14 @@ class Voice:
if ctx.author.voice:
await ctx.author.voice.channel.connect()
else:
raise commands.CommandError("Roxbot is not connected to a voice channel and couldn't auto-join a voice channel.")
raise commands.CommandError("roxbot is not connected to a voice channel and couldn't auto-join a voice channel.")

@volume_perms()
@commands.command()
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."""
if ctx.voice_client is None:
raise commands.CommandError("Roxbot is not in a voice channel.")
raise commands.CommandError("roxbot is not in a voice channel.")

try:
volume = int(volume)
@@ -317,7 +317,7 @@ class Voice:
async def pause(self, ctx):
"""Pauses the current video, if playing."""
if ctx.voice_client is None:
raise commands.CommandError("Roxbot is not in a voice channel.")
raise commands.CommandError("roxbot is not in a voice channel.")
else:
if not ctx.voice_client.is_playing():
return await ctx.send("Nothing is playing.")
@@ -332,7 +332,7 @@ class Voice:
"""Resumes the bot if paused. Also will play the next thing in the queue if the bot is stuck."""
if ctx.voice_client is None:
if len(self.playlist[ctx.guild.id]) < 1:
raise commands.CommandError("Roxbot is not in a voice channel.")
raise commands.CommandError("roxbot is not in a voice channel.")
else:
video = self.playlist[ctx.guild.id].pop(0)
await ctx.invoke(self.play, url=video)
@@ -352,7 +352,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 Roxbot.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:
@@ -400,10 +400,10 @@ class Voice:
index += 1
if output == "":
output = "Nothing is up next. Maybe you should add something!"
embed = discord.Embed(title="Queue", description=output, colour=Roxbot.EmbedColours.pink)
embed = discord.Embed(title="Queue", description=output, colour=roxbot.EmbedColours.pink)
return await ctx.send(embed=embed)

@Roxbot.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."""
@@ -429,12 +429,12 @@ class Voice:
except IndexError:
raise commands.CommandError("Valid Index not given.")

@Roxbot.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."""
if ctx.voice_client is None:
raise commands.CommandError("Roxbot is not in a voice channel.")
raise commands.CommandError("roxbot is not in a voice channel.")
else:
# Clear up variables before stopping.
self.playlist[ctx.guild.id] = []

Roxbot/err_handle.py → roxbot/err_handle.py View File

@@ -3,8 +3,8 @@ import discord
import datetime
import traceback
from discord.ext import commands
import Roxbot
from Roxbot import guild_settings
import roxbot
from roxbot import guild_settings


class ErrHandle:
@@ -16,7 +16,7 @@ class ErrHandle:
if self.dev:
traceback.print_exc()
else:
embed = discord.Embed(title="Roxbot Error", colour=Roxbot.EmbedColours.red) # Red
embed = discord.Embed(title="roxbot Error", colour=roxbot.EmbedColours.red) # Red
embed.add_field(name='Event', value=event)
embed.description = '```py\n{}\n```'.format(traceback.format_exc())
embed.timestamp = datetime.datetime.utcnow()
@@ -27,7 +27,7 @@ class ErrHandle:
if self.dev:
raise error
elif isinstance(error, commands.CommandInvokeError):
embed = discord.Embed(title='Command Error', colour=Roxbot.EmbedColours.dark_red)
embed = discord.Embed(title='Command Error', colour=roxbot.EmbedColours.dark_red)
embed.description = str(error)
embed.add_field(name='Server', value=ctx.guild)
embed.add_field(name='Channel', value=ctx.channel.mention)
@@ -56,7 +56,7 @@ class ErrHandle:
else:
embed = discord.Embed(description="That Command doesn't exist.")
elif isinstance(error, commands.BotMissingPermissions):
embed = discord.Embed(description="{}".format(error.args[0].replace("Bot", "Roxbot")))
embed = discord.Embed(description="{}".format(error.args[0].replace("Bot", "roxbot")))
elif isinstance(error, commands.MissingPermissions):
embed = discord.Embed(description="{}".format(error.args[0]))
elif isinstance(error, commands.NotOwner):
@@ -71,7 +71,7 @@ class ErrHandle:
embed = discord.Embed(
description="Placeholder embed. If you see this please message {}.".format(str(self.owner)))
if embed:
embed.colour = Roxbot.EmbedColours.dark_red
embed.colour = roxbot.EmbedColours.dark_red
await ctx.send(embed=embed, delete_after=8)



Roxbot/guild_settings.py → roxbot/guild_settings.py View File

@@ -64,7 +64,7 @@ def _open_config():
Opens the guild settings file
:return settings file: :type dict:
"""
with open('Roxbot/settings/servers.json', 'r') as config_file:
with open('roxbot/settings/servers.json', 'r') as config_file:
return json.load(config_file)

def _write_changes(config):
@@ -73,11 +73,11 @@ def _write_changes(config):
:param config: :type dict:
:return:
"""
with open('Roxbot/settings/servers.json', 'w') as conf_file:
with open('roxbot/settings/servers.json', 'w') as conf_file:
json.dump(config, conf_file)

def backup(config, name):
with open('Roxbot/settings/backups/{}.json'.format(name), "w") as f:
with open('roxbot/settings/backups/{}.json'.format(name), "w") as f:
json.dump(config, f)

def remove_guild(guild):

Roxbot/http.py → roxbot/http.py View File


+ 40
- 0
roxbot/load_config.py View File

@@ -0,0 +1,40 @@
from enum import Enum
import configparser


settings = configparser.ConfigParser()
settings.read("roxbot/settings/preferences.ini")

command_prefix = settings["roxbot"]["Command_Prefix"]
token = settings["roxbot"]["Token"]
owner = int(settings["roxbot"]["OwnerID"])
tat_token = settings["roxbot"]["Tatsumaki_Token"]


class EmbedColours(Enum):
pink = 0xDEADBF
yellow = 0xFDDF86
blue = 0x6F90F5
frog_green = 0x4C943D # Used for FROGTIPS
red = 0xe74c3c # Used for on_error
dark_red = 0x992d22 # Used for on_command_error
triv_green = 0x1fb600 # Used for the correct answer in trivia
gold = 0xd4af3a # Used for displaying the winner in trivia


# REMEMBER TO UNCOMMENT THE GSS LINE, ROXIE

cogs = [
"roxbot.cogs.admin",
"roxbot.cogs.customcommands",
"roxbot.cogs.fun",
"roxbot.cogs.joinleave",
"roxbot.cogs.nsfw",
"roxbot.cogs.reddit",
"roxbot.cogs.selfassign",
"roxbot.cogs.trivia",
"roxbot.cogs.twitch",
"roxbot.cogs.util",
"roxbot.cogs.voice",
#"roxbot.cogs.gss"
]

Roxbot/logging.py → roxbot/logging.py View File

@@ -1,5 +1,5 @@
import discord
from Roxbot import guild_settings, EmbedColours
from roxbot import guild_settings, EmbedColours


async def log(guild, channel, command_name, **kwargs):

Roxbot/settings/backups/.gitignore → roxbot/settings/backups/.gitignore View File


Roxbot/settings/blacklist.txt → roxbot/settings/blacklist.txt View File


Roxbot/settings/preferences_example.ini → roxbot/settings/preferences_example.ini View File


Roxbot/settings/settings.py → roxbot/settings/settings.py View File

@@ -4,7 +4,7 @@ import aiohttp
import asyncio
import datetime

from Roxbot import checks, load_config, guild_settings, EmbedColours
from roxbot import checks, load_config, guild_settings, EmbedColours

import discord
from discord.ext.commands import bot, group, is_owner, bot_has_permissions
@@ -67,13 +67,13 @@ class Settings:
mentions.remove(user)

if option in ['+', 'add']:
with open("Roxbot/blacklist.txt", "r") as fp:
with open("roxbot/blacklist.txt", "r") as fp:
for user in mentions:
for line in fp.readlines():
if user.id + "\n" in line:
mentions.remove(user)

with open("Roxbot/blacklist.txt", "a+") as fp:
with open("roxbot/blacklist.txt", "a+") as fp:
lines = fp.readlines()
for user in mentions:
if user.id not in lines:
@@ -82,9 +82,9 @@ class Settings:
return await ctx.send('{} user(s) have been added to the blacklist'.format(blacklist_amount))

elif option in ['-', 'remove']:
with open("Roxbot/blacklist.txt", "r") as fp:
with open("roxbot/blacklist.txt", "r") as fp:
lines = fp.readlines()
with open("Roxbot/blacklist.txt", "w") as fp:
with open("roxbot/blacklist.txt", "w") as fp:
for user in mentions:
for line in lines:
if user.id + "\n" != line:

Loading…
Cancel
Save