Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't reroll if someone is a sub #195

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading