Skip to content

Commit

Permalink
Working on #8
Browse files Browse the repository at this point in the history
- !programs_remove getting numbers
- TODO: Add try-except for each value being added
  • Loading branch information
joshuajz committed Mar 14, 2021
1 parent 6210a2e commit 42cdec9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
43 changes: 41 additions & 2 deletions commands/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,46 @@ async def programs_remove(ctx, client):
embed = create_embed("Programs_remove", "!programs_remove", "red")
await ctx.channel.send(embed=embed)

if len(content) == 1:
content = ctx.content.split("!programs_remove")[1]

if content.strip()[0:3] == "<@!":
if ctx.author.guild_permissions.administrator:
user_id = int(content.strip()[3:21])
else:
user_id = ctx.author.id
content = content.strip()[22::]
else:
user_id = ctx.author.id

remove_list = []
if "\n" in content:
for i in content.split("\n"):
if "," in i:
for z in i.split(","):
remove_list.append(int(z.strip()))
else:
remove_list.append(int(i.strip()))
elif "," in content:
for i in content.split(","):
remove_list.append(int(i.strip()))

# Remove duplicates
remove_list = list(dict.fromkeys(remove_list))

programs_raw = (
db["db"]
.execute("SELECT description FROM programs WHERE user_id = (?)", (user_id,))
.fetchone()[0]
.split("\n")
)

programs = {}
i = 1
for p in programs_raw:
programs[i] = p
i += 1

"""if len(content) == 1:
user_id = ctx.author.id
elif len(content) == 2:
if ctx.author.guild_permissions.administrator != True:
Expand Down Expand Up @@ -178,7 +217,7 @@ async def programs_remove(ctx, client):
embed = create_embed("Programs Removed Successfully", "", "dark_blue")
await ctx.channel.send(embed=embed)
return
return"""


async def programs(ctx, client):
Expand Down
2 changes: 1 addition & 1 deletion methods/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def create_filesystem(client: discord.Client):
"CREATE TABLE reaction_roles ([role_id] int, [message_id] int, [reaction_id] int, [channel_id] int)",
"CREATE TABLE normal_roles (role_id int, command text)",
"CREATE TABLE custom_commands (command text, output text, image text)",
"CREATE TABLE programs (user_id text, description text)",
"CREATE TABLE programs (user_id int, description text)",
"CREATE TABLE welcome (channel int, message text, enabled bool)",
"""CREATE TABLE "infractions" (
"id" INTEGER NOT NULL DEFAULT 0 PRIMARY KEY AUTOINCREMENT,
Expand Down

0 comments on commit 42cdec9

Please sign in to comment.