I'm a moderator in a server and if you invite 50 people you get free nitro classic but people started scamming people and sending them invalid codes so I'm trying to get my bot to check the links. This is the code I got so far:
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("" + 13): await ctx.send("n") code_check_time += 1 """make it store the code after the part, but note most gifts come in the 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(' codevariable + '/redeem', headers=redeemheaders) r = r.text.json() print(r)"""** Client.run("My_Token", bot=False) I got some of the code from Stack Overflow so can someone check if it does what it's supposed to be? The code from Stack Overflow is the code after if **if n.startswith("" + 13).
2 Answers
There's an endpoint for checking discord nitro gifts, its a GET request to CODE HERE} No body or authentication required for this endpoint.
EDIT: Your current code would NOT work, because it's making a post request to the endpoint that redeems the nitro to the account. If you would like to just check a nitro code, the endpoint above will help.
You cant check and if you could you would be breaking discord tos