Enforce channel
This commit is contained in:
		
							parent
							
								
									dcf0bdb174
								
							
						
					
					
						commit
						0e3909d4f2
					
				
							
								
								
									
										24
									
								
								Bot/Store.fs
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								Bot/Store.fs
									
									
									
									
									
								
							@ -59,7 +59,7 @@ let arsenal (ctx : InteractionContext) =
 | 
			
		||||
        do! DbService.updatePlayer updatedPlayer
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
let buy (ctx : InteractionContext) itemType =
 | 
			
		||||
let buy itemType (ctx : InteractionContext) =
 | 
			
		||||
    Game.executePlayerInteraction ctx (fun player -> async {
 | 
			
		||||
        let itemStore = Embeds.getBuyItemsEmbed itemType Armory.battleItems
 | 
			
		||||
        do! ctx.Interaction.CreateFollowupMessageAsync(itemStore)
 | 
			
		||||
@ -68,7 +68,7 @@ let buy (ctx : InteractionContext) itemType =
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
// TODO: Remove active shield when selling
 | 
			
		||||
let sell (ctx : InteractionContext) itemType =
 | 
			
		||||
let sell itemType (ctx : InteractionContext) =
 | 
			
		||||
    Game.executePlayerInteraction ctx (fun player -> async {
 | 
			
		||||
        match checkHasItemsInArsenal itemType player with
 | 
			
		||||
        | Ok _ ->
 | 
			
		||||
@ -124,18 +124,28 @@ let handleStoreEvents (_ : DiscordClient) (event : ComponentInteractionCreateEve
 | 
			
		||||
type Store() =
 | 
			
		||||
    inherit ApplicationCommandModule ()
 | 
			
		||||
 | 
			
		||||
    let enforceChannel (ctx : InteractionContext) (storeFn : InteractionContext -> Task) =
 | 
			
		||||
        match ctx.Channel.Id with
 | 
			
		||||
        | id when id = GuildEnvironment.channelArmory ->
 | 
			
		||||
            storeFn ctx
 | 
			
		||||
        | _ ->
 | 
			
		||||
            task {
 | 
			
		||||
                let msg = $"You must go to <#{GuildEnvironment.channelArmory}> channel to buy/sell or check your arsenal"
 | 
			
		||||
                do! Messaging.sendSimpleResponse ctx msg
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
    [<SlashCommand("arsenal", "Get the Hacks and Shields you own, and which ones are active")>]
 | 
			
		||||
    member this.Arsenal (ctx : InteractionContext) = arsenal ctx
 | 
			
		||||
    member this.Arsenal (ctx : InteractionContext) = enforceChannel ctx arsenal
 | 
			
		||||
 | 
			
		||||
    [<SlashCommand("buy-hack", "Purchase a hack attack you can use to earn GoodBoyTokenz")>]
 | 
			
		||||
    member _.BuyHack (ctx : InteractionContext) = buy ctx ItemType.Hack
 | 
			
		||||
    member _.BuyHack (ctx : InteractionContext) = enforceChannel ctx (buy ItemType.Hack)
 | 
			
		||||
 | 
			
		||||
    [<SlashCommand("buy-shield", "Purchase a hack shield so you can protect your GoodBoyTokenz")>]
 | 
			
		||||
    member this.BuyShield (ctx : InteractionContext) = buy ctx ItemType.Shield
 | 
			
		||||
    member this.BuyShield (ctx : InteractionContext) = enforceChannel ctx (buy ItemType.Shield)
 | 
			
		||||
 | 
			
		||||
    [<SlashCommand("sell-hack", "Sell a hack for GoodBoyTokenz")>]
 | 
			
		||||
    member this.SellHack (ctx : InteractionContext) = sell ctx ItemType.Hack
 | 
			
		||||
    member this.SellHack (ctx : InteractionContext) = enforceChannel ctx (sell ItemType.Hack)
 | 
			
		||||
 | 
			
		||||
    [<SlashCommand("sell-shield", "Sell a shield for GoodBoyTokenz")>]
 | 
			
		||||
    member this.SellShield (ctx : InteractionContext) = sell ctx ItemType.Shield
 | 
			
		||||
    member this.SellShield (ctx : InteractionContext) = enforceChannel ctx (sell ItemType.Shield)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user