Skip to content

Commit

Permalink
Don't reroll if someone is a sub
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerfort committed Nov 13, 2023
1 parent a1176c3 commit d06ceb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
11 changes: 3 additions & 8 deletions src/commands/NFD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
userMention,
} from 'discord.js'
import { Discord, Guard, Slash, SlashChoice, SlashGroup, SlashOption } from 'discordx'
import { getCallerFromCommand, getNicknameFromUser, isTwitchSub } from '../utils/CommandUtils'
import { getCallerFromCommand, getNicknameFromUser } from '../utils/CommandUtils'
import { injectable } from 'tsyringe'
import { ORM } from '../persistence'
import { NFDItem } from '../../prisma/generated/prisma-client-js'
Expand Down Expand Up @@ -104,7 +104,7 @@ class NFD {
}
}

@Slash({ name: 'hatch', description: 'Attempt to hatch a new dino. Being a subscriber makes hatching more likely.' })
@Slash({ name: 'hatch', description: 'Attempt to hatch a new dino.' })
@SlashGroup('dino')
async mint(interaction: CommandInteraction) {
const ownerMember = getCallerFromCommand(interaction)
Expand Down Expand Up @@ -146,12 +146,7 @@ class NFD {

// If we got this far then we are all set to hatch.
// Roll the hatch check
let res = roll_dy_x_TimesPick_z(4, 1, 1)

// Twitch subs get a re-roll
if (isTwitchSub(ownerMember, guild)) {
res = Math.max(res, roll_dy_x_TimesPick_z(4, 1, 1))
}
const res = roll_dy_x_TimesPick_z(4, 1, 1)

if (res <= this.MAXIMUM_FAILED_HATCHES - ownerRecordPrev.consecutiveFails) {
this.updateDBfailedMint(ownerMember.id)
Expand Down
20 changes: 0 additions & 20 deletions src/utils/CommandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,3 @@ export function getNicknameFromUser(target: User | GuildMember, guild: Guild): s
return target.username
}
}

export function isTwitchSub(user: GuildMember, guild: Guild) {
const PRIVILEGED_ROLES: Record<string, string[]> = {
'103678524375699456': ['345501570483355648'], // The Banana Hammock ['Banana Hammock']
}

try {
const roles = PRIVILEGED_ROLES[guild.id]
for (let i = 0; i < roles.length; i++) {
if (user.roles.cache.has(roles[i])) {
return true
}
}
} catch (e) {
console.log(`ERROR: Looking for guild: ${guild.name} [${guild.id}] and did not find list of Twitch sub roles.`)
return false
}
// No guild matched. So we return false.
return false
}

0 comments on commit d06ceb4

Please sign in to comment.