有没有办法让 discord 机器人检查 discord nitro 礼品代码是否有效?

Is there a way for a discord bot to check if a discord nitro gift code is valid?

我是服务器的版主,如果您邀请 50 个人,您将获得免费的 nitro classic,但人们开始诈骗他人并向他们发送无效代码,所以我试图让我的机器人检查链接。 这是我到目前为止得到的代码:

import discord
from discord.ext import commands
from discrd.ext import arg
import requests
import json
import re

client = commands.Bot(command_prefix = ";")


@client.event
async def on_ready():
    await Client.change_presence(status=discord.Status.online, activity = discord.Game("Shuffling Nitro Codes"))
    print('Bot is ready')


@client.command()
async def command(ctx, auther):
    if message.author == author:
        return True
        codes_str = await client.wait_for('message', check=check(context.author), timeout=30)
        codes = list(string.split("codes_str")
        code_now = codes



@Client.command()
async def codes(ctx, arg):
    await ctx.send("Great! Send your code list now!")
    response = client.wait_for_message(author=ctx.message.author, timeout=30)
    codes = myvar
    codes_in_list = count(codes)
    code_check_time = 0
    while code_check_time < codes_in_list:
        n = codes[code_check_time]
        **if n.startswith("discord.gift/" + 13):
            await ctx.send("n")
            code_check_time += 1
            """make it store the code after the discord.gift/ part, but note most
            gifts come in the https://discord.gift/ format, you should either use
            regex for this opertaion or just set two variables so if the message
            content includes https and discord.gift it stores it as a different
            variable.
            """
            redeemheaders = {
            'Authorization': token, #dont replace this.
            'content-type': 'application/json',
            'payment_source_id': 'null'
            }
            r = requests.post('https://ptb.discordapp.com/api/v6/entitlements/gift-codes/'+ codevariable + '/redeem', headers=redeemheaders)
            r = r.text.json()
            print(r)"""**


Client.run("My_Token", bot=False)

我从 Stack Overflow 获得了一些代码,所以有人可以检查它是否按预期运行吗? Stack Overflow 中的代码是 if **if n.startswith("discord.gift/" + 13).

之后的代码

你不能检查,如果你可以的话,你会打破不和谐

有一个检查 discord nitro 礼物的端点,它是 GET请求到 https://discord.com/api/v8/entitlements/gift-codes/{YOUR 代码在这里} 此端点不需要正文或身份验证。

编辑:您当前的代码将不起作用,因为它正在向将 nitro 兑换到帐户的端点发出 post 请求。如果您只想检查硝基代码,上面的端点会有所帮助。