Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from googletrans import Translator,LANGCODES,LANGUAGES
- from colorama import *
- init(autoreset=True)
- INTENTS = discord.Intents.all()
- class abot(discord.Bot):
- def __init__(self,intents, activity):
- super().__init__(intents=intents,activity=activity)
- self.connected = False
- async def on_ready(self):
- print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - {self.user}")
- print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - Bot Is Online!")
- await self.get_channel(LOG_CHANNEL).send("Bot Is Online!")
- self.connected = True
- async def on_disconnect(self):
- print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - Bot Disconnected!")
- await self.get_channel(LOG_CHANNEL).send("Bot Disconnected!")
- async def on_resumed(self):
- print(f"[{Fore.GREEN}LOG{Fore.RESET}]{Fore.MAGENTA}Bot{Fore.RESET} - Bot Connected!")
- await self.get_channel(LOG_CHANNEL).send("Bot Connected!")
- bot = abot(INTENTS,ACTIVITY)
- @bot.event
- async def on_message(message):
- senderID = message.author.id
- if senderID != BOTID and message.author.bot == False:
- if check_user_in_configs(str(senderID)):
- if check_auto_translate_config(str(senderID)):
- print(message)
- print(message.content)
- content = message.content
- translator = Translator()
- language = translator.detect(content).lang
- print(language)
- if language != "en":
- translated = translator.translate(content).text
- await bot.get_channel(message.channel.id).send(f"Message by {message.author.name} translated\n{content}\n{translated}")
- bot.loop.create_task(activityLoop())
- bot.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment