Browse Source

cleaned a few things up so that it isn't so inefficent due to some of the features already being provided or useless code.

tags/v1.4.0
roxie 6 years ago
parent
commit
d7c9b6a11d
2 changed files with 21 additions and 21 deletions
  1. +8
    -7
      config/settings.py
  2. +13
    -14
      main.py

+ 8
- 7
config/settings.py View File

@@ -8,7 +8,7 @@ import load_config
from config.server_config import ServerConfig

import discord
from discord.ext.commands import bot, group
from discord.ext.commands import bot, group, is_owner


class Settings:
@@ -77,7 +77,7 @@ class Settings:
return await ctx.send('{} user(s) have been removed from the blacklist'.format(blacklist_amount))

@bot.command(pass_context=True, hidden=True, aliases=["setava", "setavatar"])
@checks.is_bot_owner()
@is_owner()
async def changeavatar(self, ctx, url=None):
"""
Usage:
@@ -102,7 +102,7 @@ class Settings:
return await ctx.send(":ok_hand:")

@bot.command(pass_context=True, hidden=True, aliases=["nick"])
@checks.is_bot_owner()
@is_owner()
async def changenickname(self, ctx, *nick):
if ctx.message.channel.permissions_for(ctx.message.server.me).change_nickname:
await self.bot.change_nickname(ctx.message.server.me, ' '.join(nick))
@@ -111,7 +111,7 @@ class Settings:
return await ctx.send("I don't have permission to do that :sob:", delete_after=self.con.delete_after)

@bot.command(pass_context=True, hidden=True, aliases=["setgame", "game"])
@checks.is_bot_owner()
@is_owner()
async def changegame(self, ctx, *, game: str):
if game.lower() == "none":
game_name = None
@@ -121,7 +121,7 @@ class Settings:
return await ctx.send(":ok_hand: Game set to {}".format(str(game_name)))

@bot.command(pass_context=True, hidden=True, aliases=["status"])
@checks.is_bot_owner()
@is_owner()
async def changestatus(self, ctx, status: str):
status = status.lower()
if status == 'offline' or status == 'invisible':
@@ -136,13 +136,13 @@ class Settings:
await ctx.send("**:ok:** Status set to {}".format(discordStatus))

@bot.command(hidden=True)
@checks.is_bot_owner()
@is_owner()
async def restart(self):
await self.bot.logout()
return os.execl(sys.executable, sys.executable, *sys.argv)

@bot.command(hidden=True)
@checks.is_bot_owner()
@is_owner()
async def shutdown(self):
await self.bot.logout()
return exit(0)
@@ -166,6 +166,7 @@ class Settings:
return await ctx.send(embed=em)

@group(pass_context=True)
@checks.is_admin_or_mod()
async def settings(self, ctx):
if ctx.invoked_subcommand is None:
return await ctx.send('Missing Argument')

+ 13
- 14
main.py View File

@@ -10,17 +10,6 @@ import load_config
from config.server_config import ServerConfig


if not os.path.isfile("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("config/servers.json"):
with open("config/servers.json", "w+") as fp:
fp.write("{}")

start_time = time.time()

# Sets up Logging that discord.py does on its own
logger = logging.getLogger('discord')
logger.setLevel(logging.WARN)
@@ -88,12 +77,11 @@ async def about(ctx):
"""
Outputs info about RoxBot, showing uptime, what settings where set in prefs.ini and credits.
"""
user = await bot.get_user_info(load_config.owner)
ownername = user.name + "#" + user.discriminator
ownername = await bot.get_user_info(load_config.owner)
em = discord.Embed(title="About Roxbot", colour=load_config.embedcolour, description=load_config.__description__)
em.set_thumbnail(url=bot.user.avatar_url)
em.add_field(name="Command Prefix", value=load_config.command_prefix)
em.add_field(name="Owner", value=ownername)
em.add_field(name="Owner", value=str(ownername))
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__)
@@ -109,6 +97,17 @@ async def about(ctx):


if __name__ == "__main__":
# Pre-Boot checks
if not os.path.isfile("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("config/servers.json"):
with open("config/servers.json", "w+") as fp:
fp.write("{}")

start_time = time.time()
bot.load_extension("config.settings")
#bot.load_extension("err_handle")
bot.run(load_config.token)

Loading…
Cancel
Save