Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 55bc13d

Browse files
committed
Starting image recall feature. Rearranged help section
1 parent 0f73c9d commit 55bc13d

3 files changed

Lines changed: 102 additions & 14 deletions

File tree

commands.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ var (
3232
Help: "Args: [emoji | name]\n\nReturns all the emojis that match the given emoji or emoji name in all the servers you are in",
3333
Exec: msgFindEmoji,
3434
}.add()
35+
imageCommand = command{
36+
Name: "image",
37+
Help: "Args: [save,recall,delete,list,status] [name]\n\nSave images and recall them at anytime! Everyone gets 8MB of image storage. Any name counts so long theres no `/` in it." +
38+
"Only you can 'recall' your saved images. There's a review process to make sure nothing illegal is being uploaded but we're fairly relaxed for the most part\n\n" +
39+
"Example:\n`!owo image save 2B Happy`\n2Bot downloads the image and sends it off for reviewing\n\n" +
40+
"`!owo image recall 2B Happy`\nIf your image was confirmed, 2Bot will send the image named `2B Happy`\n\n" +
41+
"`!owo image delete 2B Happy`\nThis will delete the image you saved called `2B Happy`\n\n" +
42+
"`!owo image list`\nThis will list your saved images along with a preview!\n\n" +
43+
"`!owo image status`\nShows some details on your saved images and quota",
44+
Exec: msgImageRecall,
45+
}.add()
46+
helpComm = command{"help",
47+
"", msgHelp,
48+
}.add()
3549
)
3650

3751
//Small wrapper function to reduce clutter
@@ -48,19 +62,6 @@ func parseCommand(s *discordgo.Session, m *discordgo.MessageCreate, message stri
4862
return msglist[0]
4963
}()
5064

51-
if command == "help" {
52-
if len(msglist) == 2 {
53-
if val, ok := commMap[l(msglist[1])]; ok {
54-
val.helpCommand(s, m)
55-
return
56-
}
57-
}
58-
59-
listCommands(s, m)
60-
61-
return
62-
}
63-
6465
if command == l(commMap[command].Name) {
6566
commMap[command].Exec(s, m, msglist[1:])
6667
return
@@ -95,7 +96,11 @@ func listCommands(s *discordgo.Session, m *discordgo.MessageCreate) {
9596
})
9697
}
9798

98-
func (c command) helpCommand(s *discordgo.Session, m *discordgo.MessageCreate) {
99+
func (c command) msgHelp(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
100+
if len(msglist) == 0 {
101+
listCommands(s, m)
102+
return
103+
}
99104
userColor := s.State.UserColor(s.State.User.ID, m.ChannelID)
100105

101106
s.ChannelMessageDelete(m.ChannelID, m.Message.ID)

msgImageRecall.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package main
2+
3+
import (
4+
"io/ioutil"
5+
"github.com/bwmarrin/discordgo"
6+
"net/http"
7+
"fmt"
8+
)
9+
10+
func msgImageRecall(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
11+
if len(msglist) < 1 {
12+
s.ChannelMessageEdit(m.ChannelID, m.Message.ID, "Available sub-commands for `image`:\n`save`, `delete`, `recall`, `list`, `status`\n"+
13+
"Type `"+conf.Prefix+"help image` to see more info about this command")
14+
return
15+
}
16+
17+
switch msglist[0] {
18+
case "recall":
19+
fimageRecall(s, m, msglist)
20+
case "save":
21+
fimageSave(s, m, msglist)
22+
case "list":
23+
fimageList(s, m, msglist)
24+
case "delete":
25+
fimageDelete(s, m, msglist)
26+
case "info":
27+
fimageInfo(s, m, msglist)
28+
}
29+
}
30+
31+
func fimageRecall(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
32+
resp, err := http.Get("http://strum355.netsoc.co/inServer?id="+m.Author.ID)
33+
if err != nil {
34+
errorLog.Println(err)
35+
return
36+
}
37+
defer resp.Body.Close()
38+
39+
bytes, err := ioutil.ReadAll(resp.Body)
40+
if err != nil {
41+
errorLog.Println(err)
42+
return
43+
}
44+
45+
if string(bytes) == "1" {
46+
fmt.Println("in server")
47+
return
48+
}
49+
fmt.Println("not in server")
50+
}
51+
52+
func fimageSave(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
53+
54+
}
55+
56+
func fimageList(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
57+
58+
}
59+
60+
func fimageDelete(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
61+
62+
}
63+
64+
func fimageInfo(s *discordgo.Session, m *discordgo.MessageCreate, msglist []string) {
65+
66+
}

utilities.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"github.com/bwmarrin/discordgo"
5+
)
6+
7+
func guildDetails(channelID string, s *discordgo.Session) (*discordgo.Guild, error) {
8+
channelInGuild, err := s.State.Channel(channelID)
9+
if err != nil {
10+
return nil, err
11+
}
12+
guildDetails, err := s.State.Guild(channelInGuild.GuildID)
13+
if err != nil {
14+
return nil, err
15+
}
16+
return guildDetails, nil
17+
}

0 commit comments

Comments
 (0)