@ -3,7 +3,6 @@ package modules
import (
import (
"fmt"
"fmt"
"strconv"
"strconv"
"strings"
"github.com/bwmarrin/discordgo"
"github.com/bwmarrin/discordgo"
@ -92,54 +91,49 @@ func CheckForVote(s *discordgo.Session, r *discordgo.MessageReactionAdd) {
checkForVoteResult ( s , voteID )
checkForVoteResult ( s , voteID )
}
}
//TODO Replace with a command.
var voteSuggestion = enforceDM ( enforceArgumentCount (
func VoteSuggestion ( s * discordgo . Session , m * discordgo . MessageCreate ) {
config . VoteSuggestionUsage , 3 ,
s . ChannelMessageDelete ( m . ChannelID , m . ID )
func ( s * discordgo . Session , m * discordgo . MessageCreate , command [ ] string ) {
if len ( command [ 1 ] ) > 500 {
args := strings . SplitN ( m . Content , " " , 2 )
message . InitNewEmbed (
if len ( args ) == 1 {
config . VoteSuggestionErrorTitle ,
message . InitNewEmbed (
config . ErrorVoteSuggestionTooLong ,
config . VoteSuggestionErrorTitle ,
config . ErrorColour ,
config . ErrorVoteSuggestionNotEnoughInfo + config . VoteSuggestionNote ,
) . SendPM ( s , m . Author . ID )
config . ErrorColour ,
) . SendPM ( s , m . Author . ID )
return
}
if len ( args [ 1 ] ) > 500 {
message . InitNewEmbed (
config . VoteSuggestionErrorTitle ,
config . ErrorVoteSuggestionTooLong + config . VoteSuggestionNote ,
config . ErrorColour ,
) . SendPM ( s , m . Author . ID )
return
}
switch args [ 0 ] {
case "custom" :
msg , err := s . ChannelMessageSend ( config . VoteChannel , "正在准备新的一个投票…… Preparing for the next vote..." )
if err != nil {
message . AuditErrorPM ( s , m . Author . ID , err )
return
return
}
}
id , err := db . CreateCustomVote ( msg . ID , args [ 1 ] )
if err != nil {
switch command [ 0 ] {
message . AuditErrorPM ( s , m . Author . ID , err )
case "custom" :
return
msg , err := message . InitNewEmbed (
config . VoteSuggestionUpcomingTitle ,
config . VoteSuggestionUpcomingDescription ,
config . VoteSuggestionUpcomingColour ,
) . Send ( s , config . VoteChannel )
if err != nil {
message . AuditErrorPM ( s , m . Author . ID , err )
return
}
id , err := db . CreateCustomVote ( msg . ID , command [ 1 ] )
if err != nil {
message . AuditErrorPM ( s , m . Author . ID , err )
return
}
message . AuditInfo ( s , fmt . Sprintf ( "Vote ID %d has been created by <@%s>." , id , m . Author . ID ) )
s . ChannelMessageEdit ( config . VoteChannel , msg . ID , "" )
createCustomEmbed ( id , command [ 1 ] ) . Edit ( s , config . VoteChannel , msg . ID )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiOne )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiTwo )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiThree )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiFour )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiFive )
server . VoteNotification ( )
default :
message . InitNewEmbed (
config . VoteSuggestionErrorTitle ,
fmt . Sprintf ( config . ErrorVoteSuggestionUnknownType , command [ 1 ] ) ,
config . ErrorColour ,
) . SendPM ( s , m . Author . ID )
}
}
message . AuditInfo ( s , fmt . Sprintf ( "Vote ID %d has been created by <@%s>." , id , m . Author . ID ) )
} ,
s . ChannelMessageEdit ( config . VoteChannel , msg . ID , "" )
) )
createCustomEmbed ( id , args [ 1 ] ) . Edit ( s , config . VoteChannel , msg . ID )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiOne )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiTwo )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiThree )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiFour )
s . MessageReactionAdd ( config . VoteChannel , msg . ID , emojiFive )
server . VoteNotification ( )
default :
message . InitNewEmbed (
config . VoteSuggestionErrorTitle ,
fmt . Sprintf ( config . ErrorVoteSuggestionUnknownType , args [ 1 ] ) + config . VoteSuggestionNote ,
config . ErrorColour ,
) . SendPM ( s , m . Author . ID )
}
}