Example #1
0
async def removeRule(ctx, ruleNum):
    filePath = ExtFuncs.filePath(gid)
    with open(filePath.jsonPath, 'rt') as ruleDict:
        ruleDict = ruleDict
        subRuleDict = ruleDict.get('rules')

    if (ctx.author.name.lower() == os.environ["CHANNEL"] or ctx.author.is_mod == True):
        if (ruleNum in subRuleDict.keys()):
            writeRuleFile = open(filePath.jsonPath, "wt")
            subRuleDict.pop(ruleNum)
            ruleDict.update({'rules': subRuleDict})
            writeRuleFile.write(json.dumps(ruleDict, indent=2))
            await ctx.send("The rule with ID " + ruleNum + " has been successfully removed.")
            writeRuleFile.close()
        else:
            await ctx.send(f'The rule {str(ruleNum)} could not be found in the rule list.')
    else:
        await ctx.send("@" + ctx.author.name + " You don't have the permissions to use this command!")
Example #2
0
async def addRule(ctx, *rule):
    rule = str(" ".join(rule[:]))
    filePath = ExtFuncs.filePath(gid)
    with open(filePath.jsonPath, "rt") as ruleDict:
        ruleDict = ruleDict
        subRuleDict = ruleDict.get('rules')
    writeRuleFile = open(filePath.jsonPath, 'wt')

    if (ctx.author.name.lower() == os.environ["CHANNEL"] or ctx.author.is_mod == True):
        sortKeys = sorted(subRuleDict.keys())
        try:
            newKey = int(sortKeys[-1]) + 1
        except:
            newKey = 1
        subRuleDict.update({str(newKey): rule})
        ruleDict.update({'rules': subRuleDict})
        writeRuleFile.write(json.dumps(ruleDict, indent=2))
        await ctx.send("The rule, " + '"' + str(rule) + '"' + " with the ID of " + str(newKey) + " has been successfully added to the rules list.")
    else:
        await ctx.send("@" + ctx.author.name + " You don't have the permissions to use this command!")
    writeRuleFile.close()
Example #3
0
    async def setStreamAnnounceChannel(self, ctx, channelId=None):
        filePath = util.filePath(ctx.guild.id)
        dcBackend = None
        with open(filePath.jsonPath, 'rt') as readGuildVarsFile:
            readGuildVars = json.loads(readGuildVarsFile.read())
            dcBackend = readGuildVars.get('DiscordBackend')
        print(type(channelId))
        if channelId == None:
            channelId = int(ctx.channel.id)
#        elif isinstance(channelId, str):
#            try:
#                channelId = ctx.guildchannelId.id
        else:
            try:
                channelId = int(channelId)
            except:
                await ctx.send('Invalid channel or channel ID.')
                return
        dcBackend.update({"streamAnnouncementChannel": channelId})
        readGuildVars.update({'DiscordBackend': dcBackend})
        with open(filePath.jsonPath, 'wt') as writeVarsFile:
            writeVarsFile.write(json.dumps(readGuildVars, indent=2))
        await ctx.send(f'Successfully set {ctx.guild.get_channel(channelId).mention} as the stream announcement channel.')
Example #4
0
 def getChannel(self):
     getGlob = util.globalVars()
     return getGlob.streamers.get(str(self.guildId))
Example #5
0
async def event_message_log(ctx):
    if ctx.guild != None:
        logPath = pathlib.Path(varPath / str(ctx.guild.id) / 'logs')
    else:
        logPath = pathlib.Path('logs/Discord')
    ExtFuncs.log(logPath, logNameVar, ctx.author, ctx.channel, ctx.content)
Example #6
0
 def __init__(self, gid):
     self.gid = gid
     self.varFile = ExtFuncs.filePath(gid)
     self.twitchData = self.varFile.twitchData
     self.guildData = self.varFile.jsonData
     self.customComs = self.varFile.twitchData.get('CustomComs')
Example #7
0
async def whatimiss(ctx):
    msg = ExtFuncs.filePath(gid).twitchData.get('missTxt')
    await ctx.send("@" + ctx.author.name + " While you were gone, " + msg)