Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.72k stars 3.74k forks source link

New Event: on_nitro_boost #2397

Closed ks129 closed 4 years ago

ks129 commented 4 years ago

The Problem

Currently there is hard (or in some cases, impossible) to make Nitro Boosters auto responses, and because this would add on_nitro_boost With this is possible to make auto responses to DMs or some chat, when member boost server and make possible Nitro Rewards.

The Ideal Solution

@commands.Cog.listener
async def on_nitro_boost(booster):

Like is showed in code, this code would run each time, when someone boost server. booster variable would storage user information, Nitro information and Guild information.

The Current Solution

You may create currently background task, what check list of nitro boosters after every some time, and compare them, but this is much harder to do than would on_nitro_boost.

Summary

New event would added: on_nitro_boost, what start each time, when someone boost server.

skyblockz commented 4 years ago

It seems achievable by doing onmessage event and check the message type https://discordpy.readthedocs.io/en/latest/api.html#discord.MessageType.premium_guild_subscription

thecaralice commented 4 years ago

Discord doesn't provide such event. Instead, you should check count of boosters in guild update event or, if there's a system channel with boost messages enabled, check these messages as @skyblockz suggested

Rapptz commented 4 years ago

Generally speaking I don't like implementing events like these. An event generally corresponds to an actual Discord event. If you want to handle this then it's simple:

async def on_member_update(before, after):
    if before.premium_since is None and after.premium_since is not None:
        await on_nitro_boost(after)