SHARE
TWEET

aniiesnitroclaimer

a guest Feb 16th, 2020 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "os"
  6.     "os/signal"
  7.     "syscall"
  8.     "regexp"
  9.     "net/http"
  10.     "io/ioutil"
  11.     "log"
  12.     "bytes"
  13.     "strings"
  14.     "encoding/json"
  15.     "time"
  16.     "github.com/gookit/color"
  17.     "github.com/bwmarrin/discordgo"
  18.     "github.com/denisbrodbeck/machineid"
  19. )
  20.  
  21.  
  22. var T,_ = ioutil.ReadFile("token.txt")
  23. var Token string = strings.Replace(string(T), "\n", "", 1)
  24.  
  25. var Redeemed []string
  26.  
  27. func main() {
  28.   fmt.Println("Developed by sleep")
  29.   id, err := machineid.ProtectedID("claimer")
  30.   if err != nil {
  31.     log.Fatal(err)
  32.   }
  33.   fmt.Println(id)
  34.   dg, err := discordgo.New(Token)
  35.     _, err = dg.User("@me")
  36.     if err != nil {
  37.         fmt.Println("error creating Discord session,", err)
  38.         return
  39.     }
  40.  
  41.     dg.AddHandler(messageCreate)
  42.  
  43.     err = dg.Open()
  44.     if err != nil {
  45.         fmt.Println("error opening connection,", err)
  46.         return
  47.     }
  48.  
  49.     fmt.Println("Bot is now running.  Press CTRL-C to exit.")
  50.     sc := make(chan os.Signal, 1)
  51.     signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
  52.     <-sc
  53.     dg.Close()
  54. }
  55.  
  56. func redeem_code(code string, channel_id string) {
  57.         client := &http.Client{}
  58.         values := map[string]string{"channel_id": channel_id, "payment_source_id": "123"}
  59.         jsonValue, _ := json.Marshal(values)
  60.         req, err := http.NewRequest("POST", "https://discordapp.com/api/v6/entitlements/gift-codes/"+code+"/redeem", bytes.NewBuffer(jsonValue))
  61.         req.Header.Add("content-type", "application/json")
  62.         req.Header.Add("Authorization", Token)
  63.         resp, err := client.Do(req)
  64.         defer resp.Body.Close()
  65.  
  66.         //bodyBytes, err := ioutil.ReadAll(resp.Body)
  67.     if err != nil {
  68.         log.Fatal(err)
  69.     }
  70.     //bodyString := string(bodyBytes)
  71.     //fmt.Println(bodyString)
  72.         switch status := resp.StatusCode; status {
  73.         case 200:
  74.             color.Success.Println("Redeemed Nitro: " + code)
  75.         case 404:
  76.             color.Danger.Println("Invalid Code: " + code)
  77.         case 400:
  78.             color.Danger.Println("Invalid Code: " + code)
  79.         }
  80.         Redeemed = append(Redeemed, code)
  81. }
  82.  
  83. func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
  84.  
  85.     if m.Author.ID == s.State.User.ID {
  86.         return
  87.     }
  88.  
  89.   match1, _ := regexp.MatchString("(?:https?:)?discord(?:app.com/gifts/|.gift/)([^\\s]+)", m.Content)
  90.   if match1 == true {
  91.     re := regexp.MustCompile("(?:https?:)?discord(?:app.com/gifts/|.gift/)([^\\s]+)")
  92.     match := re.FindStringSubmatch(m.Content)
  93.     code := match[1]
  94.     //fmt.println(m.channelID)
  95.     _, found := Find(Redeemed, code)
  96.     if !found && len(code) == 16 || len(code) == 24 {
  97.         redeem_code(code, m.ChannelID)
  98.     } else {
  99.         fmt.Println(code, "- Already Attempted or Invalid Format")
  100.     }
  101. }
  102. }
  103. func Find(slice []string, val string) (int, bool) {
  104.     for i, item := range slice {
  105.         if item == val {
  106.             return i, true
  107.         }
  108.     }
  109.     return -1, false
  110. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top