@@ -5,6 +5,8 @@ import { logger } from "../../logging.js";
55import { createStandardEmbed } from "../../util/embeds.js" ;
66import { mentionIfPingable } from "../../util/users.js" ;
77
8+ const BYPASS_TOKEN = process . env . DDB_PASTE_BYPASS_TOKEN ;
9+
810const codeBlockPattern =
911 / ` ` ` (?: (?< lang > [ a - z A - Z ] + ) ? \n ) ? (?< content > (?: .| \n ) * ?) ` ` ` | (?: (?: .| \n ) (? ! ` ` ` ) ) + / g;
1012
@@ -17,7 +19,7 @@ type SplitMessageComponent =
1719
1820export function splitMessage (
1921 message : string ,
20- threshold : number = config . pastebin . threshold ,
22+ threshold : number = config . devbin . threshold
2123) {
2224 const matches = message . matchAll ( codeBlockPattern ) ;
2325
@@ -44,9 +46,18 @@ export async function upload(component: SplitMessageComponent) {
4446 if ( "text" in component ) {
4547 return component . text ;
4648 }
49+ const header : { [ key : string ] : string } = {
50+ "Content-Type" : "application/json" ,
51+ "Accept" : "application/json"
52+ } ;
53+
54+ if ( BYPASS_TOKEN ) {
55+ header . Authorization = BYPASS_TOKEN ;
56+ }
4757
48- const response = await fetch ( `${ config . pastebin . url } /documents` , {
58+ const response = await fetch ( `${ config . devbin . api_url } /documents` , {
4959 method : "POST" ,
60+ headers : header ,
5061 body : component . content ,
5162 } ) ;
5263
@@ -57,16 +68,14 @@ export async function upload(component: SplitMessageComponent) {
5768 return "Pasting failed" ;
5869 }
5970
60- const key = ( ( await response . json ( ) ) as { key : string } ) . key ;
71+ const id = ( ( await response . json ( ) ) as { id : string } ) . id ;
6172
62- if ( ! key ) {
63- logger . warn ( "Key was missing from pastebin response" ) ;
73+ if ( ! id ) {
74+ logger . warn ( "Id was missing from pastebin response" ) ;
6475 return "Pasting failed" ;
6576 }
6677
67- return `${ config . pastebin . url } /${ key } ${
68- component . language ? `.${ component . language } ` : ""
69- } `;
78+ return `${ config . devbin . url } /paste/${ id } ` ;
7079}
7180
7281type PastifyReturn < T extends boolean > = T extends true
0 commit comments