-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathplaying_status.py
40 lines (27 loc) · 943 Bytes
/
playing_status.py
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
import logging
import discord
from discord.ext import commands
import settings
logger = logging.getLogger(__name__)
def run():
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
async def update_presence():
total_member_count = 0
for guild in bot.guilds:
if guild.member_count:
total_member_count += guild.member_count
activity = discord.Activity(
name=f"{total_member_count} users", type=discord.ActivityType.listening
)
await bot.change_presence(activity=activity)
@bot.event
async def on_member_join(member: discord.Member):
await update_presence()
@bot.command()
async def presence(ctx: commands.Context):
await update_presence()
bot.run(settings.DISCORD_API_SECRET, root_logger=True)
if __name__ == "__main__":
run()