Last active
February 3, 2022 21:21
-
-
Save Sanokei/f7e453c7c0e31822714269283cf1ba54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from discord.ext import commands | |
import asyncio | |
import time | |
import datetime | |
import json | |
import os | |
# Loads the config file | |
with open('config.json') as config_file: | |
config = json.load(config_file) | |
# Sets the bot token | |
TOKEN = config['token'] | |
# Sets the bot prefix | |
client = commands.Bot(command_prefix = '!') | |
# Sets the bot status | |
@client.event | |
async def on_ready(): | |
print('Bot is ready.') | |
await client.change_presence(activity=discord.Game(name='League of Legends')) | |
# Bans users who have been playing for at least 30 minutes | |
@client.event | |
async def on_member_update(before, after): | |
if before.activity == None: | |
return | |
elif before.activity.name == 'League of Legends': | |
if (datetime.datetime.utcnow() - before.activity.start_time).total_seconds() >= 1800: | |
await after.ban(reason='Genuinely Kill Yourself... NOW') | |
# Runs the bot | |
client.run(TOKEN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment