Araeynn commited on
Commit
eeee860
1 Parent(s): f3f1639

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -7
app.py CHANGED
@@ -6,6 +6,7 @@ import random
6
  import datetime
7
  from threading import Thread
8
  import discord
 
9
  from discord.ext import tasks
10
  from PIL import Image
11
  import streamlit as st
@@ -152,22 +153,74 @@ The --setup command enables Lyre to communicate within a designated channel.
152
  ```
153
 
154
  ## Parameters
155
- - **[channel]**: Specify the target channel where you want the bot to be active. This can be either the channel name or ID.
156
 
157
  ## Example
158
- ```arduino
159
- --setup #general
160
- ```
161
 
162
  or
163
 
164
- ```arduino
165
- --setup <#123456789>
166
- ```
167
  """
168
 
169
  @client.event
170
  async def on_message(message):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  if message.content == "--help":
172
  def check(reaction, user):
173
  return reaction.message.id == msg.id and user == message.author
 
6
  import datetime
7
  from threading import Thread
8
  import discord
9
+ import discord.utils
10
  from discord.ext import tasks
11
  from PIL import Image
12
  import streamlit as st
 
153
  ```
154
 
155
  ## Parameters
156
+ - **[channel]**: Specify the target channel where you want the bot to be active. This is the channel name.
157
 
158
  ## Example
159
+
160
+ --setup <#1194161958505676851>
 
161
 
162
  or
163
 
164
+ --setup #general
165
+
 
166
  """
167
 
168
  @client.event
169
  async def on_message(message):
170
+ if message.content.startswith("--setup "):
171
+ args = message.content.split()[1:]
172
+ if len(args) == 0:
173
+ embed = discord.Embed(title="Error", description="No args provided. Use `--help` for command help.")
174
+ message.reply(embed=embed)
175
+ return 0
176
+ if args[0] == "":
177
+ embed = discord.Embed(title="Error", description="Parameter `[channel]` empty. Use `--help` for command help.")
178
+ message.reply(embed=embed)
179
+ return 0
180
+ if args[0].startswith("<#") and args[0].endswith(">"):
181
+ try:
182
+ cid = int(args[0][2:-1])
183
+ except:
184
+ embed = discord.Embed(title="Error", description="Parameter `[channel]` invalid. Use `--help` for command help.")
185
+ message.reply(embed=embed)
186
+ return 0
187
+ c = client.get_channel(cid)
188
+ if c in message.guild.text_channels:
189
+ embed = discord.Embed(title="Success!", description=f"You can now chat with the bot in <#{cid}>")
190
+ message.reply(embed=embed)
191
+ c.send(embed)
192
+ else:
193
+ embed = discord.Embed(title="Error", description="Parameter `[channel]` is not in this guild. Use `--help` for command help.")
194
+ message.reply(embed=embed)
195
+ return 0
196
+ elif args[0].startswith("#"):
197
+ try:
198
+ cname = args[0][1:])
199
+ except:
200
+ embed = discord.Embed(title="Error", description="Parameter `[channel]` invalid. Use `--help` for command help.")
201
+ message.reply(embed=embed)
202
+ return 0
203
+ try:
204
+ c = discord.utils.get(client.get_all_channels(), guild__id=message.guild.id, name=cname)
205
+ if c not None:
206
+ embed = discord.Embed(title="Success!", description=f"You can now chat with the bot in <#{c.id}>")
207
+ c.send(embed=embed)
208
+ return 0
209
+ else:
210
+ embed = discord.Embed(title="Error", description="Parameter `[channel]` is not a valid channel in this guild. Use `--help` for command help.")
211
+ message.reply(embed=embed)
212
+ return 0
213
+ except:
214
+ embed = discord.Embed(title="Error", description="Parameter `[channel]` is not a valid channel in this guild. Use `--help` for command help.")
215
+ message.reply(embed=embed)
216
+ return 0
217
+ else:
218
+ embed = discord.Embed(title="Error", description="Parameter `[channel]` is not in valid forms. Use `--help` for command help.")
219
+ message.reply(embed=embed)
220
+ return 0
221
+
222
+
223
+
224
  if message.content == "--help":
225
  def check(reaction, user):
226
  return reaction.message.id == msg.id and user == message.author