Browse Source

settings commands starting to be cleaned up. Also removed the announcement command.

tags/v1.4.0
roxie 6 years ago
parent
commit
98de9f28f8
4 changed files with 41 additions and 58 deletions
  1. +0
    -26
      cogs/selfassign.py
  2. +39
    -29
      config/settings.py
  3. +0
    -1
      load_config.py
  4. +2
    -2
      main.py

+ 0
- 26
cogs/selfassign.py View File

@@ -92,33 +92,7 @@ class SelfAssign():
else:
return await self.bot.say("That role is not self-assignable.")

@commands.command(pass_context=True, hidden=True)
@checks.is_bot_owner()
async def addrole(self, ctx, *, role: discord.Role = None):
"""
] Adds a role to the list of roles that can be self assigned for that server.
"""
self.servers = self.con.load_config()
if role.id in self.servers[ctx.message.server.id]["self_assign"]["roles"]:
return await self.bot.say("{} is already a self-assignable role.".format(role.name), delete_after=self.con.delete_after)

self.servers[ctx.message.server.id]["self_assign"]["roles"].append(role.id)
self.con.update_config(self.servers)
return await self.bot.say('Role "{}" added'.format(str(role)))

@commands.command(pass_context=True, hidden=True)
@checks.is_bot_owner()
async def removerole(self, ctx, *, role: discord.Role = None):
"""
Removes a role from the list of self assignable roles for that server.
"""
self.servers = self.con.load_config()
if role.id in self.servers[ctx.message.server.id]["self_assign"]["roles"]:
self.servers[ctx.message.server.id]["self_assign"]["roles"].remove(role.id)
self.con.update_config(self.servers)
return await self.bot.say('"{}" has been removed from the self-assignable roles.'.format(str(role)))
else:
return await self.bot.say("That role was not in the list.")

def setup(Bot):
Bot.add_cog(SelfAssign(Bot))

+ 39
- 29
config/settings.py View File

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

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


class Settings():
@@ -142,21 +141,6 @@ class Settings():
await self.bot.logout()
return exit(0)

@bot.command(pass_context=True, hidden=True)
@checks.is_bot_owner()
async def announce(self, ctx, *announcement):
"""
ONLY USE FOR SERIOUS ANNOUNCEMENTS
"""
# TODO: Make colour top level role colour
# TODO: Custom message for annoucement footer
embed = discord.Embed(title="RoxBot Announcement", colour=discord.Colour(0x306f99), description=' '.join(announcement))
embed.set_footer(text="This message has be automatically generated by a cute ass Roxie",
icon_url=self.bot.user.avatar_url)
for server in self.bot.servers:
await self.bot.send_message(server, embed=embed)
return await self.bot.say("Done!", delete_after=self.con.delete_after)

@bot.command(pass_context=True)
@checks.is_owner_or_admin()
async def printsettings(self, ctx):
@@ -182,13 +166,40 @@ class Settings():

@group(pass_context=True)
async def settings(self, ctx):
pass
self.serverconfig = self.con.load_config()
self.guild_id = str(ctx.message.guild.id)

@settings.command(pass_context=True)
async def self_assign(self, ctx, selection, *, changes = None):
"""
Adds a role to the list of roles that can be self assigned for that server.
Removes a role from the list of self assignable roles for that server.
"""
selection = selection.lower()
role = converter.RoleConverter.convert(changes)
if selection == "enable":
pass

self.serverconfig[self.guild_id]["self_assign"]["enabled"] = 1
self.con.update_config(self.serverconfig)
return await ctx.send("'self_assign' was enabled!")
elif selection == "disable":
self.serverconfig[self.guild_id]["self_assign"]["enabled"] = 0
self.con.update_config(self.serverconfig)
return await ctx.send("'self_assign' was disabled :cry:")
elif selection == "add":
if role.id in self.servers[ctx.message.server.id]["self_assign"]["roles"]:
return await ctx.send("{} is already a self-assignable role.".format(role.name),
delete_after=self.con.delete_after)

self.servers[ctx.message.server.id]["self_assign"]["roles"].append(role.id)
self.con.update_config(self.servers)
return await ctx.send('Role "{}" added'.format(str(role)))
elif selection == "remove":
if role.id in self.servers[ctx.message.server.id]["self_assign"]["roles"]:
self.servers[ctx.message.server.id]["self_assign"]["roles"].remove(role.id)
self.con.update_config(self.servers)
return await ctx.send('"{}" has been removed from the self-assignable roles.'.format(str(role)))
else:
return await ctx.send("That role was not in the list.")


@bot.command(pass_context=True)
@@ -203,9 +214,8 @@ class Settings():
self.con.update_config(self.serverconfig)
return await self.bot.say("'{}' was enabled!".format(setting))
else:
self.serverconfig[server_id][setting]["enabled"] = 0
self.con.update_config(self.serverconfig)
return await self.bot.say("'{}' was disabled :cry:".format(setting))
pass

else:
return await self.bot.say("That module dont exist fam. You made the thing")

@@ -218,21 +228,21 @@ class Settings():
return await self.bot.say('Missing Argument')

@set.command(pass_context=True, hidden=True)
async def welcomechannel(self, ctx, channel: discord.Channel = None):
async def welcomechannel(self, ctx, channel: discord.TextChannel = None):
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):
async def goodbyechannel(self, ctx, channel: discord.TextChannel = None):
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): # Idk if this should be here, maybe in thw twitch cog?
async def twitchchannel(self, ctx, channel: discord.TextChannel = None): # Idk if this should be here, maybe in thw twitch cog?
self.servers = self.con.load_config()
self.servers[ctx.message.server.id]["twitch"]["twitch-channel"] = channel.id
self.con.update_config(self.servers)
@@ -254,7 +264,7 @@ class Settings():
return await self.bot.say("Muted role set to '{}'".format(role.name))

@set.command(pass_context=True, hidden=True)
async def loggingchannel(self, ctx, channel: discord.Channel = None):
async def loggingchannel(self, ctx, channel: discord.TextChannel = None):
self.servers = self.con.load_config()
self.servers[ctx.message.server.id]["gss"]["log_channel"] = channel.id
self.con.update_config(self.servers)
@@ -302,7 +312,7 @@ class Settings():
return await self.bot.say("'{}' is already in the list.".format(role.name))

@add.command(pass_context=True, aliases=["nsfwchannel"])
async def addnsfwchannel(self, ctx, *, channel: discord.Channel = None):
async def addnsfwchannel(self, ctx, *, channel: discord.TextChannel = None):
self.servers = self.con.load_config()
if channel.id not in self.servers[ctx.message.server.id]["nsfw"]["channels"]:
self.servers[ctx.message.server.id]["nsfw"]["channels"].append(channel.id)
@@ -339,7 +349,7 @@ class Settings():
return await self.bot.say("'{}' has been removed from the Mod role list.".format(role.name))

@remove.command(pass_context=True, aliases=["nsfwchannel"])
async def rensfwchannel(self, ctx, *, channel: discord.Channel = None):
async def rensfwchannel(self, ctx, *, channel: discord.TextChannel = None):
self.servers = self.con.load_config()
try:
self.servers[ctx.message.server.id]["nsfw"]["channels"].remove(channel.id)

+ 0
- 1
load_config.py View File

@@ -28,7 +28,6 @@ cogs = [
"cogs.nsfw",
"cogs.reddit",
"cogs.selfassign",
"cogs.settings",
"cogs.twitch",
"cogs.util",
"cogs.gss"

+ 2
- 2
main.py View File

@@ -23,7 +23,7 @@ start_time = time.time()

# Sets up Logging that discord.py does on its own
logger = logging.getLogger('discord')
logger.setLevel(logging.INFO)
logger.setLevel(logging.WARN)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
@@ -109,6 +109,6 @@ async def about(ctx):


if __name__ == "__main__":
bot.load_extension("config/settings")
bot.load_extension("config.settings")
#bot.load_extension("err_handle")
bot.run(load_config.token)

Loading…
Cancel
Save