Compare commits
16 Commits
6e1c27ca27
...
bd493223ca
Author | SHA1 | Date |
---|---|---|
|
bd493223ca | 3 years ago |
|
bdbc2a1196 | 3 years ago |
|
5ae7a96c3e | 3 years ago |
|
f5c59af2b4 | 3 years ago |
|
8af3e9656d | 3 years ago |
|
c2646ad280 | 3 years ago |
|
a93d4a727b | 3 years ago |
|
706c2b516b | 3 years ago |
|
efbe429824 | 3 years ago |
|
d68f027f42 | 3 years ago |
|
59926b6b9b | 3 years ago |
|
dc0bf186ae | 3 years ago |
|
d24ff86d68 | 3 years ago |
|
27d5cf3a62 | 3 years ago |
|
0c3f4ce74a | 3 years ago |
|
6d42e0fa54 | 3 years ago |
6 changed files with 100 additions and 18 deletions
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
package tools |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"flag" |
||||
"fmt" |
||||
"log" |
||||
"os" |
||||
"os/signal" |
||||
"syscall" |
||||
|
||||
"github.com/bwmarrin/discordgo" |
||||
) |
||||
|
||||
var ( |
||||
token string |
||||
dg *discordgo.Session |
||||
guild string |
||||
) |
||||
|
||||
func init() { |
||||
flag.StringVar(&token, "t", "", "Bot Token") |
||||
flag.StringVar(&guild, "g", "", "Guild ID") |
||||
flag.Parse() |
||||
} |
||||
|
||||
func main() { |
||||
if token == "" { |
||||
fmt.Printf("No token provided. Please run: disgord-thanos -t <bot token>") |
||||
} |
||||
dg, _ = discordgo.New("Bot " + token) |
||||
dg.AddHandler(messageCreate) |
||||
_ = dg.Open() |
||||
sc := make(chan os.Signal, 1) |
||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) |
||||
<-sc |
||||
dg.Close() |
||||
} |
||||
|
||||
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { |
||||
if guild != "" { |
||||
if m.GuildID != guild { |
||||
return |
||||
} |
||||
} |
||||
jsonMsg, err := json.Marshal(m) |
||||
if err != nil { |
||||
jsonMsg = append(jsonMsg, '0') |
||||
} |
||||
log.Printf("----------\n%+v: %+v\n\n%+v\n------------------------------\n\n", m.Author.Username, m.Content, string(jsonMsg)) |
||||
} |
Loading…
Reference in new issue