import discord import os import requests import threading intents = discord.Intents.default() intents.message_content = True bot = discord.Bot(intents = intents) token = os.environ.get('TOKEN_DISCORD') class Like_Dislike(discord.ui.View): @discord.ui.button(style=discord.ButtonStyle.primary, emoji="👍") async def like_button(self, button, interaction): await interaction.response.send_message("You liked the response") @discord.ui.button(style=discord.ButtonStyle.primary, emoji="👎") async def dislike_button(self, button, interaction): await interaction.response.send_message("You disliked the response") @bot.event async def on_ready(): print(f"{bot.user} is ready and online!") @bot.slash_command(name="help", description="list of commands and other info.") async def help(ctx: discord.ApplicationContext): await ctx.respond("Hello! FURY Bot responds to all your messages\ \n1)Inside Forum channel and\ \n2)Those that tag the bot.") @bot.event async def on_message(message): url = 'http://127.0.0.1:8000/completion' obj = {'user': message.author.id, 'text': message.content.replace("<@1243428204124045385>", "")} if (message.author != bot.user) and (bot.user.mentioned_in(message)): await message.reply(content="Your message was received, it'll take around 10 seconds for FURY to process an answer.") try: return_obj = requests.post(url, json=obj) print(return_obj.text) await message.reply(content=return_obj.text, view=Like_Dislike()) except requests.exceptions.RequestException as e: print(e) await message.reply(content="Sorry something internally went wrong. Retry again.") def run_bot(): bot.run(token) threading.Thread(target=run_bot).start() # ------------------------------------------------------------------------------------------------------------------------------ import gradio as gr demo = gr.Blocks() with demo: gr.HTML("The bot is working..") demo.queue().launch()