dshellInterpreter 0.2.14.5__py3-none-any.whl → 0.2.15.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dshellInterpreter might be problematic. Click here for more details.

@@ -64,7 +64,7 @@ async def dshell_respond_interaction(ctx: Interaction,
64
64
 
65
65
  return sended_message.id
66
66
 
67
- async def dshell_defer_interaction(ctx: Interaction, hide: bool = False) -> bool:
67
+ async def dshell_defer_interaction(ctx: Interaction) -> bool:
68
68
  """
69
69
  Defer a message interaction on Discord
70
70
  """
@@ -72,10 +72,7 @@ async def dshell_defer_interaction(ctx: Interaction, hide: bool = False) -> bool
72
72
  if not isinstance(ctx, Interaction):
73
73
  raise Exception(f'Respond to an interaction must be used in an interaction context, not {type(ctx)} !')
74
74
 
75
- if not isinstance(hide, bool):
76
- raise Exception(f'Hide parameter must be a boolean, not {type(hide)} !')
77
-
78
- await ctx.response.defer(ephemeral=hide)
75
+ await ctx.response.defer()
79
76
 
80
77
  return True
81
78
 
@@ -139,10 +139,18 @@ class DshellInterpreteur:
139
139
  self.env[node.name.value] = eval_expression_inline(first_node, self)
140
140
 
141
141
  elif isinstance(first_node, EmbedNode):
142
- self.env[node.name.value] = build_embed(first_node.body, first_node.fields, self)
142
+ # rebuild the embed if it already exists
143
+ if node.name.value in self.env and isinstance(self.env[node.name.value], Embed):
144
+ self.env[node.name.value] = rebuild_embed(self.env[node.name.value], first_node.body, first_node.fields, self)
145
+ else:
146
+ self.env[node.name.value] = build_embed(first_node.body, first_node.fields, self)
143
147
 
144
148
  elif isinstance(first_node, PermissionNode):
145
- self.env[node.name.value] = build_permission(first_node.body, self)
149
+ # rebuild the permissions if it already exists
150
+ if node.name.value in self.env and isinstance(self.env[node.name.value], dict):
151
+ self.env[node.name.value].update(build_permission(first_node.body, self))
152
+ else:
153
+ self.env[node.name.value] = build_permission(first_node.body, self)
146
154
 
147
155
  elif isinstance(first_node, UiNode):
148
156
  # rebuild the UI if it already exists
@@ -410,9 +418,9 @@ def length(variable : LengthNode) -> int:
410
418
  else:
411
419
  return len(variable.body.value)
412
420
 
413
- def build_embed(body: list[Token], fields: list[FieldEmbedNode], interpreter: DshellInterpreteur) -> Embed:
421
+ def build_embed_args(body: list[Token], fields: list[FieldEmbedNode], interpreter: DshellInterpreteur) -> tuple[dict, list[dict]]:
414
422
  """
415
- Builds an embed from the command information.
423
+ Builds the arguments for an embed from the command information.
416
424
  """
417
425
  args_main_embed: dict[str, list[Any]] = regroupe_commandes(body, interpreter)[0]
418
426
  args_main_embed.pop('*') # remove unspecified parameters for the embed
@@ -430,12 +438,39 @@ def build_embed(body: list[Token], fields: list[FieldEmbedNode], interpreter: Ds
430
438
  if 'color' in args_main_embed:
431
439
  args_main_embed['color'] = build_colour(args_main_embed['color']) # convert color to Colour object or int
432
440
 
441
+ return args_main_embed, args_fields
442
+
443
+ def build_embed(body: list[Token], fields: list[FieldEmbedNode], interpreter: DshellInterpreteur) -> Embed:
444
+ """
445
+ Builds an embed from the command information.
446
+ """
447
+
448
+ args_main_embed, args_fields = build_embed_args(body, fields, interpreter)
433
449
  embed = Embed(**args_main_embed) # build the main embed
434
450
  for field in args_fields:
435
451
  embed.add_field(**field) # add all fields
436
452
 
437
453
  return embed
438
454
 
455
+ def rebuild_embed(embed: Embed, body: list[Token], fields: list[FieldEmbedNode], interpreter: DshellInterpreteur) -> Embed:
456
+ """
457
+ Rebuilds an embed from an existing embed and the command information.
458
+ """
459
+ args_main_embed, args_fields = build_embed_args(body, fields, interpreter)
460
+
461
+ for key, value in args_main_embed.items():
462
+ if key == 'color':
463
+ embed.colour = value
464
+ else:
465
+ setattr(embed, key, value)
466
+
467
+ if args_fields:
468
+ embed.clear_fields()
469
+ for field in args_fields:
470
+ embed.add_field(**field)
471
+
472
+ return embed
473
+
439
474
  def build_colour(color: Union[int, ListNode]) -> Union[Colour, int]:
440
475
  """
441
476
  Builds a Colour object from an integer or a ListNode.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.14.5
3
+ Version: 0.2.15.0
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -2,7 +2,7 @@ Dshell/__init__.py,sha256=pGd94FPy8kVXH_jH566HhApQPhbPfMPnZXzH_0dPWh0,93
2
2
  Dshell/_utils.py,sha256=PJ3fwn8IMqUMnW9oTwfr9v4--rzHIhhLQoVVqjwjoJU,23
3
3
  Dshell/DISCORD_COMMANDS/__init__.py,sha256=87-YpGU74m-m7AqUQni7PGbw73JRlioQkywW_61Whms,208
4
4
  Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=PDXpxrRRWPSucdp_3ITJk0Ur3coneRJKWEl2i7GZ2EM,15696
5
- Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=gYojAOH5hl-ZL6Y1lEb87-H9MtOa8sb_VAV4_iiYfWA,3649
5
+ Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=5FA8JZ2_v98ZzOZl6EKyjo_fUQC7FuK6C6hij6ZSP30,3495
6
6
  Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
7
7
  Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=zcWl6Y1W31h9MTHS-j9tLDwcrRiE_wGOu78zu2k0y9I,9101
8
8
  Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=H0tUJOwdzYBXvxqipK3mzoNZUKrSLcVm4EZlWbBRScs,796
@@ -11,7 +11,7 @@ Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
11
11
  Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=cQvJ15f49ddOjybARwkJKNFe3ITYQciF-pZHERFPkr0,2964
12
12
  Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
13
13
  Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
14
- Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=ndzWyXLnB8py_JgT1av5FyxlDmhisXrE0gFDN_WtVDA,30842
14
+ Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=dxXhKGCQR8dKSuMRXlWyuBT_ufETdeUao29jNZD-ci4,32429
15
15
  Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
16
16
  Dshell/_DshellParser/ast_nodes.py,sha256=fU6BVe6w78ZhYib7SGR7iAfTqWqS2kvwZ0d4wMxxOHk,18366
17
17
  Dshell/_DshellParser/dshell_parser.py,sha256=YUFfBbFQ1ApOCyVhx-0nJ6S6W5MOBG6YabbkM43BKVw,21708
@@ -19,8 +19,8 @@ Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8q
19
19
  Dshell/_DshellTokenizer/dshell_keywords.py,sha256=7oeSKLXCsPRpyU31skCerOUMzd2cdm-GwofpmgTPkD0,5961
20
20
  Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
21
21
  Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=RrJA2XpcFH2vS6SnRIn5Own_uL5orIDvpq74t8xD3og,7350
22
- dshellinterpreter-0.2.14.5.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
23
- dshellinterpreter-0.2.14.5.dist-info/METADATA,sha256=kZcBqSvPrpgYkA3aaF4RvbgC20GHlVNSnfFNBuf-Y5o,1151
24
- dshellinterpreter-0.2.14.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- dshellinterpreter-0.2.14.5.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
26
- dshellinterpreter-0.2.14.5.dist-info/RECORD,,
22
+ dshellinterpreter-0.2.15.0.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
23
+ dshellinterpreter-0.2.15.0.dist-info/METADATA,sha256=k50VoOmZbcYvsLijpnpLgnjrzsdqfU23BXjnAoN-cQo,1151
24
+ dshellinterpreter-0.2.15.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ dshellinterpreter-0.2.15.0.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
26
+ dshellinterpreter-0.2.15.0.dist-info/RECORD,,