@@ -132,7 +132,7 @@ async def run(self, args: dict[str, Any], ctx: "HarnessContext") -> ToolResult:
132132
133133 scope = ctx .identity .guild_id or f"dm:{ ctx .identity .user_id } "
134134 user_id = ctx .identity .user_id or "unknown"
135- channel_id = ctx .identity .thread_id or ctx . identity . channel_id or ""
135+ channel_id = ctx .identity .channel_id or ""
136136
137137 if args .get ("list" ):
138138 return ToolResult (call_id = "" , content = _render_effective (ctx .store , scope , channel_id , user_id ))
@@ -158,9 +158,16 @@ async def run(self, args: dict[str, Any], ctx: "HarnessContext") -> ToolResult:
158158 key = _kv_key (term , layer , entity )
159159
160160 if args .get ("remove" ):
161- ctx .store .kv_delete (scope , key )
162- tag = _layer_tag (layer , entity , user_id , channel_id )
163- return ToolResult (call_id = "" , content = f"🗑️ **{ term } ** [{ tag } ] 삭제" )
161+ # 세 scope 전체를 스캔해서 존재하는 항목 모두 삭제
162+ deleted_tags : list [str ] = []
163+ for lyr , ent in [("guild" , "" ), ("channel" , channel_id ), ("member" , user_id )]:
164+ k = _kv_key (term , lyr , ent )
165+ if ctx .store .kv_get (scope , k ) is not None :
166+ ctx .store .kv_delete (scope , k )
167+ deleted_tags .append (_layer_tag (lyr , ent , user_id , channel_id ))
168+ if not deleted_tags :
169+ return ToolResult (call_id = "" , content = f"⚠️ **{ term } ** — 등록된 정의가 없습니다." )
170+ return ToolResult (call_id = "" , content = f"🗑️ **{ term } ** [{ ', ' .join (deleted_tags )} ] 삭제" )
164171
165172 definition = str (args .get ("definition" , "" )).strip ()
166173 if not definition :
0 commit comments