-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain(OLD).py
More file actions
63 lines (45 loc) · 2.1 KB
/
main(OLD).py
File metadata and controls
63 lines (45 loc) · 2.1 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from dotenv import load_dotenv, set_key
from discord import Intents, Client
import inspect
import os
from discord.ext import commands
load_dotenv()
TOKEN = str(os.getenv("TOKEN"))
CHANNEL_ID = str(os.getenv("CHANNEL_ID"))
last_user_id = str(os.getenv("LAST_USER_ID"))
last_num = int(os.getenv("COUNT"))
class MyClient(Client):
def __init__(self, *, intents: Intents):
super().__init__(intents=intents)
async def on_message(self, message):
global last_num, last_user_id
print(f'Message from {message.author} in {message.channel}: {message.content}')
if str(message.channel.id) == CHANNEL_ID and str(message.author.id) != str(self.user.id):
if str(message.author.id) == last_user_id:
await message.channel.send(f"{message.author.mention} dej prostor taky ostatním!")
await message.delete()
else:
msg = message.content
try:
num = int(msg, 16)
except ValueError:
num = -1
if num == last_num+1:
await message.add_reaction("\U0001F44D")
last_num += 1
last_user_id = str(message.author.id)
set_key(".env", "LAST_USER_ID", last_user_id)
set_key(".env", "COUNT", str(last_num))
else:
await message.channel.send(f"Ajéje, {message.author.mention} to pokazil! Poslední bylo **{hex(last_num).split('x')[-1]}**, zvaž svoji odpověď.")
await message.delete()
async def on_ready():
print(inspect.cleandoc(f"""
Logged in as {client.user} (ID: {client.user.id})
Use this URL to invite {client.user} to your server:
https://discord.com/api/oauth2/authorize?client_id={client.user.id}&scope=applications.commands%20bot
"""), end="\n")
intents = Intents.default()
intents.message_content = True
client = MyClient(intents=intents, command_prefix="/")
client.run(TOKEN)