dshellInterpreter 0.2.9.1__tar.gz → 0.2.9.3__tar.gz

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.

Files changed (27) hide show
  1. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/DISCORD_COMMANDS/__init__.py +2 -1
  2. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/DISCORD_COMMANDS/dshell_channel.py +5 -57
  3. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/DISCORD_COMMANDS/dshell_member.py +1 -1
  4. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/DISCORD_COMMANDS/dshell_message.py +17 -24
  5. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/DISCORD_COMMANDS/dshell_role.py +2 -1
  6. {dshellinterpreter-0.2.9.1/dshellInterpreter.egg-info → dshellinterpreter-0.2.9.3}/PKG-INFO +1 -1
  7. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  8. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/setup.py +1 -1
  9. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  10. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellInterpreteur/__init__.py +0 -0
  11. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellInterpreteur/dshell_interpreter.py +0 -0
  12. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellParser/__init__.py +0 -0
  13. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellParser/ast_nodes.py +0 -0
  14. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellParser/dshell_parser.py +0 -0
  15. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellTokenizer/__init__.py +0 -0
  16. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellTokenizer/dshell_keywords.py +0 -0
  17. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
  18. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
  19. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/__init__.py +0 -0
  20. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/Dshell/_utils.py +0 -0
  21. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/LICENSE +0 -0
  22. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/README.md +0 -0
  23. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
  24. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  25. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/dshellInterpreter.egg-info/requires.txt +0 -0
  26. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/dshellInterpreter.egg-info/top_level.txt +0 -0
  27. {dshellinterpreter-0.2.9.1 → dshellinterpreter-0.2.9.3}/setup.cfg +0 -0
@@ -2,4 +2,5 @@ from .dshell_channel import *
2
2
  from .dshell_message import *
3
3
  from .dshell_member import *
4
4
  from .dshell_pastbin import *
5
- from .dshell_role import *
5
+ from .dshell_role import *
6
+ from .utils import *
@@ -2,9 +2,11 @@ from asyncio import sleep
2
2
  from re import search
3
3
  from typing import Union
4
4
 
5
- from discord import MISSING, PermissionOverwrite, Member, Role, Message, Thread
5
+ from discord import MISSING, PermissionOverwrite, Member, Role, Message
6
6
  from discord.utils import _MissingSentinel
7
- from discord import NotFound
7
+
8
+ from .utils.utils_message import utils_get_message
9
+ from .utils.utils_thread import utils_get_thread
8
10
 
9
11
  __all__ = [
10
12
  'dshell_get_channel',
@@ -22,60 +24,6 @@ __all__ = [
22
24
  'dshell_edit_thread'
23
25
  ]
24
26
 
25
- async def utils_get_message(ctx: Message, message: Union[int, str]) -> Message:
26
- """
27
- Returns the message object of the specified message ID or link.
28
- Message is only available in the same server as the command and in the same channel.
29
- If the message is a link, it must be in the format: https://discord.com/channels/{guild_id}/{channel_id}/{message_id}
30
- """
31
-
32
- if isinstance(message, int):
33
- return await ctx.channel.fetch_message(message)
34
-
35
- elif isinstance(message, str):
36
- match = search(r'https://discord\.com/channels/(\d+)/(\d+)/(\d+)', message)
37
- if not match:
38
- raise Exception("Invalid message link format. Use a valid Discord message link.")
39
- guild_id = int(match.group(1))
40
- channel_id = int(match.group(2))
41
- message_id = int(match.group(3))
42
-
43
- if guild_id != ctx.guild.id:
44
- raise Exception("The message must be from the same server as the command !")
45
-
46
- return await ctx.guild.get_channel(channel_id).fetch_message(message_id)
47
-
48
- raise Exception(f"Message must be an integer or a string, not {type(message)} !")
49
-
50
- async def utils_get_thread(ctx: Message, thread: Union[int, str]) -> Thread:
51
- """
52
- Returns the thread object of the specified thread ID or link.
53
- Thread is only available in the same server as the command and in the same channel.
54
- If the thread is a link, it must be in the format: https://discord.com/channels/{guild_id}/{channel_id}/{message_id}
55
- """
56
-
57
- if isinstance(thread, int):
58
- return ctx.channel.get_thread(thread)
59
-
60
- elif isinstance(thread, str):
61
- match = search(r'https://discord\.com/channels/(\d+)/(\d+)(/\d+)?', thread)
62
- if not match:
63
- raise Exception("Invalid thread link format. Use a valid Discord thread link.")
64
- guild_id = int(match.group(1))
65
- message_id = int(match.group(2))
66
- channel_id = ctx.channel.id if len(match.groups()) == 3 else ctx.channel.id
67
-
68
- if guild_id != ctx.guild.id:
69
- raise Exception("The thread must be from the same server as the command !")
70
-
71
- try:
72
- c = await ctx.guild.get_channel(channel_id).fetch_message(message_id)
73
- return c.thread
74
- except NotFound:
75
- raise Exception(f"Thread with ID {message_id} not found in channel {channel_id} !")
76
-
77
- raise Exception(f"Thread must be an integer or a string, not {type(thread)} !")
78
-
79
27
 
80
28
  async def dshell_get_channel(ctx: Message, name):
81
29
  """
@@ -338,7 +286,7 @@ async def dshell_create_thread_message(ctx: Message,
338
286
  if message is None:
339
287
  message = ctx.id
340
288
 
341
- message = await utils_get_message(ctx, message)
289
+ message = utils_get_message(ctx, message)
342
290
 
343
291
 
344
292
  if not isinstance(name, str):
@@ -17,7 +17,7 @@ __all__ = [
17
17
  "dshell_remove_member_roles"
18
18
  ]
19
19
 
20
- async def dshell_send_private_message(ctx: Message, member: int = None, message: str = None, delete: int = None, embeds = None, ):
20
+ async def dshell_send_private_message(ctx: Message, message: str = None, member: int = None, delete: int = None, embeds = None, ):
21
21
  """
22
22
  Sends a private message to a member.
23
23
  If member is None, sends the message to the author of the command.
@@ -3,6 +3,8 @@ from re import search
3
3
  from discord import Embed, Message, NotFound
4
4
  from discord.ext import commands
5
5
 
6
+ from .utils.utils_message import utils_get_message
7
+
6
8
  __all__ = [
7
9
  'dshell_send_message',
8
10
  'dshell_respond_message',
@@ -48,14 +50,15 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
48
50
  return sended_message.id
49
51
 
50
52
 
51
- async def dshell_respond_message(ctx: Message, message=None, delete=None, embeds=None):
53
+ async def dshell_respond_message(ctx: Message, message=None, content: str = None, delete=None, mention: bool = None, embeds=None):
52
54
  """
53
55
  Responds to a message on Discord
54
56
  """
55
57
  if delete is not None and not isinstance(delete, (int, float)):
56
58
  raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
57
59
 
58
- respond_message = ctx if message is None else ctx.channel.get_partial_message(message) # builds a reference to the message (even if it doesn't exist)
60
+ respond_message = ctx if message is None else utils_get_message(ctx, message) # builds a reference to the message (even if it doesn't exist)
61
+ mention_author = mention if mention is not None else False
59
62
 
60
63
  from .._DshellParser.ast_nodes import ListNode
61
64
 
@@ -68,7 +71,9 @@ async def dshell_respond_message(ctx: Message, message=None, delete=None, embeds
68
71
  else:
69
72
  raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
70
73
 
71
- sended_message = await ctx.reply(respond_message,
74
+ sended_message = await ctx.reply(reference=respond_message,
75
+ content=content,
76
+ mention_author=mention_author,
72
77
  delete_after=delete,
73
78
  embeds=embeds)
74
79
 
@@ -79,8 +84,7 @@ async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0
79
84
  Deletes a message
80
85
  """
81
86
 
82
- delete_message = ctx if message is None else ctx.channel.get_partial_message(
83
- message) # builds a reference to the message (even if it doesn't exist)
87
+ delete_message = ctx if message is None else utils_get_message(ctx, message)
84
88
 
85
89
  if not isinstance(delay, int):
86
90
  raise Exception(f'Delete delay must be an integer, not {type(delay)} !')
@@ -91,7 +95,7 @@ async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0
91
95
  await delete_message.delete(delay=delay, reason=reason)
92
96
 
93
97
 
94
- async def dshell_purge_message(ctx: Message, message_number, channel=None, reason=None):
98
+ async def dshell_purge_message(ctx: Message, message_number: int, channel=None, reason=None):
95
99
  """
96
100
  Purges messages from a channel
97
101
  """
@@ -111,8 +115,7 @@ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=No
111
115
  """
112
116
  Edits a message
113
117
  """
114
- edit_message = ctx.channel.get_partial_message(
115
- message) # builds a reference to the message (even if it doesn't exist)
118
+ edit_message = utils_get_message(ctx, message)
116
119
 
117
120
  if embeds is None:
118
121
  embeds = []
@@ -168,8 +171,7 @@ async def dshell_add_reactions(ctx: Message, reactions, message=None):
168
171
  """
169
172
  Adds reactions to a message
170
173
  """
171
- message = ctx if message is None else ctx.channel.get_partial_message(
172
- message) # builds a reference to the message (even if it doesn't exist)
174
+ message = ctx if message is None else utils_get_message(ctx, message)
173
175
 
174
176
  if isinstance(reactions, str):
175
177
  reactions = (reactions,)
@@ -184,8 +186,7 @@ async def dshell_remove_reactions(ctx: Message, reactions, message=None):
184
186
  """
185
187
  Removes reactions from a message
186
188
  """
187
- message = ctx if message is None else ctx.channel.get_partial_message(
188
- message) # builds a reference to the message (even if it doesn't exist)
189
+ message = ctx if message is None else utils_get_message(ctx, message)
189
190
 
190
191
  if isinstance(reactions, str):
191
192
  reactions = [reactions]
@@ -199,29 +200,21 @@ async def dshell_clear_message_reactions(ctx: Message, message):
199
200
  """
200
201
  Clear all reaction on the target message
201
202
  """
202
- if not isinstance(message, int):
203
- raise Exception(f'Message must be integer, not {type(message)}')
204
-
205
- target_message = await ctx.channel.fetch_message(message)
203
+ message = ctx if message is None else utils_get_message(ctx, message)
206
204
 
207
- if target_message is None:
205
+ if message is None:
208
206
  raise Exception(f'Message not found !')
209
207
 
210
- await target_message.clear_reactions()
208
+ await message.clear_reactions()
211
209
 
212
210
  async def dshell_clear_one_reactions(ctx: Message, message, emoji):
213
211
  """
214
212
  Clear one emoji on the target message
215
213
  """
216
- if not isinstance(message, int):
217
- raise Exception(f'Message must be integer, not {type(message)}')
218
214
 
219
215
  if not isinstance(emoji, str):
220
216
  raise Exception(f'Emoji must be string, not {type(emoji)}')
221
217
 
222
- try:
223
- target_message = await ctx.channel.fetch_message(message)
224
- except NotFound:
225
- raise Exception(f'Message not found !')
218
+ target_message = ctx if message is None else utils_get_message(ctx, message)
226
219
 
227
220
  await target_message.clear_reaction(emoji)
@@ -1,5 +1,6 @@
1
1
  from discord import MISSING, Message, PermissionOverwrite
2
2
  from discord.utils import _MissingSentinel
3
+ from typing import Union
3
4
  from .._utils import NoneType
4
5
 
5
6
  __all__ = [
@@ -56,7 +57,7 @@ async def dshell_delete_roles(ctx: Message, roles, reason=None):
56
57
  Delete the role on the server
57
58
  """
58
59
  from .._DshellInterpreteur.dshell_interpreter import ListNode
59
- roles: int | ListNode
60
+ roles: Union[int, ListNode]
60
61
  if not isinstance(roles, (int, ListNode)):
61
62
  raise Exception(f"Role must be a int, role mention or NodeList of both, not {type(roles)} !")
62
63
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.9.1
3
+ Version: 0.2.9.3
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.9.1
3
+ Version: 0.2.9.3
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
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="dshellInterpreter",
8
- version="0.2.9.1",
8
+ version="0.2.9.3",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",