不和谐的机器人有没有办法检查不和谐的硝基礼物代码是否有效?

时间:2020-10-08 14:53:50

标签: python discord discord.py discord.py-rewrite

我是服务器的主持人,如果您邀请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获得了一些代码,因此有人可以检查它是否符合预期的要求吗?来自堆栈溢出的代码是if ** if n.startswith(“ discord.gift/” + 13)之后的代码。

2 个答案:

答案 0 :(得分:0)

您无法检查,是否可以破坏不和谐的人

答案 1 :(得分:0)

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

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