package Ġcom . l hw dev . discord . utils Ċ Ċ import Ġdev . k ord . rest . Named File Ċ import Ġdev . k ord . rest . builder . component . Action Row Builder Ċ import Ġdev . k ord . rest . builder . component . Message Component Builder Ċ import Ġdev . k ord . rest . builder . message . Allowed Ment ions Builder Ċ import Ġdev . k ord . rest . builder . message . Embed Builder Ċ import Ġdev . k ord . rest . builder . message . create . Message Create Builder Ċ import Ġdev . k ord . rest . builder . message . modify . Message Modify Builder Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . with Context Ċ import Ġjava . io . InputStream Ċ import Ġjava . nio . file . Files Ċ import Ġjava . nio . file . Path Ċ import Ġkotlin . contracts . Experimental Contracts Ċ import Ġkotlin . contracts . Invocation Kind Ċ import Ġkotlin . contracts . contract ĊĊ Ċ interface ĠMessage Create Or Modify Builder Ġ{ ĊĉĊ ĉ /** Ċĉ Ġ* ĠThe Ġtext Ġcontent Ġof Ġthe Ġmessage . Ċĉ Ġ*/ Ċ ĉ var Ġcontent : ĠString ? ĊĉĊ ĉ /** Ċĉ Ġ* ĠThe Ġembedded Ġcontent Ġof Ġthe Ġmessage . Ċĉ Ġ*/ Ċ ĉ val Ġembed s : ĠMutable List < Embed Builder > ĊĉĊ ĉ /** Ċĉ Ġ* ĠThe Ġmentions Ġin Ġthis Ġmessage Ġthat Ġare Ġallowed Ġto Ġraise Ġa Ġnotification . Ċĉ Ġ* ĠSetting Ġthis Ġto Ġnull Ġwill Ġdefault Ġto Ġcreating Ġnotifications Ġfor Ġall Ġmentions . Ċĉ Ġ*/ Ċ ĉ var Ġallowed Ment ions : ĠAllowed Ment ions Builder ? ĊĉĊ ĉ /** Ċĉ Ġ* ĠThe Ġmessage Ġcomponents Ġto Ġinclude Ġin Ġthis Ġmessage . Ċĉ Ġ*/ ĊĉĊ ĉ val Ġcomponents : ĠMutable List < Message Component Builder > ĊĉĊ ĉ /** Ċĉ Ġ* ĠThe Ġfiles Ġto Ġinclude Ġas Ġattachments . Ċĉ Ġ*/ Ċ ĉ val Ġfiles : ĠMutable List < Named File > ĊĉĊĉĊ ĉ /** Ċĉ Ġ* ĠAdds Ġa Ġfile Ġwith Ġthe Ġ[ name ] Ġand Ġ[ content ] Ġto Ġthe Ġattachments . Ċĉ Ġ*/ Ċ ĉ fun Ġadd File ( name : ĠString , Ġcontent : ĠInputStream ): ĠNamed File Ġ{ Ċĉ ĉ val Ġnamed File Ġ= ĠNamed File ( name , Ġcontent ) Ċĉ ĉ files Ġ+= Ġnamed File Ċĉ ĉ return Ġnamed File Ċ ĉ } ĊĉĊ ĉ /** Ċĉ Ġ* ĠAdds Ġa Ġfile Ġwith Ġthe Ġgiven Ġ[ path ] Ġto Ġthe Ġattachments . Ċĉ Ġ*/ Ċ ĉ suspend Ġfun Ġadd File ( path : ĠPath ): ĠNamed File Ġ= Ġwith Context ( Dispatch ers . IO ) Ġ{ Ċĉ ĉ @ Suppress (" Blocking Method In Non Blocking Context ") Ċĉ ĉ add File ( path . fileName . toString (), ĠFiles . new InputStream ( path )) Ċ ĉ } Ċ } Ċ Ċ @ Opt In ( Experimental Contracts :: class ) Ċ inline Ġfun ĠMessage Create Or Modify Builder . embed ( block : ĠEmbed Builder . () Ġ-> ĠUnit ) Ġ{ Ċ ĉ contract Ġ{ Ċĉ ĉ calls In Place ( block , ĠInvocation Kind . EX ACT LY _ ON CE ) Ċ ĉ } ĊĉĊ ĉ embed s . add ( Embed Builder (). apply ( block )) Ċ } Ċ Ċ /** Ċ Ġ* ĠConfig ures Ġthe Ġmentions Ġthat Ġshould Ġtrigger Ġa Ġping . ĠNot Ġcalling Ġthis Ġfunction Ġwill Ġresult Ġin Ġthe Ġdefault Ġbehavior Ċ Ġ* Ġ( ping Ġeverything ), Ġcalling Ġthis Ġfunction Ġbut Ġnot Ġconfiguring Ġit Ġbefore Ġthe Ġrequest Ġis Ġbuild Ġwill Ġresult Ġin Ġall Ċ Ġ* Ġp ings Ġbeing Ġignored . Ċ Ġ*/ Ċ @ Opt In ( Experimental Contracts :: class ) Ċ inline Ġfun ĠMessage Create Or Modify Builder . allowed Ment ions ( block : ĠAllowed Ment ions Builder . () Ġ-> ĠUnit Ġ= Ġ{}) Ġ{ Ċ ĉ contract Ġ{ Ċĉ ĉ calls In Place ( block , ĠInvocation Kind . EX ACT LY _ ON CE ) Ċ ĉ } Ċ ĉ allowed Ment ions Ġ= Ġ( allowed Ment ions Ġ?: ĠAllowed Ment ions Builder ()). apply ( block ) Ċ } ĊĊ Ċ @ Opt In ( Experimental Contracts :: class ) Ċ inline Ġfun ĠMessage Create Or Modify Builder . action Row ( builder : ĠAction Row Builder . () Ġ-> ĠUnit ) Ġ{ Ċ ĉ contract Ġ{ Ċĉ ĉ calls In Place ( builder , ĠInvocation Kind . EX ACT LY _ ON CE ) Ċ ĉ } Ċ ĉ components . add ( Action Row Builder (). apply ( builder )) Ċ } ĊĊ Ċ fun ĠMessage Create Builder . as Common Builder (): ĠMessage Create Or Modify Builder Ġ= ĠMessage Create Or Modify Builder Create ( this ) Ċ Ċ class ĠMessage Create Or Modify Builder Create ( private Ġval Ġcreate : ĠMessage Create Builder ) Ġ: ĠMessage Create Or Modify Builder Ġ{ Ċ ĉ override Ġvar Ġcontent : ĠString ? Ċĉ ĉ get () Ġ= Ġcreate . content Ċĉ ĉ set ( value ) Ġ{ Ċĉĉ ĉ create . content Ġ= Ġvalue Ċĉ ĉ } Ċ ĉ override Ġval Ġembed s : ĠMutable List < Embed Builder > Ċĉ ĉ get () Ġ= Ġcreate . embed s Ċ ĉ override Ġvar Ġallowed Ment ions : ĠAllowed Ment ions Builder ? Ċĉ ĉ get () Ġ= Ġcreate . allowed Ment ions Ċĉ ĉ set ( value ) Ġ{ Ċĉĉ ĉ create . allowed Ment ions Ġ= Ġvalue Ċĉ ĉ } Ċ ĉ override Ġval Ġcomponents : ĠMutable List < Message Component Builder > Ċĉ ĉ get () Ġ= Ġcreate . components Ċ ĉ override Ġval Ġfiles : ĠMutable List < Named File > Ċĉ ĉ get () Ġ= Ġcreate . files Ċ } ĊĊ Ċ fun ĠMessage Modify Builder . as Common Builder (): ĠMessage Create Or Modify Builder Ġ= ĠMessage Create Or Modify Builder Modify ( this ) Ċ Ċ private Ġclass ĠSet On Modify List < T >( val Ġbase : ĠMutable List < T > Ġ= Ġmutable ListOf (), Ġval Ġon Modify : Ġ( Mutable List < T > ?) Ġ-> ĠUnit ) Ġ: Ċ ĉ Abstract Mutable List < T >() Ġ{ Ċ ĉ override Ġfun Ġadd ( index : ĠInt , Ġelement : ĠT ) Ġ{ Ċĉ ĉ base . add ( index , Ġelement ) Ċĉ ĉ on Modify ( this ) Ċ ĉ } ĊĉĊ ĉ override Ġfun Ġremove At ( index : ĠInt ): ĠT Ġ{ Ċĉ ĉ if ( size Ġ== Ġ 1 ) Ġon Modify ( null ) Ċĉ ĉ return Ġbase . remove At ( index ) Ċ ĉ } ĊĉĊ ĉ override Ġfun Ġset ( index : ĠInt , Ġelement : ĠT ): ĠT Ġ= Ġbase . set ( index , Ġelement ) Ċ ĉ override Ġval Ġsize : ĠInt Ġget () Ġ= Ġbase . size Ċ ĉ override Ġfun Ġget ( index : ĠInt ): ĠT Ġ= Ġbase [ index ] Ċ } Ċ Ċ class ĠMessage Create Or Modify Builder Modify ( private Ġval Ġmodify : ĠMessage Modify Builder ) Ġ: ĠMessage Create Or Modify Builder Ġ{ Ċ ĉ override Ġvar Ġcontent : ĠString ? Ċĉ ĉ get () Ġ= Ġmodify . content Ċĉ ĉ set ( value ) Ġ{ Ċĉĉ ĉ modify . content Ġ= Ġvalue Ċĉ ĉ } Ċ ĉ override Ġval Ġembed s : ĠMutable List < Embed Builder > Ġ= Ġmodify . embed s Ġ?: ĠSet On Modify List Ġ{ Ġmodify . embed s Ġ= Ġit Ġ} Ċ ĉ override Ġvar Ġallowed Ment ions : ĠAllowed Ment ions Builder ? Ċĉ ĉ get () Ġ= Ġmodify . allowed Ment ions Ċĉ ĉ set ( value ) Ġ{ Ċĉĉ ĉ modify . allowed Ment ions Ġ= Ġvalue Ċĉ ĉ } Ċ ĉ override Ġval Ġcomponents : ĠMutable List < Message Component Builder > Ċĉ ĉ get () Ġ= Ġmodify . components Ġ?: ĠSet On Modify List Ġ{ Ġmodify . components Ġ= Ġit Ġ} Ċ ĉ override Ġval Ġfiles : ĠMutable List < Named File > Ċĉ ĉ get () Ġ= Ġmodify . files Ġ?: ĠSet On Modify List Ġ{ Ġmodify . files Ġ= Ġit Ġ} Ċ } ĊĊ