Nameerror system is not defined

时间:2019-05-31 11:55:14

标签: python discord.py-rewrite

This is what I get while I have already defined system:

NameError: name 'system' is not defined

I am making a cog for a bot in Discord and this just pops up.

I tried changing the values of system and also referred to many programs.

My code:

import asyncio
import discord
from discord.ext import commands
from .utils import checks
from .utils.dataIO import dataIO
from __main__ import send_cmd_help

class donate:

    def __init__(self, bot):
        self.bot = bot
        self.file_path = "data/donate/donate.json"
        self.config = dataIO.load_json(self.file_path)
        self.system = {}

    @commands.group(pass_context=True, no_pm=True)
    async def setdonate(self, ctx):
        """Used To Set donate info"""

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)

        def save_system(self):
            dataIO.save_json(self.file_path, self.system)

    def check_server(self, server):
        if server.id in self.system:
            return self.system[server.id]
        else:
            self.system[server.id]  = {
                    "Title": "Help Support My Server",
                    "Text": ":point_right:Donate money:point_left:",
                    "Link": "**********",
                    "Colour": "Green",
                }
            return self.system[server.id]

    @commands.command()
    async def donate(self):
        """Donate message"""


def check_folders():
    if not os.path.exists('data/donate'):
        print("Creating data/donate folder...")
        os.makedirs('data/donate')

def check_files():
    system = {"Servers": {}}

    f = "data/donate/donate.json"

    if not dataIO.is_valid_json(f):
        print("Adding donate.json to data/donate/")
        dataIO.save_json(f, system)

def setup(bot):
    bot.add_cog(donate(bot))

The error I get:

  File "/home/pokemonfanscool/Red-DiscordBot/cogs/donate.py", line 14, in <module>
    class donate:
  File "/home/pokemonfanscool/Red-DiscordBot/cogs/donate.py", line 85, in donate
    dataIO.save_json(f, system)
NameError: name 'system' is not defined

0 个答案:

没有答案