-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (50 loc) · 2.19 KB
/
main.py
File metadata and controls
59 lines (50 loc) · 2.19 KB
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
# Anti Streaming Bot
# Author: Marco Pisco <marco@marcopisco.com>
# Modified to remove specific details
import discord
from discord.ext import commands
from discord import app_commands
import os
import random
# Replace these with your values
BOT_TOKEN = ""
TARGET_USER_ID = 0000000000000000 # The user ID of the one sharing their screen
intents = discord.Intents.default()
intents.guilds = True
intents.voice_states = True
intents.members = True
class MyBot(commands.Bot):
def __init__(self):
super().__init__(command_prefix="/", intents=intents)
async def setup_hook(self):
await bot.tree.sync()
bot = MyBot()
@bot.event
async def on_voice_state_update(member, before, after):
if after.channel is not None:
# Check if the target user started screen sharing
if member.id == TARGET_USER_ID:
# Disconnect all members except the one sharing the screen
for member in after.channel.members:
if member.id != TARGET_USER_ID:
try:
await member.move_to(None) # Disconnect the user
except Exception as e:
print(f"Failed to disconnect {other_member.name}: {e}")
# Check if a member joins a voice channel
if member.id != TARGET_USER_ID:
target_member = after.channel.guild.get_member(TARGET_USER_ID)
if target_member and target_member.id == TARGET_USER_ID and target_member.voice.self_stream:
if after.channel == target_member.voice.channel:
# Kick out all in call
try:
for member in after.channel.members:
if member.id != TARGET_USER_ID:
try:
await member.move_to(None) # Disconnect the user
except Exception as e:
print(f"Failed to disconnect {other_member.name}: {e}")
except Exception as e:
print(f"Failed to disconnect {member.name}: {e}")
# Disconnect all members except the one sharing the screen
bot.run(BOT_TOKEN)