forked from UnobjectiveRyan/JakeBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (41 loc) · 1.55 KB
/
main.py
File metadata and controls
53 lines (41 loc) · 1.55 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
import discord
from discord.ext import commands
import logging
from dotenv import load_dotenv
import os
import random
load_dotenv()
token = os.getenv('DISCORD_TOKEN')
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
intents.presences = True
bot = commands.Bot(command_prefix='/', intents=intents)
@bot.event
async def on_ready():
print(f'We have logged in as {bot.user} and want to die')
@bot.event
async def on_member_join(member):
await member.send(f'Great another one, hi {member.name}...')
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if 'jakebot' in message.content.lower():
await message.delete()
await message.channel.send(f"{message.author.mention} piss off.")
await bot.process_commands(message)
#CS ping
@bot.event
async def on_presence_update(before, after):
cs2_app_id = 730
channel_id = 1
# Check if the member started playing CS2
before_games = {a.application_id for a in before.activities if hasattr(a, 'application_id')}
after_games = {a.application_id for a in after.activities if hasattr(a, 'application_id')}
if cs2_app_id in after_games and cs2_app_id not in before_games:
channel = bot.get_channel(channel_id)
if channel:
await channel.send(f"{after.display_name} just booted up CS2 again")
bot.run(token, log_handler=handler, log_level=logging.DEBUG)