Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,35 @@
|
|
1 |
-
|
2 |
-
#
|
3 |
-
|
|
|
4 |
|
5 |
-
|
6 |
-
# intents.message_content = True
|
7 |
|
8 |
-
|
9 |
|
10 |
-
|
11 |
|
12 |
-
# @client.event
|
13 |
-
# async def on_ready():
|
14 |
-
# print(f'We have logged in as {client.user}')
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
# if message.author == client.user:
|
19 |
-
# return
|
20 |
|
21 |
-
|
22 |
-
# print(message.content)
|
23 |
-
# # await message.channel.send(model_pipe.predict([message.content]))
|
24 |
-
# await message.channel.send('Hello from hugging face')
|
25 |
|
26 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os, asyncio
|
2 |
+
# import pickle
|
3 |
+
import discord
|
4 |
+
from discord.ext import commands
|
5 |
|
6 |
+
from threading import Thread
|
|
|
7 |
|
8 |
+
lock = asyncio.Lock()
|
9 |
|
10 |
+
bot = commands.Bot("", intents=discord.Intents(messages=True, guilds=True))
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
+
intents = discord.Intents.default()
|
14 |
+
intents.message_content = True
|
|
|
|
|
15 |
|
16 |
+
client = discord.Client(intents=intents)
|
|
|
|
|
|
|
17 |
|
18 |
+
# model_pipe = pickle.load(open('pipe.pkl', 'rb'))
|
19 |
+
|
20 |
+
@bot.event
|
21 |
+
async def on_ready():
|
22 |
+
print(f'We have logged in as {bot.user}')
|
23 |
+
|
24 |
+
@bot.event
|
25 |
+
async def on_message(message: discord.Message):
|
26 |
+
if message.author == bot.user:
|
27 |
+
return
|
28 |
+
|
29 |
+
if message.content and message.content.startswith('$hello'):
|
30 |
+
# print(message.content)
|
31 |
+
# await message.channel.send(model_pipe.predict([message.content]))
|
32 |
+
await message.channel.send('Hello from hugging face')
|
33 |
+
|
34 |
+
t = Thread(target=bot.run, daemon=True, args=(os.getenv("discord_token"), ))
|
35 |
+
t.start()
|