Skip to content

Instantly share code, notes, and snippets.

View ihsangan's full-sized avatar
💬
ingfokan mood buat ngoding

Ihsan ihsangan

💬
ingfokan mood buat ngoding
View GitHub Profile
@ihsangan
ihsangan / index.js
Last active July 19, 2024 02:54
Send email from Workers with MailChannel API
async function readRequestBody(request) {
const { headers } = request;
const contentType = headers.get('content-type') || '';
if (contentType.includes('application/json')) {
return JSON.stringify(await request.json());
} else if (contentType.includes('form')) {
const formData = await request.formData();
const body = {};
for (const entry of formData.entries()) {
body[entry[0]] = entry[1];
async function handleRequest(request) {
const url = new URL(request.url);
// change the hostname
url.hostname = "rule34.paheal.net";
let req = new Request(url, request);
const response = await fetch(req, {
// RequestInitCfProperties
// see: https://developers.cloudflare.com/workers/runtime-apis/request#requestinitcfproperties
cf: {
minify: {
@Allvaa
Allvaa / ExtendedMessage.js
Last active April 16, 2024 18:28
Discord.js v12 Inline Replies
const { APIMessage, Structures } = require("discord.js");
class ExtAPIMessage extends APIMessage {
resolveData() {
if (this.data) return this;
super.resolveData();
const allowedMentions = this.options.allowedMentions || this.target.client.options.allowedMentions || {};
if (allowedMentions.repliedUser !== undefined) {
if (this.data.allowed_mentions === undefined) this.data.allowed_mentions = {};
Object.assign(this.data.allowed_mentions, { replied_user: allowedMentions.repliedUser });