Browse Source

Started fixing and making the settings file better.

tags/v1.1.0
roxie 6 years ago
parent
commit
d83976a9eb
2 changed files with 29 additions and 29 deletions
  1. +22
    -24
      cogs/settings.py
  2. +7
    -5
      main.py

+ 22
- 24
cogs/settings.py View File

@@ -75,7 +75,6 @@ class Settings():
blacklist_amount += 1
return await self.bot.say('{} user(s) have been removed from the blacklist'.format(blacklist_amount))


@bot.command(pass_context=True, hidden=True)
@checks.is_bot_owner()
async def enablesetting(self, ctx, setting):
@@ -117,44 +116,44 @@ class Settings():

@set.command(pass_context=True, hidden=True)
async def welcomechannel(self, ctx, channel: discord.Channel = None):
self.serverconfig = self.con.load_config()
self.serverconfig[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id
self.con.update_config(self.serverconfig)
self.servers = self.con.load_config()
self.servers[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id
self.con.update_config(self.servers)
return await self.bot.say("{} has been set as the welcome channel!".format(channel.mention))

@set.command(pass_context=True, hidden=True)
async def goodbyechannel(self, ctx, channel: discord.Channel = None):
self.serverconfig = self.con.load_config()
self.serverconfig[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id
self.con.update_config(self.serverconfig)
self.servers = self.con.load_config()
self.servers[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id
self.con.update_config(self.servers)
return await self.bot.say("{} has been set as the goodbye channel!".format(channel.mention))

@set.command(pass_context=True, hidden=True)
async def twitchchannel(self, ctx, channel: discord.Channel = None):
self.serverconfig = self.con.load_config()
self.serverconfig[ctx.message.server.id]["twitch"]["twitch-channel"] = channel.id
self.con.update_config(self.serverconfig)
self.servers = self.con.load_config()
self.servers[ctx.message.server.id]["twitch"]["twitch-channel"] = channel.id
self.con.update_config(self.servers)
return await self.bot.say("{} has been set as the twitch shilling channel!".format(channel.mention))

@set.command(pass_context=True, hidden=True)
async def welcomemessage(self, ctx, *, message: str):
self.serverconfig = self.con.load_config()
self.serverconfig[ctx.message.server.id]["greets"]["custom-message"] = message
self.con.update_config(self.serverconfig)
self.servers = self.con.load_config()
self.servers[ctx.message.server.id]["greets"]["custom-message"] = message
self.con.update_config(self.servers)
return await self.bot.say("Custom message set to '{}'".format(message))

@set.command(pass_context=True, hidden=True)
async def muterole(self, ctx, role: discord.Role = None):
self.serverconfig = self.con.load_config()
self.serverconfig[ctx.message.server.id]["mute"]["role"] = role.id
self.con.update_config(self.serverconfig)
self.servers = self.con.load_config()
self.servers[ctx.message.server.id]["mute"]["role"] = role.id
self.con.update_config(self.servers)
return await self.bot.say("Muted role set to '{}'".format(role.name))

@set.command(pass_context=True, hidden=True)
async def adminrole(self, ctx, role: discord.Role = None):
self.serverconfig = self.con.load_config()
self.serverconfig[ctx.message.server.id]["admin_role"] = role.id
self.con.update_config(self.serverconfig)
self.servers= self.con.load_config()
self.servers[ctx.message.server.id]["admin_role"] = role.id
self.con.update_config(self.servers)
return await self.bot.say("Admin role set to '{}'".format(role.name))

@bot.command(pass_context=True, hidden=True, aliases=["setava", "setavatar"])
@@ -216,16 +215,15 @@ class Settings():
await self.bot.change_presence(status=discordStatus)
await self.bot.say("**:ok:** Status set to {}".format(discordStatus))


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

@bot.command(pass_context=True, hidden=True)
@bot.command(hidden=True)
@checks.is_bot_owner()
async def shutdown(self, ctx):
async def shutdown(self):
await self.bot.logout()
return exit(0)


+ 7
- 5
main.py View File

@@ -4,7 +4,6 @@ import logging
import os.path
import datetime
import traceback
import json

import discord
from discord.ext import commands
@@ -24,8 +23,11 @@ logger.addHandler(handler)

server_config = ServerConfig()
bot = commands.Bot(command_prefix=load_config.command_prefix, description=load_config.description)
bot.dev = False # For debugging
bot.dev = True # For debugging
bot.owner = load_config.owner
# TODO: Put load_config variables into the bot variable so we can pass all of it to the cogs as one.
# Can't do this with server config in any meaningful way since it still needs updating.


def blacklisted(user):
with open("config/blacklist.txt", "r") as fp:
@@ -102,8 +104,8 @@ async def on_command_error(error, ctx):
await bot.send_message(ctx.message.channel, content="This command is disabled.")
elif isinstance(error, commands.CheckFailure):
await bot.send_message(ctx.message.channel, content="You do not have permission to do this. Back off, thot!")
elif isinstance(error, json.JSONDecodeError): # For the NSFW cogs requests because error exception doesn't work in commands because of this here.
await bot.send_message(ctx.message.channel, content="That didn't return anything")
elif isinstance(error, KeyError):
await bot.send_message(ctx.message.channel, content="Belgh")
elif isinstance(error, commands.CommandInvokeError):
if bot.dev:
raise error
@@ -113,7 +115,7 @@ async def on_command_error(error, ctx):
embed.add_field(name='Server', value=ctx.message.server)
embed.add_field(name='Channel', value=ctx.message.channel)
embed.add_field(name='User', value=ctx.message.author)
embed.add_field(name='Message', value=ctx.message.clean_content)
embed.add_field(name='Message', value=ctx.message.content)
embed.timestamp = datetime.datetime.utcnow()
try:
await bot.send_message(load_config.owner, embed=embed)

Loading…
Cancel
Save