teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2020/08/11 09:37

投稿

Reply
Reply

スコア21

answer CHANGED
@@ -5,4 +5,26 @@
5
5
  これでできると思います。
6
6
 
7
7
  discord.utils.getについては
8
- [こちら](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.get)を見てください。
8
+ [こちら](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.get)を見てください。
9
+
10
+ ### 追記
11
+ ```py
12
+ import discord
13
+ import random
14
+ from discord.ext import commands
15
+ from discord.utils import get
16
+
17
+ token = ""
18
+ bot = commands.Bot(command_prefix = '.')
19
+
20
+ @bot.event
21
+ async def on_ready():
22
+ print('Ready')
23
+
24
+ @bot.command(pass_context=True)
25
+ async def dm(ctx):
26
+ user = discord.utils.get(bot.users, id=609388801168769034)
27
+ await user.send('Hey guys! We have a gift for you!')
28
+
29
+ bot.run(token)
30
+ ```

1

追記

2020/08/11 09:37

投稿

Reply
Reply

スコア21

answer CHANGED
@@ -2,4 +2,7 @@
2
2
  user = discord.utils.get(client.users, id=ID)
3
3
  await user.send("test")
4
4
  ```
5
- 動作テストはしていないですが、これでおそらくできると思います。
5
+ これでできると思います。
6
+
7
+ discord.utils.getについては
8
+ [こちら](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.get)を見てください。