import { ShardClient , Structures } from 'detritus-client' ; import { RequestTypes } from 'detritus-client-rest' ; import { Response , createHeaders } from 'detritus-rest' ; import { HTTPMethods } from 'detritus-rest/lib/constants' ; import { Api , LOCALHOST_API } from './endpoints' ; import { RestOptions , RestResponsesRaw , RestResponses } from './types' ; import { GoogleLocales , GuildAllowlistTypes , GuildBlocklistTypes , GuildDisableCommandsTypes , NotSoHeaders , } from '../constants' ; export interface RequestContext { channelId ? : string ; client : ShardClient ; guildId ? : string ; user ? : Structures . User ; } export async function request ( context , options ) { options . url = Api . URL + Api . PATH ; options . headers = createHeaders ( options . headers ) ; if ( Api . URL === LOCALHOST_API ) { options . headers . set ( 'host' , 'beta.notsobot.com' ) ; } const token = process . env . NOTSOBOT_API_TOKEN ; if ( token ) { options . headers . set ( NotSoHeaders . AUTHORIZATION , `Bot ${ token }` ) ; } const { channelId , client , guildId , user } = context ; if ( channelId ) { options . headers . set ( NotSoHeaders . CHANNEL_ID , channelId ) ; } if ( guildId ) { options . headers . set ( NotSoHeaders . GUILD_ID , guildId ) ; } if ( user ) { options . headers . set ( NotSoHeaders . USER_ID , user . id ) ; const bareUser = JSON . stringify ( { avatar : user . avatar , discriminator : user . discriminator , bot : user . bot , id : user . id , username : user . username , } ) ; options . headers . set ( NotSoHeaders . USER , Buffer . from ( bareUser ) . toString ( 'base64' ) ) ; } return client . rest . request ( options ) ; } export async function createGuildAllowlist ( context , guildId , allowlistId , type ) { return request ( context , { route : { method : HTTPMethods . PUT , path : Api . GUILD_ALLOWLIST , params : { allowlistId , guildId , type } , } , } ) ; } export async function createGuildBlocklist ( context , guildId , blocklistId , type ) { return request ( context , { route : { method : HTTPMethods . PUT , path : Api . GUILD_BLOCKLIST , params : { blocklistId , guildId , type } , } , } ) ; } export async function createGuildDisabledCommand ( context , guildId , command , disabledId , type ) { return request ( context , { route : { method : HTTPMethods . PUT , path : Api . GUILD_DISABLED_COMMAND , params : { command , disabledId , guildId , type } , } , } ) ; } export async function createGuildLogger ( context , guildId , options ) { const body = { channel_id : options . channelId , type : options . type , webhook_id : options . webhookId , webhook_token : options . webhookToken , } ; const params = { guildId } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . GUILD_LOGGERS , params , } , } ) ; } export async function createGuildPrefix ( context , guildId , prefix ) { const body = { prefix } ; const params = { guildId } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . GUILD_PREFIXES , params , } , } ) ; } export async function createUserCommand ( context , userId , command , options ) { const body = { channel_id : options . channelId , content : options . content , content_url : options . contentUrl , edited_timestamp : options . editedTimestamp , failed_reason : options . failedReason , guild_id : options . guildId , message_id : options . messageId , response_id : options . responseId , response_url : options . responseUrl , } ; const params = { userId , command } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . USER_COMMAND , params , } , } ) ; } export async function deleteGuildAllowlist ( context , guildId , allowlistId , type ) { return request ( context , { route : { method : HTTPMethods . DELETE , path : Api . GUILD_ALLOWLIST , params : { allowlistId , guildId , type } , } , } ) ; } export async function deleteGuildBlocklist ( context , guildId , blocklistId , type ) { return request ( context , { route : { method : HTTPMethods . DELETE , path : Api . GUILD_BLOCKLIST , params : { blocklistId , guildId , type } , } , } ) ; } export async function deleteGuildDisabledCommand ( context , guildId , command , disabledId , type ) { return request ( context , { route : { method : HTTPMethods . DELETE , path : Api . GUILD_DISABLED_COMMAND , params : { command , disabledId , guildId , type } , } , } ) ; } export async function deleteGuildLogger ( context , guildId , options ) { const body = { channel_id : options . channelId , type : options . type , } ; const params = { guildId } ; return request ( context , { body , route : { method : HTTPMethods . POST , path : Api . GUILD_LOGGERS_DELETE , params , } , } ) ; } export async function deleteGuildPrefix ( context , guildId , prefix ) { const body = { prefix } ; const params = { guildId } ; return request ( context , { body , route : { method : HTTPMethods . POST , path : Api . GUILD_PREFIXES_DELETE , params , } , } ) ; } export async function deleteTag ( context , options ) { const query = { name : options . name , server_id : options . serverId , } ; return request ( context , { query , route : { method : HTTPMethods . DELETE , path : Api . TAGS , } , } ) ; } export async function editGuildSettings ( context , guildId , options = { } ) { const body = { allowlist : options . allowlist , blocked : options . blocked , blocklist : options . blocklist , disabled_commands : options . disabledCommands , prefixes : options . prefixes , timezone : options . timezone , } ; const params = { guildId } ; return request ( context , { body , route : { method : HTTPMethods . PATCH , path : Api . GUILD , params , } , } ) ; } export async function editUser ( context , userId , options ) { const body = { blocked : options . blocked , locale : options . locale , } ; const params = { userId } ; return request ( context , { body , route : { method : HTTPMethods . PATCH , path : Api . USER , params , } , } ) ; } export async function fetchGuildSettings ( context , guildId ) { const params = { guildId } ; return request ( context , { route : { method : HTTPMethods . GET , path : Api . GUILD , params , } , } ) ; } export async function fetchTag ( context , options ) { const query = { name : options . name , server_id : options . serverId , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . TAGS , } , } ) ; } export async function fetchTagRandom ( context , options = { } ) { const query = { content : options . content , name : options . name , server_id : options . serverId , user_id : options . userId , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . TAGS_RANDOM , } , } ) ; } export async function fetchTagsServer ( context , serverId , options = { } ) { const params = { serverId } ; const query = { after : options . after , before : options . before , content : options . content , limit : options . limit , name : options . name , user_id : options . userId , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . TAGS_SERVER , params , } , } ) ; } export async function fetchUser ( context , userId ) { const params = { userId } ; return request ( context , { route : { method : HTTPMethods . GET , path : Api . USER , params , } , } ) ; } export async function fetchUserTags ( context , userId , options = { } ) { const params = { userId } ; const query = { after : options . after , before : options . before , content : options . content , limit : options . limit , name : options . name , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . USER_TAGS , params , } , } ) ; } export async function funASCII ( context , options ) { const query = { text : options . text , } ; return request ( context , { query , route : { method : HTTPMethods . POST , path : Api . FUN_ASCII , } , } ) ; } export async function funTextToSpeech ( context , options ) { const query = { text : options . text , voice : options . voice , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . GET , path : Api . FUN_TEXT_TO_SPEECH , } , } ) ; } export async function googleContentVisionLabels ( context , options ) { const body = { url : options . url , } ; return request ( context , { body , route : { method : HTTPMethods . POST , path : Api . GOOGLE_CONTENT_VISION_LABELS , } , } ) ; } export async function googleContentVisionOCR ( context , options ) { const body = { url : options . url , } ; return request ( context , { body , route : { method : HTTPMethods . POST , path : Api . GOOGLE_CONTENT_VISION_OCR , } , } ) ; } export async function googleContentVisionSafeSearch ( context , options ) { const body = { url : options . url , } ; return request ( context , { body , route : { method : HTTPMethods . POST , path : Api . GOOGLE_CONTENT_VISION_SAFE_SEARCH , } , } ) ; } export async function googleContentVisionWebDetection ( context , options ) { const body = { url : options . url , } ; return request ( context , { body , route : { method : HTTPMethods . POST , path : Api . GOOGLE_CONTENT_VISION_WEB_DETECTION , } , } ) ; } export async function googleTranslate ( context , options ) { const query = { from : options . from , text : options . text , to : options . to , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . GOOGLE_TRANSLATE , } , } ) ; } export async function imageCreateTombstone ( context , options ) { const query = { line_1 : options . line1 , line_2 : options . line2 , line_3 : options . line3 , line_4 : options . line4 , line_5 : options . line5 , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_CREATE_TOMBSTONE , } , } ) ; } export async function imageInformationExif ( context , options ) { const query = { url : options . url , } ; return request ( context , { query , route : { method : HTTPMethods . POST , path : Api . IMAGE_INFORMATION_EXIF , } , } ) ; } export async function imageManipulationAscii ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_ASCII , } , } ) ; } export async function imageManipulationBlur ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_BLUR , } , } ) ; } export async function imageManipulationBlurple ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_BLURPLE , } , } ) ; } export async function imageManipulationCircle ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_CIRCLE , } , } ) ; } export async function imageManipulationDeepfry ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_DEEPFRY , } , } ) ; } export async function imageManipulationExplode ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_EXPLODE , } , } ) ; } export async function imageManipulationEyes ( context , options ) { const query = { type : options . type , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_EYES , } , } ) ; } export async function imageManipulationFlip ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_FLIP , } , } ) ; } export async function imageManipulationFlop ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_FLOP , } , } ) ; } export async function imageManipulationGlitch ( context , options ) { const query = { amount : options . amount , iterations : options . iterations , seed : options . seed , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_GLITCH , } , } ) ; } export async function imageManipulationGold ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_GOLD , } , } ) ; } export async function imageManipulationGrayscale ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_GRAYSCALE , } , } ) ; } export async function imageManipulationImplode ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_IMPLODE , } , } ) ; } export async function imageManipulationInvert ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_INVERT , } , } ) ; } export async function imageManipulationJPEG ( context , options ) { const query = { quality : options . quality , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_JPEG , } , } ) ; } export async function imageManipulationLegofy ( context , options ) { const query = { dither : options . dither , palette : options . palette , size : options . size , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_LEGOFY , } , } ) ; } export async function imageManipulationMagik ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_MAGIK , } , } ) ; } export async function imageManipulationMagikGif ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_MAGIK_GIF , } , } ) ; } export async function imageManipulationMeme ( context , options ) { const query = { bottom : options . bottom , font : options . font , top : options . top , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_MEME , } , } ) ; } export async function imageManipulationMirrorBottom ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_MIRROR_BOTTOM , } , } ) ; } export async function imageManipulationMirrorLeft ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_MIRROR_LEFT , } , } ) ; } export async function imageManipulationMirrorRight ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_MIRROR_RIGHT , } , } ) ; } export async function imageManipulationMirrorTop ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_MIRROR_TOP , } , } ) ; } export async function imageManipulationPixelate ( context , options ) { const query = { pixel_width : options . pixelWidth , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_PIXELATE , } , } ) ; } export async function imageManipulationRain ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_RAIN , } , } ) ; } export async function imageManipulationRainGold ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_RAIN_GOLD , } , } ) ; } export async function imageManipulationSharpen ( context , options ) { const query = { scale : options . scale , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_SHARPEN , } , } ) ; } export async function imageManipulationSpin ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_SPIN , } , } ) ; } export async function imageManipulationWall ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_MANIPULATION_WALL , } , } ) ; } export async function imageOverlayFlagIsrael ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_ISRAEL , } , } ) ; } export async function imageOverlayFlagLGBT ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_LGBT , } , } ) ; } export async function imageOverlayFlagNorthKorea ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_NORTH_KOREA , } , } ) ; } export async function imageOverlayFlagTrans ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_TRANS , } , } ) ; } export async function imageOverlayFlagRussia ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_RUSSIA , } , } ) ; } export async function imageOverlayFlagUK ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_UK , } , } ) ; } export async function imageOverlayFlagUSA ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_USA , } , } ) ; } export async function imageOverlayFlagUSSR ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_FLAG_USSR , } , } ) ; } export async function imageOverlayGoldstar ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_GOLDSTAR , } , } ) ; } export async function imageOverlayHalfLifePistol ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_HALF_LIFE_PISTOL , } , } ) ; } export async function imageOverlayHalfLifeShotgun ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_HALF_LIFE_SHOTGUN , } , } ) ; } export async function imageOverlayHalfLifeSMG ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_HALF_LIFE_SMG , } , } ) ; } export async function imageOverlayShutterstock ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_OVERLAY_SHUTTERSTOCK , } , } ) ; } export async function imageToolsBackgroundRemove ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_TOOLS_BACKGROUND_REMOVE , } , } ) ; } export async function imageToolsConvert ( context , options ) { const query = { size : options . size , to : options . to , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_TOOLS_CONVERT , } , } ) ; } export async function imageToolsGifReverse ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_TOOLS_GIF_REVERSE , } , } ) ; } export async function imageToolsGifSeeSaw ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_TOOLS_GIF_SEE_SAW , } , } ) ; } export async function imageToolsGifSpeed ( context , options ) { const query = { loop : options . loop , speed : options . speed , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_TOOLS_GIF_SPEED , } , } ) ; } export async function imageToolsResize ( context , options ) { const query = { convert : options . convert , scale : options . scale , size : options . size , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_TOOLS_RESIZE , } , } ) ; } export async function imageToolsRotate ( context , options ) { const query = { crop : options . crop , degrees : options . degrees , url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . IMAGE_TOOLS_ROTATE , } , } ) ; } export async function putGuildSettings ( context , guildId , options ) { const body = { icon : options . icon , name : options . name , } ; const params = { guildId } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . GUILD , params , } , } ) ; } export async function putInfoDiscord ( context , options ) { const body = { cluster_id : options . clusterId , ram_usage : options . ramUsage , shard_count : options . shardCount , shards_per_cluster : options . shardsPerCluster , shards : options . shards . map ( ( x ) => { return { shard_id : x . shardId , status : x . status , applications : x . applications , channels : x . channels , channel_threads : x . channelThreads , emojis : x . emojis , events : x . events , guilds : x . guilds , members : x . members , member_count : x . memberCount , messages : x . messages , permission_overwrites : x . permissionOverwrites , presences : x . presences , presence_activities : x . presenceActivities , roles : x . roles , stage_instances : x . stageInstances , typings : x . typings , users : x . users , voice_states : x . voiceStates , } ; } ) , } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . INFO_DISCORD , } , } ) ; } export async function putTag ( context , options ) { const body = { content : options . content , name : options . name , server_id : options . serverId , } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . TAGS , } , } ) ; } export async function putUser ( context , userId , options ) { const body = { avatar : options . avatar , bot : options . bot , discriminator : options . discriminator , locale : options . locale , username : options . username , } ; const params = { userId } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . USER , params , } , } ) ; } export async function searchDuckDuckGo ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_DUCKDUCKGO , } , } ) ; } export async function searchDuckDuckGoImages ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_DUCKDUCKGO_IMAGES , } , } ) ; } export async function searchE621 ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_E621 , } , } ) ; } export async function searchE926 ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_E926 , } , } ) ; } export async function searchGoogle ( context , options ) { const query = { locale : options . locale , max_results : options . maxResults , query : options . query , safe : options . safe , show_unknown : options . showUnknown , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_GOOGLE , } , } ) ; } export async function searchGoogleImages ( context , options ) { const query = { locale : options . locale , max_results : options . maxResults , query : options . query , safe : options . safe , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_GOOGLE_IMAGES , } , } ) ; } export async function searchGoogleReverseImages ( context , options ) { const query = { url : options . url , } ; return request ( context , { query , route : { method : HTTPMethods . POST , path : Api . SEARCH_GOOGLE_REVERSE_IMAGES , } , } ) ; } export async function searchReddit ( context , options ) { const query = { query : options . query , safe : options . safe , sort : options . sort , subreddit : options . subreddit , time : options . time , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_REDDIT , } , } ) ; } export async function searchRule34 ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_RULE34 , } , } ) ; } export async function searchRule34Paheal ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_RULE34_PAHEAL , } , } ) ; } export async function searchSteam ( context , options ) { const query = { query : options . query , steam_id : options . steamId , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_STEAM , } , } ) ; } export async function searchSteamEmoji ( context , emoji ) { return request ( context , { route : { method : HTTPMethods . GET , path : Api . SEARCH_STEAM_EMOJIS_EMOJI , params : { emoji } , } , } ) ; } export async function searchSteamEmojis ( context , options ) { const query = { max_results : options . maxResults , query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_STEAM_EMOJIS , } , } ) ; } export async function searchSteamProfile ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_STEAM_PROFILE , } , } ) ; } export async function searchUrban ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_URBAN_DICTIONARY , } , } ) ; } export async function searchUrbanRandom ( context , options = { } ) { return request ( context , { route : { method : HTTPMethods . GET , path : Api . SEARCH_URBAN_DICTIONARY_RANDOM , } , } ) ; } export async function searchWikihow ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_WIKIHOW , } , } ) ; } export async function searchWikihowRandom ( context , options = { } ) { return request ( context , { route : { method : HTTPMethods . GET , path : Api . SEARCH_WIKIHOW_RANDOM , } , } ) ; } export async function searchWolframAlpha ( context , options ) { const query = { query : options . query , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_WOLFRAM_ALPHA , } , } ) ; } export async function searchYoutube ( context , options ) { const query = { query : options . query , sp : options . sp , } ; return request ( context , { query , route : { method : HTTPMethods . GET , path : Api . SEARCH_YOUTUBE , } , } ) ; } export async function uploadCommands ( context , options ) { const body = { commands : options . commands , } ; return request ( context , { body , route : { method : HTTPMethods . PUT , path : Api . COMMANDS , } , } ) ; } export async function utilitiesFetchData ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . GET , path : Api . UTILITIES_FETCH_DATA , } , } ) ; } export async function utilitiesFetchImage ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . GET , path : Api . UTILITIES_FETCH_IMAGE , } , } ) ; } export async function utilitiesFetchMedia ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . GET , path : Api . UTILITIES_FETCH_MEDIA , } , } ) ; } export async function utilitiesFetchText ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . GET , path : Api . UTILITIES_FETCH_TEXT , } , } ) ; } export async function utilitiesQrCreate ( context , options ) { const query = { margin : options . margin , query : options . query , size : options . size , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . GET , path : Api . UTILITIES_QR_CREATE , } , } ) ; } export async function utilitiesQrScan ( context , options ) { const query = { url : options . url , } ; const response = await request ( context , { dataOnly : false , query , route : { method : HTTPMethods . POST , path : Api . UTILITIES_QR_SCAN , } , } ) ; return { scanned : await response . json ( ) , url : response . headers . get ( 'x-unfurled-url' ) , } ; } export async function utilitiesScreenshot ( context , options ) { const query = { url : options . url , } ; return request ( context , { dataOnly : false , query , route : { method : HTTPMethods . GET , path : Api . UTILITIES_SCREENSHOT , } , } ) ; }