@ -3,7 +3,6 @@ package modules
import (
"fmt"
"strconv"
"strings"
"github.com/bwmarrin/discordgo"
@ -92,43 +91,37 @@ func CheckForVote(s *discordgo.Session, r *discordgo.MessageReactionAdd) {
checkForVoteResult ( s , voteID )
}
//TODO Replace with a command.
func VoteSuggestion ( s * discordgo . Session , m * discordgo . MessageCreate ) {
s . ChannelMessageDelete ( m . ChannelID , m . ID )
args := strings . SplitN ( m . Content , " " , 2 )
if len ( args ) == 1 {
message . InitNewEmbed (
config . VoteSuggestionErrorTitle ,
config . ErrorVoteSuggestionNotEnoughInfo + config . VoteSuggestionNote ,
config . ErrorColour ,
) . SendPM ( s , m . Author . ID )
return
}
if len ( args [ 1 ] ) > 500 {
var voteSuggestion = enforceDM ( enforceArgumentCount (
config . VoteSuggestionUsage , 3 ,
func ( s * discordgo . Session , m * discordgo . MessageCreate , command [ ] string ) {
if len ( command [ 1 ] ) > 500 {
message . InitNewEmbed (
config . VoteSuggestionErrorTitle ,
config . ErrorVoteSuggestionTooLong + config . VoteSuggestionNote ,
config . ErrorVoteSuggestionTooLong ,
config . ErrorColour ,
) . SendPM ( s , m . Author . ID )
return
}
switch args [ 0 ] {
switch command [ 0 ] {
case "custom" :
msg , err := s . ChannelMessageSend ( config . VoteChannel , "正在准备新的一个投票…… Preparing for the next vote..." )
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 , args [ 1 ] )
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 , args [ 1 ] ) . Edit ( s , 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 )
@ -138,8 +131,9 @@ func VoteSuggestion(s *discordgo.Session, m *discordgo.MessageCreate) {
default :
message . InitNewEmbed (
config . VoteSuggestionErrorTitle ,
fmt . Sprintf ( config . ErrorVoteSuggestionUnknownType , args[ 1 ] ) + config . VoteSuggestionNote ,
fmt . Sprintf ( config . ErrorVoteSuggestionUnknownType , command[ 1 ] ) ,
config . ErrorColour ,
) . SendPM ( s , m . Author . ID )
}
}
} ,
) )