Esempio n. 1
0
 def speak(self, channel: TextChannel, tts, volume: Optional[float]):
     try:
         temp_file = self.tts.synthesize_speech(tts)
         self.player.play_sound_now(temp_file, volume)
     except TTSAlreadyProcessingException:
         self.loop.create_task(
             channel.send("Cannot process multiple TTS's at the same time"))
     except TTSProcessException as e:
         self.loop.create_task(
             channel.send(
                 "Something went wrong with the TTS process. {}".format(e)))
Esempio n. 2
0
    def send_ok_embed(self,
                      channel: discord.TextChannel,
                      description: str = None,
                      title: str = "ОК"):
        embed = self.get_special_embed(0x6AAF6A, title=title)
        embed.description = description

        return channel.send(embed=embed)
Esempio n. 3
0
    def send_error_embed(self,
                         channel: discord.TextChannel,
                         description: str = None,
                         title: str = "Ошибка"):
        embed = self.get_special_embed(0xFF4C4C, title=title)
        embed.description = description

        return channel.send(embed=embed)
Esempio n. 4
0
 async def sticky(self,
                  ctx,
                  message,
                  channel: discord.TextChannel = None,
                  reply: discord.Message = None):
     if channel is None:
         channel = ctx.channel
     msg = channel.send(message, reference=reply, mention_author=False)
     self._add_sticky(msg)
Esempio n. 5
0
 def add_rift(self,
              source: discord.TextChannel,
              target: discord.TextChannel,
              notify: bool = True):
     self.data[str(target.id)] = {
         "source": source.id,
         "target": target.id,
         "notify": notify
     }
     self.save()
     if notify:
         self.bot.loop.create_task(
             target.send("\N{cinema} A rift has opened in this channel!"))
     return
Esempio n. 6
0
 async def save_pins(self, ctx, pins_channel: discord.TextChannel):
     """
     Send all the pins in the current channel to a dedicated pins channel!
     I currently don't support multiple attachments.
     Remember to use mb.deleteallpins after this!
     """
     bot_as_member = ctx.guild.get_member(self.bot.user.id)
     member_can_move_messages = pins_channel.permissions_for(
         ctx.message.author).send_messages
     bot_can_send_messages = pins_channel.permissions_for(
         bot_as_member).send_messages
     if not member_can_move_messages:
         await ctx.send("I'm not sure if you're allowed to do that, sorry!")
         return
     if not bot_can_send_messages:
         await ctx.send("I don't have permissions to send messages there!")
         return
     save_pin_futures = []
     for message in await ctx.channel.pins():
         just_copy_embed = (
             not message.content
             and not message.attachments
             and message.embeds)
         if just_copy_embed:
             pin_embed = message.embeds[0].copy()
         else:
             pin_embed_dict = {
                 "description": await util.clean(
                     ctx, message.content),
                 "footer": {"text": f"In {message.channel.name}"},
                 "author": {"name": message.author.name,
                            "icon_url": str(message.author.avatar_url)
                            },
                 "timestamp": message.created_at.isoformat()
             }
             if message.attachments:
                 pin_embed_dict["image"] = {
                     "url": message.attachments[0].url}
             pin_embed = discord.Embed.from_dict(pin_embed_dict)
         save_pin_futures.append(pins_channel.send(embed=pin_embed))
     await asyncio.gather(*save_pin_futures)
     await ctx.send("Done!")
Esempio n. 7
0
 def ping_target(self, channel: TextChannel):
     asyncio.ensure_future(
         channel.send(f"A bump is available %s!" %
                      self.bump_roles[channel.guild.id]),
         loop=self.loop,
     )