Skip to content

Commit

Permalink
added command delete on tweet, permissions printing
Browse files Browse the repository at this point in the history
  • Loading branch information
cyckl committed Oct 10, 2020
1 parent 33fae08 commit d6745ff
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
"strings"
"syscall"
"time"

"github.com/bwmarrin/discordgo"
)

var (
token string
token string
version string
)

Expand All @@ -26,8 +25,6 @@ func init() {
}

func main() {
// Pseudorandom num gen seed

// Create new Discord session using bot token
dg, err := discordgo.New("Bot " + token)
if err != nil {
Expand All @@ -54,13 +51,16 @@ func main() {
fmt.Println("║ Tweeter by cyckl ║")
fmt.Println(fmt.Sprintf("║ Running version %s ║", version))
fmt.Println("╚═══════════════════════╝")
fmt.Println("[Permissions] 75776")

// Seed RNG
rand.Seed(time.Now().UnixNano())
fmt.Println("[Info] Random number generator seeded")

// Close Discord session cleanly
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc

// Close Discord session cleanly
dg.Close()
fmt.Println("[Info] Program terminated")
}
Expand All @@ -85,7 +85,10 @@ func tweet(s *discordgo.Session, m *discordgo.MessageCreate) {
} else {
tweetAuthor = m.Author.Username
}


// Delete command issuer
s.ChannelMessageDelete(m.ChannelID, m.ID)

// Fill embed and send it
s.ChannelMessageSendEmbed(m.ChannelID, &discordgo.MessageEmbed{
Author: &discordgo.MessageEmbedAuthor{
Expand All @@ -104,6 +107,8 @@ func tweet(s *discordgo.Session, m *discordgo.MessageCreate) {
{Name: "Likes", Value: strconv.Itoa(randInt(25000, 150000)), Inline: true},
},
})

// Log to console
fmt.Println(fmt.Sprintf("[Tweet] (%s) %s", m.Author.ID, strings.TrimPrefix(m.Content, ".t ")))
}
}
Expand Down

0 comments on commit d6745ff

Please sign in to comment.