To answer your question, it will not work as the embedded invalidation codes are not messages. They are previews (sort of, doesn't really matter what they are right now). All you really have to do is parse the codes and validate them. I'd suggest also redeeming the code as soon as you can validate it, which I'll assume you know how to do.
Code:
import requests
import re
import os
from discord.ext import commands
import discord
client = commands.Bot(command_prefix='!')
# commands.Bot(command_prefix='!', self_bot=True) - This is for Selfbots (Using a Discord User's token instead of a application/bot token)
# Creating Discord Bot instance
def validate_code(*args):
try:
results = []
for code in args:
response = requests.get(f'https://discordapp.com/api/v8/entitlements/gift-codes/{code}')
body = response.text
if not any(message in body for message in ['Unknown', 'redeemed already', '404']):
results.append((True, code))
elif 'rate limit' in body:
# Handle it how you will
pass
else:
results.append((False, code))
return results
except Exception:
return False
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
matches = re.findall(gift_pattern, message.content)
if matches:
gift_codes = list(filter(None, sum(matches, ()))) # Flattening the list of tuples while removing all invalid strings e.g: '', None, etc
validation = validate_code(*gift_codes)
# Continue your code
if __name__ == '__main__':
client.run(os.getenv('TOKEN')) # Normal Discord Bot
# client.run(os.getenv('TOKEN'), bot=False) - This is for Selfbots (Using a Discord User's token instead of a application/bot token)
This is a very basic way of doing it. While working, it is not ideal. I haven't tested it, however, I doubt the speeds will be anything stunning. I'll assume it's around 0.5-8 (depending on your internet connection). That's just one way of doing it, slowly. Not the point though, have a nice day.
Always confirm via PM before dealing with me.