async def create_channel(self, ctx, id): """Create important proposal channels""" if not Admin._sender_is_effect_member(ctx): return if int(id) <= 0: return await ctx.send("id cannot be smaller than 1.", delete_after=3.0) else: proposal = self.eos.get_proposal(id=id)[0] self.eos.clear_proposal() title = "#{0} {1}".format(proposal['id'], proposal['title']) data = { "title": title, "description": proposal['description'], "url": proposal['url'], "footer_text": "Effect DAO", "body": { "Proposal id": proposal['id'], "Status": proposal['status'], "category": proposal['category_name'], "author": proposal['author'], "cycle": proposal['cycle'], "proposal costs": proposal['proposal_costs'].replace('EFX', '**EFX**'), } } # reformat title so that it matches channel title. channel = discord.utils.get(ctx.guild.text_channels, name=title.replace(' ', '-').replace( '#', '').lower()) if not channel: dao_member_role = discord.utils.get( ctx.guild.roles, id=ROLE_IDS['DISCORD_DAO_MEMBER_ID']) bot_role = discord.utils.get(ctx.guild.roles, id=ROLE_IDS['BOT_ID']) category = discord.utils.get(ctx.guild.categories, id=CATEGORY_IDS['DAO_PROPOSALS']) await category.set_permissions(dao_member_role, view_channel=True) await category.set_permissions(bot_role, view_channel=True) await category.set_permissions(ctx.guild.default_role, view_channel=False) channel = await ctx.guild.create_text_channel( title, category=category, sync_permissions=True) embed = create_embed(self, data) await channel.send(embed=embed) else: await ctx.trigger_typing() return await ctx.send('Channel already exists.')
async def account(self, ctx, account_name=None): """Get DAO stats for account""" account_name = get_account_name_from_context(self.db, ctx, account_name) if not account_name: return await ctx.send('No EOS account linked to {}'.format( ctx.author.display_name)) signed = self.eos.signed_constitution(account_name) if not signed: return await ctx.send( '{} did not sign the constitution!'.format(account_name)) efx_staked, nfx_staked, last_claim_age, last_claim_time = self.eos.get_staking_details( account_name) stake_age = self.eos.calculate_stake_age(last_claim_age, last_claim_time) efx_power = self.eos.calculate_efx_power(efx_staked, stake_age) vote_power = self.eos.calculate_vote_power(efx_power, nfx_staked) data = { "title": "Account details", "url": "https://dao.effect.network/account/{}".format(account_name), "footer_text": "Effect DAO", "body": { "DAO Account": account_name, "EFX staked": efx_staked, "NFX staked": nfx_staked, "Vote Power": vote_power } } embed = create_embed(self, data, inline=False) return await ctx.send(embed=embed)
async def find(self, ctx, id): """Get a proposal for a given id. You can find the id when running the `!proposals list` command""" if int(id) <= 0: await ctx.send("id cannot be smaller than 1.", delete_after=3.0) else: await ctx.trigger_typing() proposal = self.eos.get_proposal(id=id)[0] self.eos.clear_proposal() data = { "title": "**#{0}** {1}".format(proposal['id'], proposal['title']), "description": proposal['description'], "url": proposal['url'], "footer_text": "Effect DAO", "body": { "Proposal id": proposal['id'], "Status": proposal['status'], "category": proposal['category_name'], "author": proposal['author'], "cycle": proposal['cycle'], "proposal costs": proposal['proposal_costs'].replace('EFX', '**EFX**'), } } embed = create_embed(self, data) await ctx.send(embed=embed)
async def get_tokens(self, ctx, account): """Sending tokens from the faucet to account, which can be an Vaccount name or Vaccount address.""" if Admin._sender_is_effect_member(ctx): ctx.command.reset_cooldown(ctx) if ctx.channel.id == CHANNEL_IDS['DISCORD_FAUCET_CHANNEL']: vaccount, account_exists = self.eos.search_account(account) if account_exists is True: await ctx.trigger_typing() res = self.eos.transferTo(vaccount['id']) data = { "title": "Sent tokens to {}".format(vaccount['address'][1]), "url": "https://jungle3.bloks.io/transaction/{0}".format( res['transaction_id']), "footer_text": "Effect Hackathon", "body": { "transaction id": res['transaction_id'], "status": res['processed']['receipt']['status'], "memo": res['processed']['action_traces'][0]['act']['data'] ['memo'], "amount": res['processed']['action_traces'][0]['act']['data'] ['quantity']['quantity'].replace('EFX', '**EFX**'), } } embed = create_embed(self, data, inline=False) return await ctx.send(embed=embed) else: ctx.command.reset_cooldown(ctx) return await ctx.send( f"**{account}** does not exist. Have you registered your account on the effect account system?" ) else: ctx.command.reset_cooldown(ctx) return await ctx.send("Cannot use this command in this channel.")
async def cycle(self, ctx): """Show cycle stats, how long till the next cycle. etc.""" config = self.eos.get_config() cycle = self.eos.get_cycle(config['current_cycle'])[0] now = arrow.utcnow() started_at = arrow.get(cycle['start_time']) started_at_str = started_at.humanize( now, granularity=["day", "hour", "minute"]) started_at_dt = started_at.format("D MMMM YYYY HH:mm:ss ZZZ") ends_at = arrow.get(started_at.timestamp() + config['cycle_duration_sec']) ends_at_str = ends_at.humanize(now, granularity=["day", "hour", "minute"]) ends_at_dt = ends_at.format("D MMMM YYYY HH:mm:ss ZZZ") vote_duration = arrow.get(started_at.timestamp() + config['cycle_voting_duration_sec']) vote_duration_str = vote_duration.humanize( now, granularity=["day", "hour", "minute"]) vote_duration_dt = vote_duration.format("D MMMM YYYY HH:mm:ss ZZZ") data = { "title": "Cycle details", "url": "https://dao.effect.network/proposals", "footer_text": "Effect DAO", "body": { "Current cycle": config['current_cycle'], "Cycle start time": "{0}\n(**{1}**)".format(started_at_dt, started_at_str), "Cycle end time": "{0}\n(**{1}**)".format(ends_at_dt, ends_at_str), "Voting time": "{0}\n(**{1}**)".format(vote_duration_dt, vote_duration_str), "Budget": cycle['budget'][0]['quantity'].replace("EFX", "**EFX**"), } } embed = create_embed(self, data, inline=False) return await ctx.send(embed=embed)