forked from RatWasHere/bmods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetListElementPosition_MOD.js
47 lines (43 loc) · 1.03 KB
/
getListElementPosition_MOD.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module.exports = {
data: {
name: "Get List Element Position",
},
category: "Lists",
info: {
source: "https://github.com/RatWasHere/bmods/tree/master/Actions",
creator: "candiedapple",
donate: "https://buymeacoffee.com/candiedapple",
},
UI: [
{
element: "variableInsertion",
storeAs: "list",
name: "List",
},
{
element: "input",
storeAs: "elementname",
name: "Element Name",
},
"-",
{
element: "storageInput",
storeAs: "store",
name: "Store Element Position As",
},
"-",
{
element: "text",
text: "Note : Positions start at 0",
},
],
async run(values, interaction, client, bridge) {
const list = bridge.get(values.list);
const elementName = bridge.transf(values.elementname);
const elementPosition = list.indexOf(elementName);
if (elementPosition === -1) {
console.log(`The element "${elementName}" is not found in the list.`);
}
bridge.store(values.store, elementPosition);
},
};