def get_sendable_data(self, ctx: commands.Context): """Send a valid embed to the destination""" ctx.invoke_meta = True # Create embed embed = discord.Embed() lines = [] emoji_list = [] index = 0 for index, i in enumerate(self.items): emoji = i.emoji if emoji is None: emoji = f"{index}\N{COMBINING ENCLOSING KEYCAP}" index += 1 display = i.get_display() if display: lines.append(f"{emoji} {i.get_display()}") self.emoji_options[emoji] = i emoji_list.append(emoji) # Finish embed text_lines = '\n'.join(lines) embed.description = text_lines or "No set data" # Add tick self.emoji_options[self.TICK_EMOJI] = None emoji_list.append(self.TICK_EMOJI) # Return data return {'embed': embed}, emoji_list
def get_sendable_data( self, ctx: commands.Context) -> typing.Tuple[dict, typing.List[str]]: """ Get a valid set of sendable data for the destination. Args: ctx (commands.Context): Just so we can set the invoke meta flag. Returns: typing.Tuple[dict, typing.List[str]]: A tuple of the sendable data for the destination that can be unpacked into a `discord.abc.Messageable.send`, and a list of emoji to add to the message in question. """ ctx.invoke_meta = True # Create embed embed = discord.Embed() lines = [] emoji_list = [] index = 0 for index, i in enumerate(self.options): emoji = i.emoji if emoji is None: emoji = f"{index}" index += 1 display = i.get_display() if display: lines.append(f"{emoji}) {i.get_display()}") self.emoji_options[emoji] = i emoji_list.append(emoji) # Finish embed text_lines = '\n'.join(lines) embed.description = text_lines or "No set data" # Add tick self.emoji_options[self.TICK_EMOJI] = None emoji_list.append(self.TICK_EMOJI) buttons = [ discord.ui.Button(emoji=i, custom_id=i) for i in emoji_list ] + [ discord.ui.Button(label="Done", custom_id="done", style=discord.ui.ButtonStyle.sucess) ] components = discord.ui.MessageComponents.add_buttons_with_rows( *buttons) # Return data return {'embed': embed, "components": components}, emoji_list
def get_sendable_data( self, ctx: commands.Context) -> typing.Tuple[dict, typing.List[str]]: """ Get a valid set of sendable data for the destination. Args: ctx (commands.Context): Just so we can set the invoke meta flag. Returns: typing.Tuple[dict, typing.List[str]]: A tuple of the sendable data for the destination that can be unpacked into a `discord.abc.Messageable.send`, and a list of emoji to add to the message in question. """ ctx.invoke_meta = True # Create embed embed = discord.Embed() lines = [] emoji_list = [] index = 0 for index, i in enumerate(self.options): emoji = i.emoji if emoji is None: emoji = f"{index}\N{COMBINING ENCLOSING KEYCAP}" index += 1 display = i.get_display() if display: lines.append(f"{emoji} {i.get_display()}") self.emoji_options[emoji] = i emoji_list.append(emoji) # Finish embed text_lines = '\n'.join(lines) embed.description = text_lines or "No set data" # Add tick self.emoji_options[self.TICK_EMOJI] = None emoji_list.append(self.TICK_EMOJI) # Return data return {'embed': embed}, emoji_list
def get_sendable_data(self, ctx:commands.Context): """Get a valid set of sendable data for the destination Returns: Two arguments - a dict that is passed directly into a `.send`, and a list of emoji that should be added to that message """ ctx.invoke_meta = True # Create embed embed = discord.Embed() lines = [] emoji_list = [] index = 0 for index, i in enumerate(self.options): emoji = i.emoji if emoji is None: emoji = f"{index}\N{COMBINING ENCLOSING KEYCAP}" index += 1 display = i.get_display() if display: lines.append(f"{emoji} {i.get_display()}") self.emoji_options[emoji] = i emoji_list.append(emoji) # Finish embed text_lines = '\n'.join(lines) embed.description = text_lines or "No set data" # Add tick self.emoji_options[self.TICK_EMOJI] = None emoji_list.append(self.TICK_EMOJI) # Return data return {'embed': embed}, emoji_list