Skip to main content

Edit-Item command

this command would allow admins to edit items in the shop.

  • /edit item

Flow

tip

You can just duplicate the add-item command and edit the blocks as this command is almost identical to the previous one.

What's Changed?
  • Arguments - some arguments are changed from Required: true to Required: false
  • Calculate Value Blocks

everything else is same as the previous command!

🛠️ Arguments and Permissions

Arguments

ArgumentsDescriptionTypeValuesRequired
idid of the item - no special characters allowedTextMax Length : 50True
namename of itemTextMax Length : 50False
priceprice for the itemWhole Number
descriptionshort description of the itemTextMax Length : 150
reward_rolerole to give as rewardRole
required_rolerole required to buy this itemRole
stockremaining stock for the itemWhole Number
responseextra notes to add in response when someone buys this itemTextMax Length : 150

Command Permissions

MANAGE GUILD or ADMIN, modify it according to you.

Get Stored Variable

  • Variable : shop
  • Set Temporary Variable : shop

Calculate Value

  • Temporary Variable : shop_item
Expression
let list = var('shop') ?? [];

let item = findIndex(list, .id == arg('id'));

item != nil ?
map(list, #index == item ?
{
"id": .id,
"stock": arg('stock') ?? .stock,
"name": arg('name') ?? .name,
"role": arg('reward_role')?.id ?? .role,
"require": arg('required_role')?.id ?? .require,
"price": arg('price') ?? .price,
"desc": arg('description') ?? .desc,
"response": arg('response') ?? .response
}
: #)
:
"## ⚠️ Item not in list."

Comparison Condition

  • Base Value : {{type(var('shop_item'))}}

Match Condition

Comparison ModeComparison Value
Equalarray
  1. Set stored variable

    • Variable : shop
    • Operation : Overwrite
    • Value : {{var('shop_item')}}
  2. Create Response Message : done 👌

Else

  • Create Response Message : {{var('shop_item')}}