Guest User

messages

a guest
Jul 21st, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. import discord
  2. from googletrans import Translator,LANGCODES,LANGUAGES
  3. from colorama import *
  4.  
  5. init(autoreset=True)
  6.  
  7. INTENTS = discord.Intents.all()
  8.  
  9. class abot(discord.Bot):
  10.     def __init__(self,intents, activity):
  11.         super().__init__(intents=intents,activity=activity)
  12.         self.connected = False
  13.    
  14.     async def on_ready(self):
  15.         print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - {self.user}")
  16.         print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - Bot Is Online!")
  17.         await self.get_channel(LOG_CHANNEL).send("Bot Is Online!")
  18.         self.connected = True
  19.    
  20.     async def on_disconnect(self):
  21.         print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - Bot Disconnected!")
  22.         await self.get_channel(LOG_CHANNEL).send("Bot Disconnected!")
  23.    
  24.     async def on_resumed(self):
  25.         print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - Bot Connected!")
  26.         await self.get_channel(LOG_CHANNEL).send("Bot Connected!")
  27.  
  28. bot = abot(INTENTS,ACTIVITY)
  29.  
  30. @bot.event
  31. async def on_message(message):
  32.     senderID = message.author.id
  33.     if senderID != BOTID and message.author.bot == False:
  34.         if check_user_in_configs(str(senderID)):
  35.             if check_auto_translate_config(str(senderID)):
  36.                 print(message)
  37.                 print(message.content)
  38.                 content = message.content
  39.                 translator = Translator()
  40.                 language = translator.detect(content).lang
  41.                 print(language)
  42.                 if language != "en":
  43.                     translated = translator.translate(content).text
  44.                     await bot.get_channel(message.channel.id).send(f"Message by {message.author.name} translated\n{content}\n{translated}")
  45.  
  46. bot.loop.create_task(activityLoop())
  47. bot.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment