Skip to content

Commit 24a591e

Browse files
authored
Adds some silly presence messages (cheran-senthil#178)
* Adding silly presence behavior * Change durations * Make fixes * Use displayname, and use random activity
1 parent 15fe78f commit 24a591e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tle/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import argparse
23
import logging
34
import os
@@ -69,6 +70,7 @@ def no_dm_check(ctx):
6970
@bot.event
7071
async def on_ready():
7172
await cf_common.initialize(args.nodb)
73+
asyncio.create_task(discord_common.presence(bot))
7274

7375
bot.add_listener(discord_common.bot_error_handler, name='on_command_error')
7476

tle/util/discord_common.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import logging
23
import random
34

@@ -54,3 +55,19 @@ async def bot_error_handler(ctx, exception):
5455
else:
5556
exc_info = type(exception), exception, exception.__traceback__
5657
logger.exception('Ignoring exception in command {}:'.format(ctx.command), exc_info=exc_info)
58+
59+
60+
async def presence(bot):
61+
await bot.change_presence(activity=discord.Activity(
62+
type=discord.ActivityType(random.randint(0,3)),
63+
name="and ready for input"))
64+
await asyncio.sleep(60)
65+
while True:
66+
target = random.choice([
67+
member for member in bot.get_all_members()
68+
if 'Purgatory' not in {role.name for role in member.roles}
69+
])
70+
await bot.change_presence(activity=discord.Activity(
71+
type=discord.ActivityType(random.randint(0,3)),
72+
name=f'{target.display_name} orz'))
73+
await asyncio.sleep(10 * 60)

0 commit comments

Comments
 (0)