Commit 3adfa37b authored by IS1_4M's avatar IS1_4M
Browse files

Lots of UX tweaks

parent c6c6222a
......@@ -158,11 +158,12 @@ class AbstractChanSuite:
'''
async def add_text_channel(chan, channelName):
# add a text channel to this category.
channelName = AbstractChanSuite.format_uinp(channelName)
await chan.create_text_channel(channelName)
async def remove_text_channel(chan, channel_name):
#remove text channel from category
channel_name = channel_name.lower()
channel_name = AbstractChanSuite.format_uinp(channel_name)
for channel in chan.text_channels:
if channel.name.lower() == channel_name:
await channel.delete()
......@@ -174,11 +175,12 @@ class AbstractChanSuite:
'''
async def add_voice_channel(chan, channelName):
#add voice channel to category
channelName = AbstractChanSuite.format_uinp(channelName)
await chan.create_voice_channel(channelName)
async def remove_voice_channel(chan, channel_name):
#remove voice channel from this category
channel_name = channel_name.lower()
channel_name = AbstractChanSuite.format_uinp(channel_name)
for channel in chan.voice_channels:
if channel.name == channel_name:
await channel.delete()
......@@ -217,7 +219,8 @@ class AbstractChanSuite:
await role.delete()
await chan.delete()
def format_uinp(inp):
return inp.lower().replace(' ', '-')
def get_chan_commands():
raise NotImplementedError()
def get_restrictchan_command_examples():
......
......@@ -161,11 +161,12 @@ async def on_message(message):
'''
if content.startswith('!makeclub'):
clubName = content[len('!makeclub '):].upper()
clubName.replace(' ', '-')
clubName = clubName.replace(' ', '-')
print(clubName)
clubs = list(ClubSuite.get_all_clubs(message.channel.guild))
# make sure we're not making a duplicate club
for i in range(len(clubs)):
clubs[i] = clubs[i].name.lower()
clubs[i] = clubs[i].name.upper()
if clubName in clubs:
await message.channel.send('Sorry, that clubname is already taken. try a different one?', delete_after = 5)
return
......@@ -174,7 +175,7 @@ async def on_message(message):
await newClub._init()
return
elif content.startswith('!joinclub'):
target = ('c-' + content[len('!joinclub '):]).upper()
target = ('c-' + content[len('!joinclub '):]).upper().replace(' ','-')
print('registered joinclub for' + target)
target_club = ClubSuite.get_club(ClubSuite.get_all_clubs(message.channel.guild), target)
await ClubSuite.add_member(target_club, message.author)
......@@ -183,7 +184,7 @@ async def on_message(message):
# Find club category
# if there is a role called category [member], add the person to the role]
elif content.startswith('!leaveclub'):
target = ('c-' + content[len('!leaveclub '):]).upper()
target = ('c-' + content[len('!leaveclub '):]).upper().replace(' ','-')
print('registered leaveclub for' + target)
target_club = ClubSuite.get_club(ClubSuite.get_all_clubs(message.channel.guild), target)
await ClubSuite.kick_member(target_club, message.author)
......@@ -241,6 +242,13 @@ async def on_message(message):
return
await message.channel.send('Sorry. We didn\'t process your command. Will you check for typos or ask for help and try again?', delete_after=10)
else:
try:
maybe_auth = is_auth(message.channel, auth_channel)#''' This will break the program later. message.channel can be a DM channel. find a way to make it so that that wont break the channel'''
except:
print('could not find auth channel')
if maybe_auth:
await message.delete(delay=3)
# Check if a message comes in from a CLI channel.
# if in a CLI channel,
# is it an admin channel?
......
......@@ -164,14 +164,14 @@ class ClubSuite(AbstractChanSuite):
if content.startswith('!addtextchannel '): # Add club text channel
await ClubSuite.add_text_channel(maybe_club, content[len('!addtextchannel '):]); return True
elif content.startswith('!removetextchannel'): # remove club text channel
await ClubSuite.remove_text_channel(maybe_club, content[len('!removetextchannel '):]); return True
await ClubSuite.remove_text_channel(maybe_club, content[len('!removetextchannel '):].replace(' ', '-')); return True
elif content.startswith('!addvoicechannel'): #add club voice channel
print('arrived at clubsuite addvoicechannel: ' + message.content)
await ClubSuite.add_voice_channel(maybe_club, content[len('!addvoicechannel '):]);
print('completed addvoicechannel')
return True
elif content.startswith('!removevoicechannel'): # remove club voice channel
await ClubSuite.remove_voice_channel(maybe_club, content[len('!removevoicechannel '):]); return True
await ClubSuite.remove_voice_channel(maybe_club, content[len('!removevoicechannel '):].replace(' ', '-')); return True
elif content.startswith('!closeclub'):
await ClubSuite.delete_category(maybe_club); return True
elif content.startswith('!addmember'):
......
......@@ -218,12 +218,13 @@ class PubChanSuite:
return False
if content.startswith('!addtextchannel'):
params = content[len('!addtextchannel '):].split(' ')
target = 'O-' + params[0].upper()
target = 'O-' + params[0].upper().replace(' ', '-')
channel = '-'.join(params[1:])
pubchan = PubChanSuite.get_pubchan(PubChanSuite.get_all_pubchans(message.channel.guild), target)
if pubchan:
start_role = await message.channel.guild.create_role(name=target + params[1] + ' Starter')
start_role = await message.channel.guild.create_role(name=target + channel + ' Starter')
await message.author.add_roles(start_role)
await PubChanSuite.add_text_channel(pubchan, params[1])
await PubChanSuite.add_text_channel(pubchan, channel)
return True
else:
return False
......@@ -231,40 +232,43 @@ class PubChanSuite:
elif content.startswith('!removetextchannel'):
params = content[len('!removetextchannel '):].split(' ')
target = 'O-' +params[0].upper()
if target + params[1] + ' Starter' in [role.name for role in message.author.roles]:
channel = '-'.join(params[1:])
if target + channel + ' Starter' in [role.name for role in message.author.roles]:
pubchan = PubChanSuite.get_pubchan(PubChanSuite.get_all_pubchans(message.channel.guild), target)
for role in message.channel.guild.roles:
if role.name == target + params[1] + ' Starter':
if role.name == target + channel + ' Starter':
await message.author.remove_roles(role)
await role.delete()
break
await PubChanSuite.remove_text_channel(pubchan, params[1])
await PubChanSuite.remove_text_channel(pubchan, channel)
return True
else:
await message.channel.send('You either dont have permission to do that or you typod a name...', delete_after = 3)
return False
elif content.startswith('!addvoicechannel'):
params = content[len('!addvoicechannel '):].split(' ')
target = 'O-' +params[0].upper()
target = 'O-' +params[0].upper().replace(' ','-')
channel = '-'.join(params[1:])
pubchan = PubChanSuite.get_pubchan(PubChanSuite.get_all_pubchans(message.channel.guild), target)
if pubchan:
start_role = await message.channel.guild.create_role(name=target + params[1] + ' Starter')
start_role = await message.channel.guild.create_role(name=target + channel + ' Starter')
await message.author.add_roles(start_role)
await PubChanSuite.add_voice_channel(pubchan, params[1])
await PubChanSuite.add_voice_channel(pubchan, channel)
return True
else:
return False
elif content.startswith('!removevoicechannel'):
params = content[len('!removevoicechannel '):].split(' ')
target = 'O-' +params[0].upper()
if target + params[1] + ' Starter' in [role.name for role in message.author.roles]:
channel = '-'.join(params[1:])
if target + channel + ' Starter' in [role.name for role in message.author.roles]:
pubchan = PubChanSuite.get_pubchan(PubChanSuite.get_all_pubchans(message.channel.guild), target)
for role in message.channel.guild.roles:
if role.name == target + params[1] + ' Starter':
if role.name == target + channel + ' Starter':
await message.author.remove_roles(role)
await role.delete()
break
await PubChanSuite.remove_voice_channel(pubchan, params[1].lower())
await PubChanSuite.remove_voice_channel(pubchan, channel.lower())
return True
else:
await message.channel.send('You either dont have permission to do that or you typod a name...', delete_after = 3)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment