Is there any way to notify about ADDITONAL boosts to a server via the bot? #10219
-
So I already wrote a form of boost notification as a service in the import logging
import discord
from discord import app_commands
from discord.ext import commands
class BoostShoutoutHandler(commands.Cog, name="Discord Boost Announcement Service"):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_update(self, before: discord.Member, after: discord.Member):
config = self.bot.config
if after.premium_since != before.premium_since:
boost_announce_channel_id = config.get_value(after.guild.id, "BOOST_ANNOUNCE_CHANNEL")
if boost_announce_channel_id:
msg = f"Thank you, {after.name}, for boosting {after.guild.name}!"
embed = discord.Embed(
title="Server Boost Alert!",
description=msg,
colour=discord.Colour.purple(),
)
embed.set_thumbnail(url=after.display_avatar.url)
# Fetch the announcement channel and send the embed
channel = await self.bot.fetch_channel(boost_announce_channel_id)
await channel.send(embed=embed)
async def setup(bot):
await bot.add_cog(BoostShoutoutHandler(bot)) Basically attempts to see if Firstly: as far as I'm aware, Secondly: Even if that did change, I'm not sure it would actually cause the So with those things in mind.. does anyone know of a method I could use to include additonal user boosts to that notification? (IE: user already boosted once, and then adds another boost to the server on top of that already existing boost). Basically the only ideas I could think of is possibly using the The other would be to check for the system boost message and piggyback off of that. But that somewhat defeats the purpose of this as the person I'm helping with make it wanted it to be more personalized than the system message anyways, and has already turned it off 😅 (I could however convince them to turn it back on and supply the message to a private channel and keep the personalized one public) Anyways with those thoughts out of the way, if anyone has any ideas I would be appreciative!! Thank you <3 (Also I am aware that there was a similar discussion here, but I just wanted to see if anything has changed since then or to get further clarification on the topic. Both sorry and thanks in advance!) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello, I would probably check this using the @commands.Cog.listener()
async def on_message(self, message):
if message.type == discord.MessageType.premium_guild_subscription:
booster = message.author This is the best way I can see to do what you want |
Beta Was this translation helpful? Give feedback.
-
from https://docs.discord.food/resources/guild#get-premium-guild-subscriptions:
there's no mention of this specific endpoint in the official API documentation so use it at your own risk 🤷 |
Beta Was this translation helpful? Give feedback.
Hello, I would probably check this using the
on_message
listener and wait for aMessageType
equal to 8 (premium_guild_subscription
), which already identifies the messages announcing boost on the server, something like this:This is the best way I can see to do what you want