Skip to content

Commit

Permalink
Added new Premium redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
denverquane committed Dec 5, 2020
1 parent 7127d2f commit c209eb4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
4 changes: 2 additions & 2 deletions discord/command_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (bot *Bot) HandleCommand(isAdmin, isPermissioned bool, sett *storage.GuildS
break

case command.Info:
embed := bot.infoResponse(sett)
embed := bot.infoResponse(m.GuildID, sett)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, embed)
if err != nil {
log.Println(err)
Expand Down Expand Up @@ -380,7 +380,7 @@ func (bot *Bot) HandleCommand(isAdmin, isPermissioned bool, sett *storage.GuildS
case command.Premium:
premStatus := bot.PostgresInterface.GetGuildPremiumStatus(m.GuildID)
if len(args[1:]) == 0 {
s.ChannelMessageSendEmbed(m.ChannelID, premiumEmbedResponse(premStatus, sett))
s.ChannelMessageSendEmbed(m.ChannelID, premiumEmbedResponse(m.GuildID, premStatus, sett))
} else {
arg := strings.ToLower(args[1])
if isAdmin {
Expand Down
5 changes: 3 additions & 2 deletions discord/message_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,11 @@ func (bot *Bot) handleNewGameMessage(s *discordgo.Session, m *discordgo.MessageC
s.ChannelMessageSend(m.ChannelID, sett.LocalizeMessage(&i18n.Message{
ID: "message_handlers.handleNewGameMessage.lockout",
Other: "If I start any more games, Discord will lock me out, or throttle the games I'm running! 😦\n" +
"Please try again in a few minutes, or consider [AutoMuteUs Premium](https://patreon.com/automuteus)\n" +
"Please try again in a few minutes, or consider AutoMuteUs Premium (`{{.CommandPrefix}} premium`)\n" +
"Current Games: {{.Games}}",
}, map[string]interface{}{
"Games": fmt.Sprintf("%d/%d", activeGames, num),
"CommandPrefix": sett.CommandPrefix,
"Games": fmt.Sprintf("%d/%d", activeGames, num),
}))
lock.Release(context.Background())
return
Expand Down
20 changes: 13 additions & 7 deletions discord/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var EmojiNums = []string{":one:", ":two:", ":three:"}

const ISO8601 = "2006-01-02T15:04:05-0700"

const BasePremiumUrl = "https://crewmate.xyz/donate/amu?guildid="

func helpResponse(isAdmin, isPermissioned bool, CommandPrefix string, commands []command.Command, sett *storage.GuildSettings) discordgo.MessageEmbed {
embed := discordgo.MessageEmbed{
URL: "",
Expand Down Expand Up @@ -118,7 +120,7 @@ func settingResponse(CommandPrefix string, settings []Setting, sett *storage.Gui
return &embed
}

func (bot *Bot) infoResponse(sett *storage.GuildSettings) *discordgo.MessageEmbed {
func (bot *Bot) infoResponse(guildID string, sett *storage.GuildSettings) *discordgo.MessageEmbed {
version, commit := broker.GetVersionAndCommit(bot.RedisInterface.client)
embed := discordgo.MessageEmbed{
URL: "",
Expand Down Expand Up @@ -216,7 +218,7 @@ func (bot *Bot) infoResponse(sett *storage.GuildSettings) *discordgo.MessageEmbe
ID: "responses.statsResponse.Donate",
Other: "Premium",
}),
Value: "[patreon/automuteus](https://www.patreon.com/automuteus)",
Value: "[PayPal](" + BasePremiumUrl + guildID + ")",
Inline: true,
}

Expand Down Expand Up @@ -445,7 +447,7 @@ func (dgs *DiscordGameState) makeDescription(sett *storage.GuildSettings) string
return buf.String()
}

func premiumEmbedResponse(tier storage.PremiumTier, sett *storage.GuildSettings) *discordgo.MessageEmbed {
func premiumEmbedResponse(guildID string, tier storage.PremiumTier, sett *storage.GuildSettings) *discordgo.MessageEmbed {
desc := ""
fields := []*discordgo.MessageEmbedField{}

Expand All @@ -472,7 +474,7 @@ func premiumEmbedResponse(tier storage.PremiumTier, sett *storage.GuildSettings)
{
Name: "Premium Settings",
Value: sett.LocalizeMessage(&i18n.Message{
ID: "responses.premiumResponse.Settings",
ID: "responses.premiumResponse.SettingsDescExtra",
Other: "Look for the settings marked with 💎 under `{{.CommandPrefix}} settings!`",
}, map[string]interface{}{
"CommandPrefix": sett.GetCommandPrefix(),
Expand All @@ -482,8 +484,12 @@ func premiumEmbedResponse(tier storage.PremiumTier, sett *storage.GuildSettings)
}
} else {
desc = sett.LocalizeMessage(&i18n.Message{
ID: "responses.premiumResponse.FreeDescription",
Other: "Check out the cool things that Premium AutoMuteUs has to offer!\n\n[Get AutoMuteUs Premium](https://patreon.com/automuteus)",
ID: "responses.premiumResponse.FreeDescription",
Other: "Check out the cool things that Premium AutoMuteUs has to offer!\n\n" +
"[Get AutoMuteUs Premium]({{.BaseURL}}{{.GuildID}})",
}, map[string]interface{}{
"BaseURL": BasePremiumUrl,
"GuildID": guildID,
})
fields = []*discordgo.MessageEmbedField{
{
Expand Down Expand Up @@ -545,7 +551,7 @@ func premiumEmbedResponse(tier storage.PremiumTier, sett *storage.GuildSettings)
}

msg := discordgo.MessageEmbed{
URL: "https://patreon.com/automuteus",
URL: BasePremiumUrl + guildID,
Type: "",
Title: sett.LocalizeMessage(&i18n.Message{
ID: "responses.premiumResponse.Title",
Expand Down
18 changes: 8 additions & 10 deletions locales/active.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
"commands.AllCommands.Force.args" = "<phase name> (task, discuss, or lobby / t,d, or l)"
"commands.AllCommands.Force.desc" = "Force the bot to transition to another game stage, if it doesn't transition properly"
"commands.AllCommands.Force.shortDesc" = "Force the bot to transition"
"commands.AllCommands.Help.args" = "None, or optional command to see info for"
"commands.AllCommands.Help.desc" = "Display bot help message, or see info about a command"
"commands.AllCommands.Help.args" = "None, or optional Command to see info for"
"commands.AllCommands.Help.desc" = "Display bot help message, or see info about a Command"
"commands.AllCommands.Help.shortDesc" = "Display help"
"commands.AllCommands.Info.args" = "None"
"commands.AllCommands.Info.desc" = "View info about the bot, like total guild number, active games, etc"
"commands.AllCommands.Info.shortDesc" = "View Bot info"
"commands.AllCommands.Link.args" = "<discord User> <in-game color or name>"
"commands.AllCommands.Link.desc" = "Manually link a Discord User to their in-game color or name"
"commands.AllCommands.Link.shortDesc" = "Link a Discord User"
"commands.AllCommands.Log.args" = "<message>"
"commands.AllCommands.Log.desc" = "Log if something bad happened, so you can find the event in your logs later"
"commands.AllCommands.Log.shortDesc" = "Log a weird event"
"commands.AllCommands.Map.args" = "<map_name> (skeld, mira_hq, polus) <version> (optional, simple or detailed)"
"commands.AllCommands.Map.desc" = "Display an image of an in-game map in the text channel. Two supported versions: simple or detailed"
"commands.AllCommands.Map.shortDesc" = "Display an in-game map"
Expand Down Expand Up @@ -93,7 +90,7 @@
"message_handlers.handleNewGameMessage.embed.Fields.Code" = "Code"
"message_handlers.handleNewGameMessage.embed.Fields.URL" = "URL"
"message_handlers.handleNewGameMessage.embed.Title" = "You just started a game!"
"message_handlers.handleNewGameMessage.lockout" = "If I start any more games, Discord will lock me out, or throttle the games I'm running! 😦\\nPlease try again in a few minutes, or consider AutoMuteUs Premium"
"message_handlers.handleNewGameMessage.lockout" = "If I start any more games, Discord will lock me out, or throttle the games I'm running! 😦\\nPlease try again in a few minutes, or consider AutoMuteUs Premium (`{{.CommandPrefix}} premium`)\\nCurrent Games: {{.Games}}"
"message_handlers.handleNewGameMessage.noChannel" = "{{.User}}, please join a voice channel before starting a match!"
"message_handlers.handleNewGameMessage.specificRatelimit" = "{{.User}} You're creating games too fast! Please slow down!"
"message_handlers.handleReactionGameStartAdd.generalRatelimit" = "{{.User}}, you're reacting too fast! Please slow down!"
Expand Down Expand Up @@ -125,13 +122,14 @@
"responses.premiumInviteResponseNoAccess.desc" = "{{.Tier}} users don't have access to Priority mute bots!\\nPlease type `{{.CommandPrefix}} premium` to see more details about AutoMuteUs Premium"
"responses.premiumResponse.FastMute" = "🙊 Fast Mute/Deafen"
"responses.premiumResponse.FastMuteDesc" = "Premium users get access to \"helper\" bots that make sure muting is fast!"
"responses.premiumResponse.FreeDescription" = "Check out the cool things that Premium AutoMuteUs has to offer!\\n\\n[Get AutoMuteUs Premium](https://patreon.com/automuteus)"
"responses.premiumResponse.FreeDescription" = "Check out the cool things that Premium AutoMuteUs has to offer!\\n\\n[Get AutoMuteUs Premium]({{.BaseURL}}{{.GuildID}})"
"responses.premiumResponse.Invites" = "View a list of Premium bots you can invite with `{{.CommandPrefix}} premium invites`!"
"responses.premiumResponse.PremiumDescription" = "Looks like you have AutoMuteUs **{{.Tier}}**! Thanks for the support!\\n\\nBelow are some of the benefits you can customize with your Premium status!"
"responses.premiumResponse.PriorityGameAccess" = "👑 Priority Game Access"
"responses.premiumResponse.PriorityGameAccessDesc" = "If the Bot is under heavy load, Premium users will always be able to make new games!"
"responses.premiumResponse.Settings" = "🛠 Special Settings"
"responses.premiumResponse.SettingsDesc" = "Premium users can specify additional settings, like displaying an end-game status message, or auto-refreshing the status message!"
"responses.premiumResponse.SettingsDescExtra" = "Look for the settings marked with 💎 under `{{.CommandPrefix}} settings!`"
"responses.premiumResponse.Stats" = "📊 Game Stats and Leaderboards"
"responses.premiumResponse.StatsDesc" = "Premium users have access to a full suite of player stats and leaderboards!"
"responses.premiumResponse.Support" = "👂 Premium Support"
Expand All @@ -150,7 +148,6 @@
"responses.statsResponse.Title" = "Bot Info"
"responses.statsResponse.Version" = "Version"
"responses.statsResponse.Website" = "Website"
"responses.title.GameOver" = "**Game Over**"
"responses.userStatsEmbed.CrewmateWins" = "Crewmate Wins"
"responses.userStatsEmbed.Desc" = "User stats for {{.User}}"
"responses.userStatsEmbed.FavoriteColors" = "Favorite Colors"
Expand All @@ -159,6 +156,7 @@
"responses.userStatsEmbed.ImposterWins" = "Imposter Wins"
"responses.userStatsEmbed.NoPremium" = "Detailed stats are only available for AutoMuteUs Premium users; type `{{.CommandPrefix}} premium` to learn more"
"responses.userStatsEmbed.Premium" = "Showing additional Premium Stats!\\n(Note: stats are still in **BETA**, and will be likely be inaccurate while we work to improve them)."
"responses.userStatsEmbed.ServerPlayedInValue" = "{{.Server}} Server"
"responses.userStatsEmbed.ServersPlayedIn" = "Played In"
"responses.userStatsEmbed.ServersPlayedInValue" = "{{.Servers}} Servers"
"responses.userStatsEmbed.Title" = "User Stats"
Expand Down Expand Up @@ -214,8 +212,6 @@
"settings.SettingAutoRefresh.False" = "From now on, I will not AutoRefresh the game status message"
"settings.SettingAutoRefresh.True" = "From now on, I'll AutoRefresh the game status message"
"settings.SettingAutoRefresh.Unrecognized" = "{{.Arg}} is not a true/false value. See `{{.CommandPrefix}} settings autorefresh` for usage"
"settings.SettingMapVersion.Unrecognized" = "{{.Arg}} is not an expected value. See `{{.CommandPrefix}} settings mapversion` for usage"
"settings.SettingMapVersion.Success" = "From now on, I will display map images as {{.Arg}}"
"settings.SettingDelays.Phase.UNINITIALIZED" = "I don't know what `{{.PhaseName}}` is. The list of game phases are `Lobby`, `Tasks` and `Discussion`."
"settings.SettingDelays.delayBetweenPhases" = "Currently, the delay when passing from `{{.PhaseA}}` to `{{.PhaseB}}` is {{.OldDelay}}."
"settings.SettingDelays.missingPhases" = "The list of game phases are `Lobby`, `Tasks` and `Discussion`.\\nYou need to type both phases the game is transitioning from and to to change the delay."
Expand All @@ -227,6 +223,8 @@
"settings.SettingLanguage.reloaded" = "Localization files are reloaded ({{.Count}}). Available language codes: {{.Langs}}"
"settings.SettingLanguage.set" = "Localization is set to {{.LangName}}"
"settings.SettingLanguage.tooShort" = "Sorry, the language code is short. Available language codes: {{.Langs}}."
"settings.SettingMapVersion.Success" = "From now on, I will display map images as {{.Arg}}"
"settings.SettingMapVersion.Unrecognized" = "{{.Arg}} is not an expected value. See `{{.CommandPrefix}} settings mapversion` for usage"
"settings.SettingMatchSummary.OutOfRange" = "You provided a number too high or too low. Please specify a number between [0-60], or -1 to never delete match summaries"
"settings.SettingMatchSummary.Success" = "From now on, I'll delete match summary messages after {{.Minutes}} minutes."
"settings.SettingMatchSummary.Success-1" = "From now on, I'll never delete match summary messages."
Expand Down

0 comments on commit c209eb4

Please sign in to comment.