回答編集履歴

1

追記

2022/01/05 12:39

投稿

umau
umau

スコア831

test CHANGED
@@ -49,3 +49,93 @@
49
49
  await channel.send(str(jikan) + '時' + str(fun) + '分です。')
50
50
 
51
51
  ```
52
+
53
+
54
+
55
+ ---
56
+
57
+ (追記)
58
+
59
+ さほど違いがあるように思えないですが、こちらで動いているコードを丸ごと貼っておきます。
60
+
61
+
62
+
63
+ ```python
64
+
65
+ import discord
66
+
67
+ import datetime
68
+
69
+
70
+
71
+ client = discord.Client()
72
+
73
+
74
+
75
+
76
+
77
+ @client.event
78
+
79
+ async def on_message(message):
80
+
81
+ if message.author.bot:
82
+
83
+ return
84
+
85
+
86
+
87
+ channel = client.get_channel(チャンネルID)
88
+
89
+
90
+
91
+ if message.content.startswith('/'):
92
+
93
+ str = message.content
94
+
95
+ number = str.lstrip('/')
96
+
97
+ min = (100 - int(number)) * 10
98
+
99
+ if min >= 60:
100
+
101
+ hour = min // 60
102
+
103
+ minute = min % 60
104
+
105
+
106
+
107
+ else:
108
+
109
+ hour = 0
110
+
111
+ minute = min
112
+
113
+
114
+
115
+ now = datetime.datetime.now()
116
+
117
+ jikan = now.hour + hour
118
+
119
+ fun = now.minute + minute
120
+
121
+ if fun >= 60:
122
+
123
+ h = fun // 60
124
+
125
+ fun = fun % 60
126
+
127
+ jikan = jikan + h
128
+
129
+
130
+
131
+ await channel.send(f"{jikan}時{fun}分です")
132
+
133
+
134
+
135
+ if __name__ == '__main__':
136
+
137
+ client.run('トークン')
138
+
139
+
140
+
141
+ ```