Skip to content
This repository was archived by the owner on Nov 14, 2022. It is now read-only.

Commit 0c592ab

Browse files
committed
Send emojis in bulk to prevent 429 (resolves #4)
1 parent 9994857 commit 0c592ab

2 files changed

Lines changed: 43 additions & 39 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "discord-4sucres-connector",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"author": "Simon MGK <contact@mgkprod.fr>",
55
"description": "Send your Discord guilds emojis on 4sucres",
66
"license": null,

src/renderer/components/LandingPage.vue

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
src="@/assets/img/discord-connector.png"
1818
class="img-fluid"
1919
style="width: 80px;"
20-
>
20+
/>
2121
</div>
2222
<div class="col">
2323
<h1 class="h5 mb-0">Connecteur 4sucres-Discord</h1>
2424
<span class="text-muted">{{ config.version }}</span>
25-
<br>
25+
<br />
2626
<div class="mt-3">
2727
<button class="btn btn-primary btn-sm" @click="gotoPage(2)">
2828
Ah oui oui
29-
<font-awesome-icon icon="angle-right"/>
29+
<font-awesome-icon icon="angle-right" />
3030
</button>
3131
</div>
3232
</div>
@@ -53,7 +53,7 @@
5353
<div class="text-right">
5454
<button class="btn btn-primary" @click="gotoPage(3)">
5555
Je prends la main
56-
<font-awesome-icon icon="angle-right"/>
56+
<font-awesome-icon icon="angle-right" />
5757
</button>
5858
</div>
5959
</div>
@@ -119,7 +119,7 @@
119119
placeholder="oGyw2AaPwiwO9FBIPEiBNNuYTPJvmNCClpyariSf"
120120
type="text"
121121
:disabled="accounts.fourSucres.connecting || accounts.fourSucres.connected "
122-
>
122+
/>
123123

124124
<div
125125
class="p-1 text-danger"
@@ -128,7 +128,7 @@
128128
</div>
129129
</div>
130130
</div>
131-
<hr class="m-0">
131+
<hr class="m-0" />
132132
<div class="card-body">
133133
<div class="row align-items-center">
134134
<div class="col-auto pr-0">
@@ -178,7 +178,7 @@
178178
placeholder="NNuYTPJvmNCClpyariSfoGyw2AaPwiwO9FBIPEiB"
179179
type="text"
180180
:disabled="accounts.discord.connecting || accounts.discord.connected"
181-
>
181+
/>
182182
<div
183183
class="p-1 text-danger"
184184
v-show="accounts.discord.hasError"
@@ -190,7 +190,7 @@
190190
<div class="text-right">
191191
<button class="btn btn-primary" @click="connect()">
192192
Valider
193-
<font-awesome-icon icon="check"/>
193+
<font-awesome-icon icon="check" />
194194
</button>
195195
</div>
196196
</div>
@@ -204,11 +204,11 @@
204204
>
205205
<div class="text-left">
206206
<div class="mb-5 mx-auto" style="width: 350px">
207-
<FourSucresLogo/>
207+
<FourSucresLogo />
208208
</div>
209209
<div class="row align-items-center">
210210
<div class="col-auto">
211-
<font-awesome-icon icon="sync" spin size="2x"/>
211+
<font-awesome-icon icon="sync" spin size="2x" />
212212
</div>
213213
<div class="col">
214214
<h1 class="h5 mb-0">Échanges en cours</h1>
@@ -229,11 +229,11 @@
229229
>
230230
<div class="text-left">
231231
<div class="mb-5 mx-auto" style="width: 350px">
232-
<FourSucresLogo/>
232+
<FourSucresLogo />
233233
</div>
234234
<div class="row align-items-center">
235235
<div class="col-auto">
236-
<font-awesome-icon icon="check" size="2x"/>
236+
<font-awesome-icon icon="check" size="2x" />
237237
</div>
238238
<div class="col">
239239
<h1 class="h5 mb-0 text-success">Synchronisation terminée !</h1>
@@ -252,11 +252,11 @@
252252
>
253253
<div class="text-left">
254254
<div class="mb-5 mx-auto" style="width: 350px">
255-
<FourSucresLogo/>
255+
<FourSucresLogo />
256256
</div>
257257
<div class="row align-items-center">
258258
<div class="col-auto">
259-
<font-awesome-icon icon="times" size="2x"/>
259+
<font-awesome-icon icon="times" size="2x" />
260260
</div>
261261
<div class="col">
262262
<h1 class="h5 mb-0 text-danger">Erreur !</h1>
@@ -333,9 +333,9 @@ export default {
333333
axios.defaults.headers.common["Content-Type"] =
334334
"application/x-www-form-urlencoded";
335335
axios.defaults.headers.common["Accept"] = "application/json";
336-
axios.defaults.headers.common["Authorization"] = `Bearer ${
337-
this.accounts.fourSucres.token
338-
}`;
336+
axios.defaults.headers.common[
337+
"Authorization"
338+
] = `Bearer ${this.accounts.fourSucres.token}`;
339339
axios.defaults.baseURL = "https://" + this.config.server + "/api/v1/";
340340
341341
axios
@@ -396,30 +396,34 @@ export default {
396396
this.gotoPage(6);
397397
}
398398
399+
let postEmojis = [];
400+
399401
for (const emoji of guild[1].emojis) {
400-
this.loading.status =
401-
"Serveur : " +
402-
guild[1].name +
403-
"<br>Emoji : <code>:" +
404-
emoji[1].name +
405-
":</code>";
402+
postEmojis.push({
403+
id: emoji[0],
404+
name: emoji[1].name,
405+
animated: emoji[1].animated,
406+
deleted: emoji[1].deleted,
407+
});
408+
}
409+
410+
if (postEmojis.length) {
411+
this.loading.status = "Serveur : " + guild[1].name;
412+
406413
try {
407-
await axios({
408-
url: "discord-emojis",
409-
method: "post",
410-
data: {
411-
id: emoji[0],
412-
name: emoji[1].name,
413-
animated: emoji[1].animated,
414-
deleted: emoji[1].deleted,
415-
guild_id: guild[0]
416-
}
417-
});
418-
} catch (error) {
419-
console.log(error);
420-
this.gotoPage(6);
414+
await axios({
415+
url: "discord-emojis",
416+
method: "post",
417+
data: {
418+
guild_id: guild[0],
419+
emojis: postEmojis
420+
}
421+
});
422+
} catch (error) {
423+
console.log(error);
424+
this.gotoPage(6);
425+
}
421426
}
422-
}
423427
}
424428
425429
this.gotoPage(5);

0 commit comments

Comments
 (0)