@@ -153,6 +153,67 @@ def test_remove_guild_member(responses):
153
153
bot_client .remove_guild_member (guild_id = guild_id , user_id = user_id )
154
154
155
155
156
+ def test_get_dm_channel (responses ):
157
+ bot_token = 'MTAwNDU0MTg3NTk1NDQwNTQzNg.GFcT5X.Kp4gVn0U1kOPvdwLku-oki7LI_wtbMma2E_ET4'
158
+ bot_client = DiscordBotClient (bot_token )
159
+ user_id = 946364767864504360
160
+
161
+ channel_id = '122334232132323'
162
+ responses .add (
163
+ responses .POST , 'https://discord.com/api/v10/users/@me/channels' , json = {'id' : channel_id }, status = 200 ,
164
+ match = [
165
+ matchers .json_params_matcher ({'recipient_id' : user_id })
166
+ ]
167
+ )
168
+
169
+ resp_json = bot_client .get_dm_channel (user_id )
170
+ assert resp_json == {'id' : channel_id }
171
+
172
+
173
+ def test_create_msg (responses ):
174
+ bot_token = 'MTAwNDU0MTg3NTk1NDQwNTQzNg.GFcT5X.Kp4gVn0U1kOPvdwLku-oki7LI_wtbMma2E_ET4'
175
+ bot_client = DiscordBotClient (bot_token )
176
+
177
+ message = 'some new message'
178
+ channel_id = '122334232132323'
179
+ responses .add (
180
+ responses .POST , f'https://discord.com/api/v10/channels/{ channel_id } /messages' , json = {'id' : 'message_id' },
181
+ status = 200 ,
182
+ match = [
183
+ matchers .json_params_matcher ({'content' : message })
184
+ ]
185
+ )
186
+
187
+ resp_json = bot_client .create_message (channel_id , message )
188
+ assert resp_json == {'id' : 'message_id' }
189
+
190
+
191
+ def test_send_user_msg (responses ):
192
+ bot_token = 'MTAwNDU0MTg3NTk1NDQwNTQzNg.GFcT5X.Kp4gVn0U1kOPvdwLku-oki7LI_wtbMma2E_ET4'
193
+ bot_client = DiscordBotClient (bot_token )
194
+
195
+ message = 'some new message'
196
+ channel_id = '122334232132323'
197
+ user_id = 946364767864504360
198
+
199
+ responses .add (
200
+ responses .POST , 'https://discord.com/api/v10/users/@me/channels' , json = {'id' : channel_id }, status = 200 ,
201
+ match = [
202
+ matchers .json_params_matcher ({'recipient_id' : user_id })
203
+ ]
204
+ )
205
+ responses .add (
206
+ responses .POST , f'https://discord.com/api/v10/channels/{ channel_id } /messages' , json = {'id' : 'message_id' },
207
+ status = 200 ,
208
+ match = [
209
+ matchers .json_params_matcher ({'content' : message })
210
+ ]
211
+ )
212
+
213
+ resp_json = bot_client .send_user_message (user_id , message )
214
+ assert resp_json == {'id' : 'message_id' }
215
+
216
+
156
217
def test_remove_guild_member_bot_missing_permissionts (responses ):
157
218
bot_token = 'MTAwNDU0MTg3NTk1NDQwNTQzNg.GFcT5X.Kp4gVn0U1kOPvdwLku-oki7LI_wtbMma2E_ET4'
158
219
bot_client = DiscordBotClient (bot_token )
0 commit comments