async def set(self, ctx): """Edit your information""" await self.delete(ctx.message) if ctx.invoked_subcommand is not None: return description = ( f"**NOTE**: _You have to register first with_ `{self.p}register`" if repo_u.get(ctx.author.id) is None else "" ) # fmt: off embed = self.get_embed( title="Wormhole: **set**", description=description, ) embed.add_field( name="Set home wormhole", value=f"**{self.p}set home**", inline=False, ) embed.add_field( name="Set new nickname", value=f"**{self.p}set name [new name]**", inline=False ) # fmt: on await ctx.send(embed=embed, delete_after=self.delay())
async def me(self, ctx): """See your information""" await self.delete(ctx.message) db_u = repo_u.get(ctx.author.id) if db_u is None: return await ctx.author.send("You are not registered.") await self.display_user_info(ctx, db_u)
async def settings(self, ctx: commands.Context): """Display settings for current beam""" db_w = repo_w.get(ctx.channel.id) db_b = repo_b.get(db_w.beam) db_u = repo_u.get(ctx.author.id) msg = ">>> **Settings**:\n" # beam settings pars = [] # fmt: off pars.append("active" if db_b.active else "inactive") pars.append(f"replacing (timeout **{db_b.timeout} s**)" if db_b. replace else "not replacing") pars.append(f"anonymity level **{db_b.anonymity}**") # fmt: on msg += ", ".join(pars) # wormhole settings pars = [] if db_w.active is False: pars.append("inactive") if db_w.readonly is True: pars.append("read only") if len(pars) > 0: msg += "\n**Wormhole overrides**:\n" msg += ", ".join(pars) # user settings if db_u is not None and db_u.readonly is True: msg += "\n**User overrides**:\n" msg += "read only" await ctx.send(msg, delete_after=self.delay())
def _get_prefix(self, message: discord.Message, first_line: bool = True): """Get prefix for message""" db_w = repo_w.get(message.channel.id) db_b = repo_b.get(db_w.beam) db_u = repo_u.get(message.author.id) # get user nickname if db_u is not None: if db_b.name in db_u.home_ids: # user has home wormhole home = repo_w.get(db_u.home_ids[db_b.name]) else: # user is registered without home home = None if home is not None: name = "__" + db_u.nickname + "__" else: name = db_u.nickname else: name = self.sanitise(message.author.name, limit=32) home = db_w # get logo if hasattr(home, "logo") and len(home.logo): if first_line: logo = home.logo else: logo = config["logo fill"] else: logo = self.sanitise(message.guild.name) # get prefix if db_b.anonymity == "none": # display everything prefix = f"{logo} **{name}**: " elif db_b.anonymity == "guild" and len(logo): # display guild logo prefix = logo + " " elif db_b.anonymity == "guild" and len(logo) == 0: # display guild name prefix = f"{logo}, **{name}**" else: # wrong configuration or full anonymity prefix = "" return prefix
async def help(self, ctx: commands.Context): """Display help""" embed = self.get_embed(ctx=ctx, title="User commands") p = config["prefix"] # fmt: off embed.add_field(name=f"**{p}e** | **{p}edit**", value="Edit last message") embed.add_field(name=f"**{p}d** | **{p}delete**", value="Delete last message") embed.add_field(name=f"**{p}info**", value="Connection information") embed.add_field(name=f"**{p}settings**", value="Display current settings") embed.add_field(name=f"**{p}link**", value="Link to GitHub repository") embed.add_field(name=f"**{p}invite**", value="Bot invite link") db_u = repo_u.get(ctx.author.id) if "User" in self.bot.cogs and db_u is None: embed.add_field(name=f"**{p}register**", value="Register your username") embed.add_field(name=f"**{p}whois**", value="Get information about user") if "User" in self.bot.cogs and db_u is not None: embed.add_field(name=f"**{p}me**", value="Display your information") embed.add_field(name=f"**{p}whois**", value="Get information about user") embed.add_field(name=f"**{p}set**", value="Edit nickname or home") if "User" in self.bot.cogs: embed.add_field(name=f"{p}invites", value="Invite links to wormhole channels", inline=False) embed.add_field( name="Online help", value="https://sinus-x.github.io/discord-wormhole/commands", inline=False) # fmt: on if hasattr(ctx.channel, "id"): # we are in public channel await ctx.send(embed=embed, delete_after=self.delay()) else: # private channel, we can keep the message await ctx.send(embed=embed) await self.delete(ctx.message)