質問編集履歴

2

コード直し

2020/03/01 01:21

投稿

ameminn
ameminn

スコア17

test CHANGED
File without changes
test CHANGED
@@ -84,8 +84,86 @@
84
84
 
85
85
 
86
86
 
87
+ ですが/ping を実行すると/pongが返ってくるようにするコードを書き実行したところ
88
+
89
+ 1回のみの反応でした。
90
+
91
+ 多重ログインではないです
92
+
93
+
94
+
95
+
96
+
97
+
98
+
87
99
  ### 補足情報
88
100
 
89
101
 
90
102
 
91
103
  pythonV3.8.1 ブランチrewrite
104
+
105
+
106
+
107
+ ###書き直したコード(追加あり)
108
+
109
+ ```py
110
+
111
+ global ch_flag
112
+
113
+ ch_flag = True
114
+
115
+ @client.event
116
+
117
+ async def on_message(message):
118
+
119
+ if message.content.startswith('/open') and ch_flag == True:
120
+
121
+ ch_flag = False
122
+
123
+ category_id = xxxxxxxxxxxxxxxxx
124
+
125
+ category = message.guild.get_channel(category_id)
126
+
127
+ cmd_search = str(message.content)
128
+
129
+ ch_name = cmd_search[6:]
130
+
131
+ new_channel = await category.create_text_channel(name= ch_name)
132
+
133
+ reply = f'{new_channel.mention} を作成しました'
134
+
135
+ await message.channel.send(reply)
136
+
137
+ guild = message.guild
138
+
139
+ role = await guild.create_role(name=ch_name)
140
+
141
+ await new_channel.set_permissions(role,read_messages=True,send_messages=True)
142
+
143
+ reply2 = f'{role.mention} を作成しました'
144
+
145
+ await message.channel.send(reply2)
146
+
147
+ await message.channel.send('権限設定を行いました')
148
+
149
+ await asyncio.sleep(0.2)
150
+
151
+ ch_flag = True
152
+
153
+ category_id_2 = xxxxxxxxxxxxxxxxxxxxxxxx
154
+
155
+ category_2 = message.guild.get_channel(category_id_2)
156
+
157
+ new_channel_2 = await category_2.create_text_channel(name = ch_name + '用')
158
+
159
+ if message.content == "/ping":
160
+
161
+ await message.channel.send("pong!")
162
+
163
+ if message.author.bot:
164
+
165
+ return```
166
+
167
+
168
+
169
+ です

1

依頼通り直しましたすいません

2020/03/01 01:21

投稿

ameminn
ameminn

スコア17

test CHANGED
File without changes
test CHANGED
@@ -13,8 +13,6 @@
13
13
  ```
14
14
 
15
15
  コードを実行した際にこのようになります。
16
-
17
- ![イメージ説明](9f7b5008268fbb61e685cb71ad650d77.png)
18
16
 
19
17
  チャンネルを一つだけ作成したいのですが3つ作られてしまう
20
18
 
@@ -32,7 +30,7 @@
32
30
 
33
31
  ```
34
32
 
35
-
33
+ ![イメージ説明](df54ccbb67369c851aff1fb16bb7644c.png)
36
34
 
37
35
  ### 該当のソースコード
38
36
 
@@ -82,6 +80,8 @@
82
80
 
83
81
  サイトをあちこち回りました
84
82
 
83
+ が何をすればいいのか全く...
84
+
85
85
 
86
86
 
87
87
  ### 補足情報