This commit is contained in:
@@ -13,26 +13,40 @@ intents.messages = True
|
||||
intents.message_content = True
|
||||
client = discord.Client(intents=intents)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(f"Logged in as {client.user.name} running {model}.", flush=True)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
if message.author == client.user:
|
||||
return
|
||||
if message.content.lower().startswith("hey money") or isinstance(message.channel, discord.DMChannel):
|
||||
question = message.content[9:] if message.content.lower().startswith("hey money") else message.content
|
||||
if message.content.lower().startswith("hey money") or isinstance(
|
||||
message.channel, discord.DMChannel
|
||||
):
|
||||
question = (
|
||||
message.content[9:]
|
||||
if message.content.lower().startswith("hey money")
|
||||
else message.content
|
||||
)
|
||||
try:
|
||||
response = openai.ChatCompletion.create(
|
||||
model=model,
|
||||
messages=[
|
||||
{"role": "system", "content": "Pretend you are eccentric conspiracy theorist Planetside 2 gamer named Dr. Moneypants."},
|
||||
{"role": "user", "content": f"{question} please keep it short with religious undertones"}
|
||||
],
|
||||
max_tokens=400
|
||||
{
|
||||
"role": "system",
|
||||
"content": "Pretend you are eccentric conspiracy theorist Planetside 2 gamer named Dr. Moneypants.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"{question} please keep it short with religious undertones",
|
||||
},
|
||||
],
|
||||
max_tokens=400,
|
||||
)
|
||||
answer = response['choices'][0]['message']['content']
|
||||
answer = response["choices"][0]["message"]["content"]
|
||||
answer = answer.replace("an AI language model", "a man of God")
|
||||
answer = answer.replace("language model AI", "man of God")
|
||||
await message.channel.send(answer)
|
||||
@@ -40,14 +54,16 @@ async def on_message(message):
|
||||
e = str(e)
|
||||
await message.channel.send(f"`MoneyBot Error: {e}`")
|
||||
|
||||
|
||||
async def moneybot_connect():
|
||||
while True:
|
||||
try:
|
||||
await client.start(moneykey)
|
||||
except Exception as e:
|
||||
e = str(e)
|
||||
logger.error(f"Moneybot couldn't connect! {e}")
|
||||
await asyncio.sleep(60)
|
||||
e = str(e)
|
||||
logger.error(f"Moneybot couldn't connect! {e}")
|
||||
await asyncio.sleep(60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(moneybot_connect())
|
||||
|
||||
Reference in New Issue
Block a user