-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import discord | ||
import dotenv | ||
import os | ||
from discord.ext import commands | ||
from dotenv import load_dotenv | ||
import openai | ||
|
||
load_dotenv() | ||
|
||
intents = discord.Intents.default() | ||
intents.message_content = True | ||
|
||
bot = commands.Bot(command_prefix='!', intents=intents); | ||
|
||
|
||
openai.api_key = os.getenv('apikey') | ||
|
||
|
||
|
||
@bot.event | ||
async def on_ready(): | ||
await bot.change_presence(activity=discord.Streaming(name='OpenApi', url='https://www.twitch.tv/hoodie4546')) | ||
print(f'Bot Status is Spiced up ! {bot.user.name}') | ||
print(f"{bot.user.name} is Ready For Ai Chating!") | ||
print(f"{bot.user.name} is connected to Open Ai Api!") | ||
|
||
|
||
|
||
@bot.event | ||
async def on_message(message): | ||
if message.channel.id == 1113365746219749477 and not message.author.bot: | ||
response = openai.Completion.create( | ||
engine='text-davinci-003', | ||
prompt=message.content, | ||
temperature=0.7, | ||
max_tokens=50 | ||
) | ||
await message.channel.send(response.choices[0].text) | ||
|
||
|
||
bot.run(os.getenv('Token')) |