Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update infochannel.py #232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firstmessage/firstmessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def firstmessage(self, ctx: commands.Context, channel: discord.TextChannel
await ctx.maybe_send_embed("Unable to read message history for that channel")
return

em = discord.Embed(description=f"[First Message in {channel.mention}]({message.jump_url})")
em = discord.Embed(description=f"Jump to the [First Message]({message.jump_url}) in {channel.mention}")
em.set_author(name=message.author.display_name, icon_url=message.author.avatar.url)

await ctx.send(embed=em)
53 changes: 44 additions & 9 deletions infochannel/infochannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

log = logging.getLogger("red.fox_v3.infochannel")


async def get_channel_counts(category, guild):
# Gets count of bots
bot_num = len([m for m in guild.members if m.bot])
Expand All @@ -30,6 +29,13 @@ async def get_channel_counts(category, guild):
human_num = members - bot_num
# count amount of premium subs/nitro subs.
boosters = guild.premium_subscription_count
# New additions
emojis_count = len(guild.emojis)
news_channels_count = len([c for c in guild.channels if isinstance(c, discord.TextChannel) and c.is_news()])
stage_channels_count = len([c for c in guild.channels if isinstance(c, discord.StageChannel)])
voice_channels_count = len([c for c in guild.channels if isinstance(c, discord.VoiceChannel)])
server_boost_tier = guild.premium_tier
timezones = guild.preferred_locale
return {
"members": members,
"humans": human_num,
Expand All @@ -39,9 +45,14 @@ async def get_channel_counts(category, guild):
"channels": channels_num,
"online": online_num,
"offline": offline_num,
"emojis": emojis_count,
"news_channels": news_channels_count,
"stage_channels": stage_channels_count,
"voice_channels": voice_channels_count,
"server_boost_tier": server_boost_tier,
"timezones": timezones,
}


class InfoChannel(Cog):
"""
Create a channel with updating server info
Expand All @@ -59,19 +70,25 @@ def __init__(self, bot: Red):

# self. so I can get the keys from this later
self.default_channel_names = {
"members": "Members: {count}",
"humans": "Humans: {count}",
"boosters": "Boosters: {count}",
"bots": "Bots: {count}",
"roles": "Roles: {count}",
"channels": "Channels: {count}",
"members": "👤 Members: {count}",
"humans": "👤 Humans: {count}",
"boosters": "💎 Boosters: {count}",
"bots": "🤖 Bots: {count}",
"roles": "👔 Roles: {count}",
"channels": "🔧 Channels: {count}",
"online": "Online: {count}",
"offline": "Offline: {count}",
"emojis": "🥳 Emojis: {count}",
"news_channels": "📰 News Channels: {count}",
"stage_channels": "🎤 Stage Channels: {count}",
"voice_channels": "🔊 Voice Channels: {count}",
"server_boost_tier": "🥇 Server Boost Tier: {count}",
"timezones": "⏰ Timezone: {count}",
}

default_channel_ids = {k: None for k in self.default_channel_names}
# Only members is enabled by default
default_enabled_counts = {k: k == "members" for k in self.default_channel_names}
default_enabled_counts = {k: k in ["members", "emojis", "news_channels", "stage_channels", "voice_channels", "server_boost_tier", "timezones"] for k in self.default_channel_names}

default_guild = {
"category_id": None,
Expand Down Expand Up @@ -184,6 +201,12 @@ async def _infochannelset_togglechannel(
- `channels`: Total number of channels excluding infochannels,
- `online`: Total online members,
- `offline`: Total offline members,
- `emojis`: Total amount of emojis
- `news_channels`: Total amount of news channels
- `stage_channels`: Total number of stage channels
- `voice_channels`: Total number of voice channels,
- `server_boost_tier`: Server boost tier,
- `timezones`: Timezones,
"""
guild = ctx.guild
if channel_type not in self.default_channel_names.keys():
Expand Down Expand Up @@ -239,6 +262,12 @@ async def _infochannelset_name(self, ctx: commands.Context, channel_type: str, *
- `channels`: Total number of channels excluding infochannels
- `online`: Total online members
- `offline`: Total offline members
- `emojis`: Total amount of emojis
- `news_channels`: Total amount of news channels
- `stage_channels`: Total number of stage channels
- `voice_channels`: Total number of voice channels,
- `server_boost_tier`: Server boost tier,
- `timezones`: Timezones,

Warning: This command counts against the channel update rate limit and may be queued.
"""
Expand Down Expand Up @@ -457,6 +486,12 @@ async def update_infochannel(self, guild: discord.Guild, channel_type=None, chan
channels=True,
online=True,
offline=True,
emojis=True,
news_channels=True,
stage_channels=True,
voice_channels=True,
server_boost_tier=True,
timezones=True,
extra_roles=set(guild.roles),
)

Expand Down
Loading