Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got logging of all users in group working #59

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ __pycache__
/.vscode
/bot-env
/guilds
/groups
/logo
/utils
analytics.json
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

## Quick start:

* Clone the repository: `git clone https://github.com/gregzaal/Auto-Voice-Channels.git`
* Clone the repository: `git clone https://github.com/Jakimbo/Auto-Voice-Channels.git`
* Go to the directory: `cd Auto-Voice-Channels`
* Make folder to store guild settings: `mkdir guilds`
* Make folder to store group settings: `mkdir groups`
* Install pip: `sudo apt-get -y install python3-pip`
* Install venv: `pip3 install virtualenv`
* Make venv: `python3 -m virtualenv bot-env`
Expand Down
2 changes: 2 additions & 0 deletions cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

# Store settings so we don't have to read them from drive all the time
GUILD_SETTINGS = {}
GROUP_SETTINGS = {}
PREV_GROUP_SETTINGS = {}
PREV_GUILD_SETTINGS = {}

# Store Patreon stuff so we can use it globally and don't have to read it all on every is_gold check
Expand Down
12 changes: 12 additions & 0 deletions commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
bitrate,
channelinfo,
create,
creategroup,
dcnf,
defaultlimit,
disable,
Expand All @@ -24,6 +25,7 @@
limit,
listroles,
logging,
merge,
name,
nick,
patreon,
Expand All @@ -35,9 +37,11 @@
removealias,
rename,
restrict,
resetgroup,
restrictions,
servercheck,
source,
split,
showtextchannelsto,
template,
textchannelname,
Expand All @@ -56,6 +60,8 @@
"bitrate": bitrate.command,
"channelinfo": channelinfo.command,
"create": create.command,
"creategroup": creategroup.command,
"cg": creategroup.command,
"dcnf": dcnf.command,
"defaultlimit": defaultlimit.command,
"disable": disable.command,
Expand All @@ -71,6 +77,8 @@
"listroles": listroles.command,
"lock": limit.command,
"logging": logging.command,
"merge": merge.command,
"m": merge.command,
"name": name.command,
"nick": nick.command,
"patreon": patreon.command,
Expand All @@ -82,10 +90,14 @@
"public": public.command,
"removealias": removealias.command,
"rename": rename.command,
"resetgroup": resetgroup.command,
"rg": resetgroup.command,
"restrict": restrict.command,
"restrictions": restrictions.command,
"servercheck": servercheck.command,
"source": source.command,
"split": split.command,
"sp": split.command,
"showtextchannelsto": showtextchannelsto.command,
"template": template.command,
"textchannelname": textchannelname.command,
Expand Down
2 changes: 1 addition & 1 deletion commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]
]


async def execute(ctx, params):
guild = ctx['guild']
default_name = "➕ New Session"
Expand Down
41 changes: 41 additions & 0 deletions commands/creategroup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import discord
import functions as func
from commands.base import Cmd

help_text = [
[
("Usage:", "<PREFIX><COMMAND> GROUP NAME"),
("Description:",
"Make a new voice channel group. This will create a new catagory containing a primary channel that will create secondary channels, as well as a \n"
"'Tavern' channel that will be used for holding the entire group, and a text channel for chatting and bot commands (You can also create another private\n"
"text channel for commands if you wish, it just needs to be under the same category and you will need to give the bot permission to use it ). After\n"
"creating this gorup, you can use the <PREFIX>merge (or <PREFIX>m) command to move all users out of their voice channels made in the category and place them into\n"
"the 'Tavern' channel. You can then use <PREFIX>split (or <PREFIX>sp) to move all the users out of the 'Tavern' channel and back into the ones they came from"),
]
]


async def execute(ctx, params):
guild = ctx['guild']
default_name = "➕ New Session"
group_name = ' '.join(params)

try:
await func.create_group(guild, group_name, default_name, ctx['message'].author)
except discord.errors.Forbidden:
return False, "I don't have permission to create categories."
except discord.errors.HTTPException as e:
return False, "An HTTPException occurred: {}".format(e.text)

response = ("A new voice channel group called " + group_name + " has been created. "
"You can now use the split and merge commnands within this category\n".format(default_name,
ctx['print_prefix']))
return True, response


command = Cmd(
execute=execute,
help_text=help_text,
params_required=0,
admin_required=True,
)
34 changes: 34 additions & 0 deletions commands/merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import functions as func
from commands.base import Cmd

help_text = [
[
("Usage:", "<PREFIX><COMMAND>"),
("Description:",
"When used in a text channel belonging to a group, will merge in channels made using the 'New Session' channel\n"
"and place them into that groups 'Tavern' channel"),
]
]


async def execute(ctx, params):
channel = ctx['channel']
guild = ctx['guild']
CategoryID = channel.category_id

#print(CategoryID)

await func.merge_channels(guild, channel)

return True, ("Successfully merged channels")




command = Cmd(
execute=execute,
help_text=help_text,
params_required=0,
admin_required=False,
voice_required=False,
)
33 changes: 33 additions & 0 deletions commands/resetgroup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import functions as func
from commands.base import Cmd

help_text = [
[
("Usage:", "<PREFIX><COMMAND>"),
("Description:",
"Once you have completed using the group, run this command so that the voice channels being preserved by the.\n"
"merge command can be automatically deleted again"),
]
]


async def execute(ctx, params):
channel = ctx['channel']
guild = ctx['guild']

#print(CategoryID)

await func.reset_group(guild, channel)

return True, ("Successfully reset group")




command = Cmd(
execute=execute,
help_text=help_text,
params_required=0,
admin_required=False,
voice_required=False,
)
34 changes: 34 additions & 0 deletions commands/split.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import functions as func
from commands.base import Cmd

help_text = [
[
("Usage:", "<PREFIX><COMMAND>"),
("Description:",
"Will take all users in the 'Tavern' channel and move them from that voice channel back into the one's they were\n"
"previously in before the merge command was used"),
]
]


async def execute(ctx, params):
channel = ctx['channel']
guild = ctx['guild']
client = ctx['client']

#print(CategoryID)

await func.split_channels(guild, channel, client)

return True, ("Successfully split channel into groups")




command = Cmd(
execute=execute,
help_text=help_text,
params_required=0,
admin_required=False,
voice_required=False,
)
3 changes: 3 additions & 0 deletions default_group_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"group_channels":{}
}
Loading