-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathww_permissions.py
executable file
·93 lines (76 loc) · 3.96 KB
/
ww_permissions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 2 18:32:12 2020
@author: Jonathan
"""
import discord
class WerewolfPermissions():
def __init__(self, bot):
self.bot = bot
self.NoText = discord.PermissionOverwrite()
self.NoText.send_messages = False
self.NoText.read_messages = False
self.NoText.read_message_history = False
self.AllText = discord.PermissionOverwrite()
self.AllText.send_messages = True
self.AllText.read_messages = True
self.AllText.read_message_history = True
self.ReadOnly = discord.PermissionOverwrite()
self.ReadOnly.send_messages = False
self.ReadOnly.read_messages = True
self.ReadOnly.read_message_history = True
self.Speak = discord.PermissionOverwrite()
self.Speak.speak = True
self.Speak.connect = True
self.ListenOnly = discord.PermissionOverwrite()
self.ListenOnly.speak = False
self.ListenOnly.connect = True
async def NewTextChannel(self, ctx, ChannelName, Public = False):
channel = await ctx.guild.create_text_channel(ChannelName)
# for member in ctx.guild.members:
# if not member.bot:
if Public:
try:
await channel.set_permissions(ctx.guild.default_role, overwrite = self.ReadOnly)
except discord.Forbidden as Error:
print("Failed to set permissions in {} due to {}".format(ctx.guild.name, Error))
else:
try:
await channel.set_permissions(ctx.guild.default_role, overwrite = self.NoText)
except discord.Forbidden as Error:
print("Failed to set permissions in {} due to {}".format(ctx.guild.name, Error))
return channel
async def NewVoiceChannel(self, ctx, ChannelName):
channel = await ctx.guild.create_voice_channel(ChannelName)
try:
await channel.set_permissions(ctx.guild.default_role, overwrite = self.ListenOnly)
except discord.Forbidden as Error:
print("Failed to set permissions in {} due to {}".format(ctx.guild.name, Error))
return channel
def GetPermission(self, PermissionName):
if PermissionName == "textOK":
return self.AllText
elif PermissionName == "speak":
return self.Speak
async def Kill(self, GuildID, PlayerID):
guild = self.bot.get_guild(GuildID)
User = guild.get_member(PlayerID)
general_text_channel = guild.get_channel(self.bot.game_list[GuildID]["channel_ids"]["general"])
general_voice_channel = guild.get_channel(self.bot.game_list[GuildID]["channel_ids"]["general-voice"])
werewolf_channel = guild.get_channel(self.bot.game_list[GuildID]["channel_ids"]["werewolf"])
medic_channel = guild.get_channel(self.bot.game_list[GuildID]["channel_ids"]["medic"])
detective_channel = guild.get_channel(self.bot.game_list[GuildID]["channel_ids"]["detective"])
DeathMessage = discord.Embed(title="You Have Died...",
description="You have been killed, and you can no longer communicate with the living in the Village-Ville Text and Voice channels...",
color = 0xFF0000)
try:
await User.send(embed=DeathMessage)
await werewolf_channel.set_permissions(User, overwrite = self.ReadOnly)
await medic_channel.set_permissions(User, overwrite = self.ReadOnly)
await detective_channel.set_permissions(User, overwrite = self.ReadOnly)
await general_text_channel.set_permissions(User, overwrite = self.ReadOnly)
await general_voice_channel.set_permissions(User, overwrite = self.ListenOnly)
except discord.Forbidden as Error:
print("Failed to set permissions in {} due to {}".format(guild.name, Error))
return