def get_owner_pi(context): """Get the user who has been previously set as the owner of this item (must support IOwned i.e. Doc or Attachment). """ assert interfaces.IOwned.providedBy(context), \ "Not an Owned (parliamentary) Item: %s" % (context) return dbutils.get_user(context.owner_id)
def get_owner_login_pi(context): """Get the login of the user who has been previously set as the owner of this ParliamentaryItem. """ assert interfaces.IBungeniContent.providedBy(context), \ "Not a Parliamentary Item: %s" % (context) return dbutils.get_user(context.owner_id).login
def get_owner_pi(context): """Get the user who has been previously set as the owner of this item (must support IOwned i.e. ParliamentaryItem or AttachedFile). """ assert interfaces.IOwned.providedBy(context), \ "Not an Owned (parliamentary) Item: %s" % (context) return dbutils.get_user(context.owner_id)
async def balance(self, ctx, id=None): """ Returns the Users Exact Balance in the Vault """ await ctx.message.delete() sender = None message = None if ctx.message.author.nick is None: sender = ctx.message.author.name else: sender = ctx.message.author.nick senderid = get_torn_id(sender) sender = remove_torn_id(sender) if dbutils.get_user(ctx.message.author.id, "tornid") == "": verification = await tornget( ctx, f'https://api.torn.com/user/{senderid}?selections=discord&key=' ) if verification["discord"]["discordID"] != str(ctx.message.author.id) and \ verification["discord"]["discordID"] != "": embed = discord.Embed() embed.title = "Permission Denied" embed.description = f'The nickname of {ctx.message.author.name} in {ctx.guild.name} does not reflect ' \ f'the Torn ID and username. Please update the nickname (i.e. through YATA) or add' \ f' your ID to the database via the `?addid` or `addkey` commands (NOTE: the ' \ f'`?addkey` command requires your Torn API key). This interaction has been logged.' await ctx.send(embed=embed) log( f'{ctx.message.author.id} does not have an accurate nickname, and attempted to withdraw' f' some money from the faction vault.', self.access_file) return None log(f'{sender} is checking their balance in their faction vault.') response = await tornget( ctx, "https://api.torn.com/faction/?selections=donataions&key=") response = response["donations"] primary_balance = 0 secondary_balance = 0 member = False for user in response: if response[user]["name"] == sender: log(f'{sender} has {num_to_text(response[user]["money_balance"])} in the faction vault.' ) primary_balance = response[user]["money_balance"] member = True break if dbutils.get_guild(ctx.guild.id, "tornapikey2") == "": embed = discord.Embed() embed.title = f'Vault Balance for {sender}' embed.description = f'Faction Vault Balance: {commas(primary_balance)}' message = await ctx.send(embed=embed) await asyncio.sleep(30) await message.delete() return None response = await tornget( ctx, "https://api.torn.com/faction/?selections=donations&key=", guildkey=2) response = response['donations'] for user in response: if response[user]["name"] == sender: log(f'{sender} has {num_to_text(response[user]["money_balance"])} in the faction vault.' ) secondary_balance = response[user]["money_balance"] member = True if member is not True: log(f'{sender} who is not a member of any of the stored factions, has requested their balance.' ) embed = discord.Embed() embed.title = "Vault Balance for " + sender embed.description = f'{sender} is not a member of any of the stored factions.' message = await ctx.send(embed=embed) await asyncio.sleep(30) await message.delete() else: embed = discord.Embed() embed.title = f'Vault Balance for {sender}' embed.description = f'Primary Faction Vault Balance: {commas(primary_balance)}\nSecondary '\ f'faction vault balance: {commas(secondary_balance)}' message = await ctx.send(embed=embed) await asyncio.sleep(30) await message.delete()
async def withdraw(self, ctx, arg): ''' Sends a message to faction leadership (assuming you have enough funds in the vault and you are a member of the specific faction) ''' # sender = None if ctx.message.author.nick is None: sender = ctx.message.author.name else: sender = ctx.message.author.nick senderid = get_torn_id(sender) sender = remove_torn_id(sender) if dbutils.get_user(ctx.message.author.id, "tornid") == "": verification = await tornget( ctx, f'https://api.torn.com/user/{senderid}?selections=discord&key=' ) if verification["discord"]["discordID"] != str(ctx.message.author.id) and \ verification["discord"]["discordID"] != "": embed = discord.Embed() embed.title = "Permission Denied" embed.description = f'The nickname of {ctx.message.author.nick} in {ctx.guild.name} does not reflect ' \ f'the Torn ID and username. Please update the nickname (i.e. through YATA) or add' \ f' your ID to the database via the `?addid` or `addkey` commands (NOTE: the ' \ f'`?addkey` command requires your Torn API key). This interaction has been logged.' await ctx.send(embed=embed) log( f'{ctx.message.author.id} (known as {ctx.message.author.name} does not have an accurate nickname, ' f'and attempted to withdraw some money from the faction vault.', self.access_file) return None value = text_to_num(arg) log(sender + " has submitted a request for " + arg + ".", self.log_file) primary_faction = await tornget( ctx, "https://api.torn.com/faction/?selections=&key=") secondary_faction = None if dbutils.get_guild(ctx.guild.id, "tornapikey2") != "": secondary_faction = await tornget( ctx, "https://api.torn.com/faction/?selections=&key=", guildkey=2) await ctx.message.delete() if senderid in primary_faction["members"]: request = await tornget( ctx, "https://api.torn.com/faction/?selections=donations&key=") request = request["donations"] if int(value) > request[senderid]["money_balance"]: log( f'{sender} has requested {arg}, but only has {request[senderid]["money_balance"]} in ' f'the vault.', self.log_file) await ctx.send(f'You do not have {arg} in the faction vault.') return None else: channel = discord.utils.get(ctx.guild.channels, name=dbutils.get_vault( ctx.guild.id, "channel")) log( f'{sender} has successfully requested {arg} from the faction vault.', self.log_file) requestid = dbutils.read("requests")["nextrequest"] embed = discord.Embed() embed.title = f'Money Request #{dbutils.read("requests")["nextrequest"]}' embed.description = "Your request has been forwarded to the faction leadership." original = await ctx.send(embed=embed) embed = discord.Embed() embed.title = f'Money Request #{dbutils.read("requests")["nextrequest"]}' embed.description = f'{sender} is requesting {arg} from the faction vault. To fulfill this request, ' \ f'enter `?f {requestid}` in this channel.' message = await channel.send(dbutils.get_vault( ctx.guild.id, "role"), embed=embed) data = dbutils.read("requests") data["nextrequest"] += 1 data[requestid] = { "requester": ctx.message.author.id, "timerequested": time.ctime(), "fulfiller": None, "timefulfilled": "", "requestmessage": original.id, "withdrawmessage": message.id, "fulfilled": False, "faction": 1 } dbutils.write("requests", data) elif senderid in secondary_faction["members"]: request = await tornget( ctx, "https://api.torn.com/faction?selections=donations&key=", guildkey=2) request = request["donations"] if int(value) > request[senderid]["money_balance"]: log( f'{sender} has requested {arg}, but only has {request[senderid]["money_balance"]} in ' f'the vault.', self.log_file) await ctx.send(f'You do not have {arg} in the faction vault.') return None else: channel = discord.utils.get(ctx.guild.channels, name=dbutils.get_vault( ctx.guild.id, "channel2")) log( f'{sender} has successfully requested {arg} from the faction vault.', self.log_file) requestid = dbutils.read("requests")["nextrequest"] embed = discord.Embed() embed.title = f'Money Request #{dbutils.read("requests")["nextrequest"]}' embed.description = "Your request has been forwarded to the faction leadership." original = await ctx.send(embed=embed) embed = discord.Embed() embed.title = f'Money Request #{dbutils.read("requests")["nextrequest"]}' embed.description = f'{sender} is requesting {arg} from the faction vault. To fulfill this request, ' \ f'enter `?f {requestid}` in this channel.' message = await channel.send(dbutils.get_vault( ctx.guild.id, "role"), embed=embed) data = dbutils.read("requests") data["nextrequest"] += 1 data[requestid] = { "requester": ctx.message.author.id, "timerequested": time.ctime(), "fulfiller": None, "timefulfilled": "", "requestmessage": original.id, "withdrawmessage": message.id, "fulfilled": False, "faction": 2 } dbutils.write("requests", data) else: log( f'{sender} who is not a member of stored factions has requested {arg}.', self.log_file) embed = discord.Embed() embed.title = "Money Request" embed.description = f'{sender} is not a member of stored factions has requested {arg}.' await ctx.send(embed=embed) return None