-
Notifications
You must be signed in to change notification settings - Fork 0
/
deaf_test_cpc.button.interaction.js
116 lines (109 loc) · 2.81 KB
/
deaf_test_cpc.button.interaction.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
let result = await lib.googlesheets.query['@0.3.0'].select({
range: `variables!B:C`,
bounds: 'FIRST_EMPTY_ROW',
where: [
{
'name': `cpc_game_id`
}
],
limit: {
'count': 0,
'offset': 0
},
});
/*if (result.rows[0].fields.content != 0) {*/
await lib.discord.channels['@0.2.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
"content": ` https://www.cpc-power.com/index.php?page=detail&num=${result.rows[0].fields.content}`,
"tts": false,
"embeds": [
{
"type": "rich",
"title": "",
"description": "",
"color": 0x00FFFF,
"image": {
"url": `https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcold&fiche=${result.rows[0].fields.content}&slot=1&part=A&type=.png`,
"height": 0,
"width": 0
}
}
]
});
// console.log(`https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcold&fiche=${result.rows[0].fields.content}&slot=1&part=A&type=.png`);
/* await lib.googlesheets.query['@0.3.0'].update({
range: `variables!B:C`,
bounds: 'FIRST_EMPTY_ROW',
where: [
{
'name': `cpc_game_id`,
}
],
limit: {
'count': 0,
'offset': 0
},
fields: {
'content': 0
}
});*/
let randomgamenumber = getRandomInt(1,3698);
await lib.googlesheets.query['@0.3.0'].update({
range: `variables!B:C`,
bounds: 'FIRST_EMPTY_ROW',
where: [
{
'name': `cpc_game_id`,
}
],
limit: {
'count': 0,
'offset': 0
},
fields: {
'content': `${randomgamenumber}`
}
});
//display quiz message
await lib.discord.channels['@0.2.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
"content": ` `,
"tts": false,
"components": [
{
"type": 1,
"components": [
{
"style": 3,
"label": `Solution`,
"custom_id": `cpc_solution_button_id`,
"disabled": false,
"type": 2
}
]
}
],
"embeds": [
{
"type": "rich",
"title": "",
"description": "",
"color": 0x00FFFF,
"image": {
"url": `https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcold&fiche=${randomgamenumber}&slot=2&part=A&type=.png`,
"height": 0,
"width": 0
}
}
]
});
/*}
else {}*/