Browse Source

settings and main should work now with the new objects.

tags/v1.5.0
Roxie Gibson 6 years ago
parent
commit
838fa60dfd
2 changed files with 9 additions and 10 deletions
  1. +7
    -8
      Roxbot/settings/settings.py
  2. +2
    -2
      main.py

+ 7
- 8
Roxbot/settings/settings.py View File

import asyncio import asyncio


from Roxbot import checks, load_config from Roxbot import checks, load_config
from Roxbot.settings import guild_settings as settings
from Roxbot.settings import guild_settings


import discord import discord
from discord.ext.commands import bot, group, is_owner, bot_has_permissions from discord.ext.commands import bot, group, is_owner, bot_has_permissions
""" """
def __init__(self, bot_client): def __init__(self, bot_client):
self.bot = bot_client self.bot = bot_client
self.settings = settings


def get_channel(self, ctx, channel): def get_channel(self, ctx, channel):
if ctx.message.channel_mentions: if ctx.message.channel_mentions:
@checks.is_owner_or_admin() @checks.is_owner_or_admin()
async def printsettings(self, ctx, option=None): async def printsettings(self, ctx, option=None):
"OWNER OR ADMIN ONLY: Prints the servers settings file." "OWNER OR ADMIN ONLY: Prints the servers settings file."
config = self.settings.get(ctx.guild)
config = guild_settings.get(ctx.guild)
em = discord.Embed(colour=0xDEADBF) em = discord.Embed(colour=0xDEADBF)
em.set_author(name="{} settings for {}.".format(self.bot.user.name, ctx.message.guild.name), icon_url=self.bot.user.avatar_url) em.set_author(name="{} settings for {}.".format(self.bot.user.name, ctx.message.guild.name), icon_url=self.bot.user.avatar_url)
if option in config:
if option in config.settings:
settingcontent = "" settingcontent = ""
for x in config[option].items():
for x in config.settings[option].items():
settingcontent += str(x).strip("()") + "\n" settingcontent += str(x).strip("()") + "\n"
em.add_field(name=option, value=settingcontent, inline=False) em.add_field(name=option, value=settingcontent, inline=False)
return await ctx.send(embed=em) return await ctx.send(embed=em)
else: else:
for settings in config:
for settings in config.settings:
if settings != "custom_commands" and settings != "warnings": if settings != "custom_commands" and settings != "warnings":
settingcontent = "" settingcontent = ""
for x in config[settings].items():
for x in config.settings[settings].items():
settingcontent += str(x).strip("()") + "\n" settingcontent += str(x).strip("()") + "\n"
em.add_field(name=settings, value=settingcontent, inline=False) em.add_field(name=settings, value=settingcontent, inline=False)
elif settings == "custom_commands": elif settings == "custom_commands":
async def settings(self, ctx): async def settings(self, ctx):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
return await ctx.send('Missing Argument') return await ctx.send('Missing Argument')
self.guild_settings = self.settings.get(ctx.guild)
self.guild_settings = guild_settings.get(ctx.guild)


@settings.command(aliases=["sa"]) @settings.command(aliases=["sa"])
async def selfassign(self, ctx, selection, *, changes = None): async def selfassign(self, ctx, selection, *, changes = None):

+ 2
- 2
main.py View File



@bot.event @bot.event
async def on_server_join(guild): async def on_server_join(guild):
bot.settings = gs.get_all(bot.guilds)
gs.error_check(bot.guilds)


@bot.event @bot.event
async def on_server_remove(guild): async def on_server_remove(guild):
fp.write("{}") fp.write("{}")


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

Loading…
Cancel
Save