@@ -149,7 +149,7 @@ def type(self):
149
149
150
150
151
151
class Attachment :
152
- def __init__ (self , data ):
152
+ def __init__ (self , data , author ):
153
153
if isinstance (data , str ): # Backwards compatibility
154
154
self .id = 0
155
155
self .filename = "attachment"
@@ -159,7 +159,9 @@ def __init__(self, data):
159
159
else :
160
160
self .id = int (data ["id" ])
161
161
self .filename = data ["filename" ]
162
- self .url = data ["url" ].replace ('cdn.discordapp.com/' , os .environ ['PERMACACHE_LOCATION' ])
162
+ self .url = data ["url" ]
163
+ if author .mod :
164
+ self .url = self .url .replace ('cdn.discordapp.com/' , os .environ ['PERMACACHE_LOCATION' ])
163
165
self .is_image = data ["is_image" ]
164
166
self .size = data ["size" ]
165
167
@@ -172,17 +174,17 @@ def __init__(self, data):
172
174
class Message :
173
175
def __init__ (self , data ):
174
176
self .id = int (data ["message_id" ])
177
+ self .type = data .get ("type" , "thread_message" )
178
+ self .author = User (data ["author" ])
175
179
self .created_at = dateutil .parser .parse (data ["timestamp" ]).replace (tzinfo = None )
176
180
self .human_created_at = duration (self .created_at , now = datetime .now ())
177
181
self .raw_content = data ["content" ]
178
182
self .content = self .format_html_content (self .raw_content )
179
- self .attachments = [Attachment (a ) for a in data ["attachments" ]]
183
+ self .attachments = [Attachment (a , self . author ) for a in data ["attachments" ]]
180
184
if "stickers" in data :
181
185
self .stickers = [Sticker (a ) for a in data ["stickers" ]]
182
186
else :
183
187
self .stickers = []
184
- self .author = User (data ["author" ])
185
- self .type = data .get ("type" , "thread_message" )
186
188
self .edited = data .get ("edited" , False )
187
189
188
190
def is_different_from (self , other ):
0 commit comments