-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (31 loc) · 867 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import discord
import openai
import keep_alive # A 24/7 module
from discord.ext import commands
description = '''Discord bot'''
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
# NEED A API KEY
openai.api_key = TOKEN
bot = commands.Bot(command_prefix='!', description=description, intents=intents) # Replace "!" for you fav prefix
@bot.event
async def on_ready():
print("Bot online")
#Chat gpt
@bot.command()
async def chatgpt(ctx, *, text):
await ctx.send(f'Cargando resultados de: "{text}"')
pedido = openai.Completion.create(
engine="text-davinci-003",
prompt=f"{text}",
max_tokens=2000,
temperature=0.5,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
resultado = pedido["choices"][0]["text"]
await ctx.send(resultado)
keep_alive.keep_alive()
bot.run(TOKEN)