robinroy03's picture
work?
a749a60
raw
history blame
2 kB
import discord
import os
import requests
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.")
if __name__ == "__main__":
import gradio as gr
def greet():
return "Hello"
demo = gr.Interface(
fn=greet,
inputs=[],
outputs=["text"],
)
demo.launch()
bot.run(token)