-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
132 lines (111 loc) · 5.48 KB
/
Copy pathmain.py
File metadata and controls
132 lines (111 loc) · 5.48 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import os
import time
import discord
from discord import Interaction, app_commands
from discord.app_commands import AppCommandError
from discord.ext import commands
from discord.ext.commands import *
from dotenv import load_dotenv
from pretty_help import AppMenu, PrettyHelp
load_dotenv()
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
menu = AppMenu(ephemeral=True)
bot = commands.Bot(command_prefix='r!', description='Custom Bot Made By Naviamold',
intents=intents, help_command=PrettyHelp(menu=menu))
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(name='Naviamold!', type=discord.ActivityType.watching))
print(f'We have logged in as {bot.user}')
sync = await bot.tree.sync()
print(f"Synced {len(sync)} commands(s):")
for command in sync:
print(command.name)
print(f'\nBot is in {len(bot.guilds)} server(s):')
for server in bot.guilds:
print(server.name)
@bot.tree.command(name="ping", description="Pong")
@app_commands.default_permissions(administrator=True)
async def ping(interaction: discord.Interaction):
await interaction.response.send_message(f'Pong: {round (bot.latency * 1000)} ms', ephemeral=True)
@bot.tree.command(name="kick_all", description="Kicks Every Member")
@app_commands.default_permissions(administrator=True)
@app_commands.describe(bots='If True Bots will also be Kicked', reason="Kick Reason")
async def kickall(interaction: discord.Interaction, reason: str = None, bots: bool = False):
await interaction.response.defer()
for member in interaction.guild.members:
if bots is False:
if member.bot:
continue
try:
await member.kick(reason=reason)
print(f"✔️ Kicked {member.name}")
await interaction.followup.send(f"✔️ Kicked {member.name}")
except:
print(f"❌ Could not kick {member}")
await interaction.followup.send(f'❌ Could not Kick {member}')
@bot.tree.command(name="ban_all", description="Bans Every Member")
@app_commands.describe(bots='If True Bots will also be Banned', reason="Ban Reason", delete_message_days="The number of Days worth of Messages to Delete from the user in the Server.")
@app_commands.default_permissions(administrator=True)
async def banall(interaction: discord.Interaction, reason: str = None, delete_message_days: int = 0, bots: bool = False):
await interaction.response.defer()
for member in interaction.guild.members:
if bots is False:
if member.bot:
continue
try:
await member.ban(reason=reason, delete_message_days=delete_message_days)
await interaction.followup.send(f'✔️ Banned {member.name}')
except:
await interaction.followup.send(f'❌ Could not Ban {member.name}')
@bot.tree.command(name="msg_all", description="Messages Every Member")
@app_commands.default_permissions(administrator=True)
@app_commands.describe(message="Message you want to Send")
async def msgall(interaction: discord.Interaction, message: str):
await interaction.response.defer()
if message != None:
num = 0
members = interaction.guild.members
for member in members:
if member.bot:
continue
num += 1
try:
if num > 45:
await interaction.followup.send(f'Looks like your server has more than 45 members sorry I have to slow down to not hit the rate limit')
time.sleep(30)
await member.send(message)
await interaction.followup.send(f'✔️ Successfully sent dm to {member} with 30 second delay')
elif num < 45:
await member.send(message)
print(f'✔️ Successfully sent dm to {member}')
await interaction.followup.send(f'✔️ Successfully sent dm to {member}')
except:
await interaction.followup.send(f'❌ Could Sent DM to {member}')
print(f'❌ Could Sent DM to {member}')
@bot.tree.command(name="reset_nicknames", description="Removes Every Members Nickname")
@app_commands.default_permissions(administrator=True)
@app_commands.describe(bots='If True Bots nicknames will also be Reseted')
async def reset_nicknames(interaction: discord.Interaction, bots: bool = False):
await interaction.response.defer()
for member in interaction.guild.members:
if bots is False:
if member.bot:
continue
try:
nick = member.nick
await member.edit(nick=None)
if nick != None:
await interaction.followup.send(f" ✔ Reset nickname of {member.name} from {nick} to {member.name}")
except discord.Forbidden:
# The bot doesn't have permission to change the nickname of this user
await interaction.followup.send(f" ❌ Dont have permission to reset nickname of {member.name} from {nick} to {member.name}")
pass
@bot.tree.error
async def error(interaction: Interaction, error: AppCommandError):
try:
await interaction.response.send_message(error, ephemeral=True)
except discord.errors.InteractionResponded:
await interaction.followup.send(error, ephemeral=True)
bot.run(os.getenv('BOT_TOKEN'))