govisi commited on
Commit
9a5ae39
·
1 Parent(s): 311f1d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -19
app.py CHANGED
@@ -1,26 +1,35 @@
1
- # import os
2
- # # import pickle
3
- # import discord
 
4
 
5
- # intents = discord.Intents.default()
6
- # intents.message_content = True
7
 
8
- # client = discord.Client(intents=intents)
9
 
10
- # # model_pipe = pickle.load(open('pipe.pkl', 'rb'))
11
 
12
- # @client.event
13
- # async def on_ready():
14
- # print(f'We have logged in as {client.user}')
15
 
16
- # @client.event
17
- # async def on_message(message):
18
- # if message.author == client.user:
19
- # return
20
 
21
- # if message.content.startswith('$hello'):
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
- # client.run("MTA3NjU3MDc3MDYzMDc5MTIxOA.GvxRm6.Lm7ZDPwrkmz0AqrUxkxTRXKcObCzswDMfNpCIc")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()