UNPKG

8.85 kBJavaScriptView Raw
1const fetch = require('node-fetch')
2const baseurl = 'https://frenchnoodles.xyz/api/endpoints/'
3
4
5
6async function request(endpoint, input='') {
7 const res = await fetch(`${baseurl}${endpoint}/?${input}`, {
8 headers: {'User-Agent': `noodles-wrapper@${process.env.npm_package_version}(https://www.npmjs.com/package/noodles-wrapper) by French Noodles#4000`}
9 });
10 if(res.status == 429) {console.log(await res.json()); throw new Error('You have been rate limited')}
11 else return res.buffer()
12}
13
14module.exports.drake = async function(text1, text2) {
15 if(!text1) throw new Error('The field text1 was left empty in the drake function')
16 if(!text2) throw new Error('The field text2 was left empty in the drake function')
17 const input = `text1=${encodeURIComponent(text1)}&text2=${encodeURIComponent(text2)}`
18 const response = await request('drake', input)
19 return response
20}
21
22module.exports.worthless = async function(text) {
23 if(!text) throw new Error('The field text was left empty in worthless function')
24 const input = `text=${encodeURIComponent(text)}`
25 const response = await request('worthless', input)
26 return response
27}
28
29module.exports.presidentialalert = async function(text) {
30 if(!text) throw new Error('The field text was left empty in presidentialalert function')
31 const input = `text=${encodeURIComponent(text)}`
32 const response = await request('presidentialalert', input)
33 return response
34}
35
36module.exports.spongebobburnpaper = async function(text) {
37 if(!text) throw new Error('The field text was left empty in spongebobburnpaper function')
38 const input = `text=${encodeURIComponent(text)}`
39 const response = await request('spongebobburnpaper', input)
40 return response
41}
42
43
44module.exports.lisastage = async function(text) {
45 if(!text) throw new Error('The field text was left empty in lisastage function')
46 const input = `text=${encodeURIComponent(text)}`
47 const response = await request('lisastage', input)
48 return response
49}
50
51module.exports.changemymind = async function(text) {
52 if(!text) throw new Error('The field text was left empty in changemymind function')
53 const input = `text=${encodeURIComponent(text)}`
54 const response = await request('changemymind', input)
55 return response
56}
57
58module.exports.awkwardmonkey = async function(text) {
59 if(!text) throw new Error('The field text was left empty in awkwardmonkey function')
60 const input = `text=${encodeURIComponent(text)}`
61 const response = await request('awkwardmonkey', input)
62 return response
63}
64
65module.exports.blur = async function(image) {
66 if(!image) throw new Error('The field text was left empty in blur function')
67 const input = `image=${encodeURIComponent(image)}`
68 const response = await request('blur', input)
69 return response
70}
71
72module.exports.invert = async function(image) {
73 if(!image) throw new Error('The field text was left empty in invert function')
74 const input = `image=${encodeURIComponent(image)}`
75 const response = await request('invert', input)
76 return response
77}
78
79module.exports.edges = async function(image) {
80 if(!image) throw new Error('The field text was left empty in edges function')
81 const input = `image=${encodeURIComponent(image)}`
82 const response = await request('edges', input)
83 return response
84}
85
86module.exports.circle = async function(image) {
87 if(!image) throw new Error('The field text was left empty in circle function')
88 const input = `image=${encodeURIComponent(image)}`
89 const response = await request('circle', input)
90 return response
91}
92
93module.exports.wide = async function(image) {
94 if(!image) throw new Error('The field text was left empty in wide function')
95 const input = `image=${encodeURIComponent(image)}`
96 const response = await request('wide', input)
97 return response
98}
99
100module.exports.uglyupclose = async function(image) {
101 if(!image) throw new Error('The field text was left empty in uglyupclose function')
102 const input = `image=${encodeURIComponent(image)}`
103 const response = await request('uglyupclose', input)
104 return response
105}
106
107module.exports.clown = async function(image) {
108 if(!image) throw new Error('The field text was left empty in clown function')
109 const input = `image=${encodeURIComponent(image)}`
110 const response = await request('clown', input)
111 return response
112}
113
114module.exports.rip = async function(image) {
115 if(!image) throw new Error('The field text was left empty in rip function')
116 const input = `image=${encodeURIComponent(image)}`
117 const response = await request('rip', input)
118 return response
119}
120
121module.exports.affectbaby = async function(image) {
122 if(!image) throw new Error('The field text was left empty in affectbaby function')
123 const input = `image=${encodeURIComponent(image)}`
124 const response = await request('affectbaby', input)
125 return response
126}
127
128module.exports.trash = async function(image) {
129 if(!image) throw new Error('The field text was left empty in trash function')
130 const input = `image=${encodeURIComponent(image)}`
131 const response = await request('trash', input)
132 return response
133}
134
135module.exports.welcomebanner = class welcomebanner{
136 constructor(){}
137 setBackground(value) { this.background = value; return this}
138 setAvatar(value) { this.avatar = value; return this}
139 setTitle(value) { this.title = value; return this}
140 setText1(value) { this.text1 = value; return this}
141 setSubtitle(value) { this.subtitle = value; return this}
142 setTextColor(value) { this.textcolor = value; return this}
143 build(){
144 return welcomebannerbuild(this.background, this.avatar, this.title, this.text1, this.subtitle, this.textcolor);
145 }
146}
147async function welcomebannerbuild(background, avatar, title, text1, subtitle, textcolor) {
148 if(!background) throw new Error('The field background was left empty in welcomebanner function')
149 if(!avatar) throw new Error('The field avatar was left empty in welcomebanner function')
150 if(!title) throw new Error('The field title was left empty in welcomebanner function')
151 if(!subtitle) throw new Error('The field subtitle was left empty in welcomebanner function')
152 if(!textcolor) throw new Error('The field textcolor was left empty in welcomebanner function')
153 const input = `background=${encodeURIComponent(background)}&avatar=${encodeURIComponent(avatar)}&title=${encodeURIComponent(title)}&text1=${encodeURIComponent(text1)}&subtitle=${encodeURIComponent(subtitle)}&textcolor=${encodeURIComponent(textcolor.replace('#', ''))}`
154 const response = await request('welcomebanner', input)
155 return response
156}
157
158module.exports.boostercard = async function(image) {
159 if(!image) throw new Error('The field text was left empty in boostercard function')
160 const input = `image=${encodeURIComponent(image)}`
161 const response = await request('boostercard', input)
162 return response
163}
164
165module.exports.balancecard = class balancecard{
166 constructor(){}
167 setBackground(value) { this.background = value; return this}
168 setAvatar(value) { this.avatar = value; return this}
169 setTitle(value) { this.title = value; return this}
170 setText1(value) { this.text1 = value; return this}
171 setText2(value) { this.text2 = value; return this}
172 setTextColor(value) { this.textcolor = value; return this}
173 build(){
174 return balancecardbuild(this.background, this.avatar, this.title, this.text1, this.text2, this.textcolor);
175 }
176}
177async function balancecardbuild(background, avatar, title, text1, text2, textcolor) {
178 if(!background) throw new Error('The field background was left empty in balancecard function')
179 if(!avatar) throw new Error('The field avatar was left empty in balancecard function')
180 if(!title) throw new Error('The field title was left empty in balancecard function')
181 if(!text1) throw new Error('The field text1 was left empty in balancecard function')
182 if(!text2) throw new Error('The field text2 was left empty in balancecard function')
183 if(!textcolor) throw new Error('The field textcolor was left empty in balancecard function')
184 const input = `background=${encodeURIComponent(background)}&avatar=${encodeURIComponent(avatar)}&title=${encodeURIComponent(title)}&text1=${encodeURIComponent(text1)}&text2=${encodeURIComponent(text2)}&textcolor=${encodeURIComponent(textcolor.replace('#', ''))}`
185 const response = await request('balancecard', input)
186 return response
187}
188
189module.exports.randommeme = async function() {
190 const response = await request('randommeme')
191 return response
192}
\No newline at end of file