statchannel: member count channel
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c51b2ff3f3
commit
5adcf3478e
3 files changed
+21
No files matched your search
@@ -149,6 +149,8 @@ CATEGORIES: dict[str, tuple[str, str, str, str]] = {
|
|||||||
"with a timestamp that shows in everyone's own time zone.\n\n"
|
"with a timestamp that shows in everyone's own time zone.\n\n"
|
||||||
"**Strinova player count** — a channel name that shows how many people are "
|
"**Strinova player count** — a channel name that shows how many people are "
|
||||||
"playing Strinova, updated every 10 minutes.\n\n"
|
"playing Strinova, updated every 10 minutes.\n\n"
|
||||||
|
"**Member count** — a channel name that shows how many members the server has, "
|
||||||
|
"updated every 10 minutes.\n\n"
|
||||||
"**Custom roles** — in the roles channel, press *Get my role* and I'll DM you "
|
"**Custom roles** — in the roles channel, press *Get my role* and I'll DM you "
|
||||||
"to make your own colored role.\n\n"
|
"to make your own colored role.\n\n"
|
||||||
"**Website** — the PC's live stats are shown on https://esefos.netlify.app"
|
"**Website** — the PC's live stats are shown on https://esefos.netlify.app"
|
||||||
|
|||||||
@@ -12,14 +12,18 @@ class StatChannel(commands.Cog):
|
|||||||
|
|
||||||
self.channel_id = _parse_id('STRINOVA_STAT_CHANNEL_ID')
|
self.channel_id = _parse_id('STRINOVA_STAT_CHANNEL_ID')
|
||||||
self.channel_id_mao = _parse_id('STRINOVA_STAT_CHANNEL_ID_MAO')
|
self.channel_id_mao = _parse_id('STRINOVA_STAT_CHANNEL_ID_MAO')
|
||||||
|
self.member_channel_id = _parse_id('MEMBER_COUNT_CHANNEL_ID')
|
||||||
|
|
||||||
self.update_stat.start()
|
self.update_stat.start()
|
||||||
if self.channel_id_mao is not None:
|
if self.channel_id_mao is not None:
|
||||||
self.update_stat_mao.start()
|
self.update_stat_mao.start()
|
||||||
|
if self.member_channel_id is not None:
|
||||||
|
self.update_members.start()
|
||||||
|
|
||||||
def cog_unload(self):
|
def cog_unload(self):
|
||||||
self.update_stat.cancel()
|
self.update_stat.cancel()
|
||||||
self.update_stat_mao.cancel()
|
self.update_stat_mao.cancel()
|
||||||
|
self.update_members.cancel()
|
||||||
|
|
||||||
async def _fetch_and_update(self, channel_id):
|
async def _fetch_and_update(self, channel_id):
|
||||||
try:
|
try:
|
||||||
@@ -41,6 +45,15 @@ class StatChannel(commands.Cog):
|
|||||||
async def update_stat_mao(self):
|
async def update_stat_mao(self):
|
||||||
await self._fetch_and_update(self.channel_id_mao)
|
await self._fetch_and_update(self.channel_id_mao)
|
||||||
|
|
||||||
|
@tasks.loop(minutes=10)
|
||||||
|
async def update_members(self):
|
||||||
|
try:
|
||||||
|
channel = self.bot.get_channel(self.member_channel_id)
|
||||||
|
if channel:
|
||||||
|
await channel.edit(name=f'Member Count: {channel.guild.member_count:,}')
|
||||||
|
except Exception as e:
|
||||||
|
print(f'member count update failed (channel {self.member_channel_id}): {e}')
|
||||||
|
|
||||||
@update_stat.before_loop
|
@update_stat.before_loop
|
||||||
async def before_update_stat(self):
|
async def before_update_stat(self):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
@@ -49,5 +62,9 @@ class StatChannel(commands.Cog):
|
|||||||
async def before_update_stat_mao(self):
|
async def before_update_stat_mao(self):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
|
|
||||||
|
@update_members.before_loop
|
||||||
|
async def before_update_members(self):
|
||||||
|
await self.bot.wait_until_ready()
|
||||||
|
|
||||||
async def setup(bot):
|
async def setup(bot):
|
||||||
await bot.add_cog(StatChannel(bot))
|
await bot.add_cog(StatChannel(bot))
|
||||||
@@ -17,6 +17,8 @@ TWITTER_DISCORD_WEBHOOK_MAO="yo discord twitter channel here for mao server"
|
|||||||
#strinova stats voice channel
|
#strinova stats voice channel
|
||||||
STRINOVA_STAT_CHANNEL_ID="yo strinova stat channel here"
|
STRINOVA_STAT_CHANNEL_ID="yo strinova stat channel here"
|
||||||
STRINOVA_STAT_CHANNEL_ID_MAO="yo strinova stat channel here for mao server"
|
STRINOVA_STAT_CHANNEL_ID_MAO="yo strinova stat channel here for mao server"
|
||||||
|
#member count voice channel
|
||||||
|
MEMBER_COUNT_CHANNEL_ID="yo member count channel here"
|
||||||
|
|
||||||
#me (for purging and other owner only things)
|
#me (for purging and other owner only things)
|
||||||
OWNER_ID="your discord servers owner id here"
|
OWNER_ID="your discord servers owner id here"
|
||||||
|
|||||||
Reference in new issue
Block a user