-
Notifications
You must be signed in to change notification settings - Fork 0
/
prev.txt
188 lines (133 loc) · 5.48 KB
/
prev.txt
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
from discord.ext import commands
import discord
import asyncio
from discord.utils import get
from keep_alive import keep_alive
import random
import time
import os
import sys
from discord import Intents
import re
client = commands.Bot(command_prefix='?')
@client.command()
async def test(ctx):
print('command recieved')
@client.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, member: discord.Member, length, reason=None):
guild = ctx.guild
muted = get(guild.roles, name='Muted')
dater = re.split('(\D+)',length)
numbers = ' '.join(dater[:1])
letter = ' '.join(dater[1:2])
flength = 0
if letter == 's':
flength = int(numbers)
elif letter == 'm':
flength = int(numbers) * 60
elif letter == 'h':
flength = int(numbers) * 60 * 60
elif letter == 'd':
flength = int(numbers) * 60 * 60 * 24
elif letter == 'w':
flength = int(numbers) * 60 * 60 * 24 * 7
elif letter == 'mon':
flength = int(numbers) * 60 * 60 * 24 * 7 * 30
elif letter == 'y':
flength = int(numbers) * 60 * 60 * 24 * 7 * 30 * 12
elif letter == 'dec':
flength = int(numbers) * 60 * 60 * 24 * 7 * 30 * 12 * 100
if not muted:
muted = await guild.create_role(name='Muted')
for channel in guild.channels:
await channel.set_premissions(muted, speak=False, send_messages=False)
await member.add_roles(muted, reason=reason)
if reason == None:
reason = 'did something bad'
await ctx.send(f"Hi I was told to mute {member.mention} because (s)he {reason}, I was also told to mute him for {length}")
await member.send(f"Hi, you were muted on the server {guild.name} because {reason}, I was also told to mute you for {length}")
await asyncio.sleep(flength)
await member.remove_roles(muted)
await ctx.send(f'{member.mention} has been unmuted (Yay!)')
@client.command()
@commands.has_permissions(kick_members=True)
async def unmute(ctx, member: discord.Member, reason=None):
guild = ctx.guild
muted = get(guild.roles, name='Muted')
await member.remove_roles(muted, reason=reason)
if reason == None:
reason = 'did something good'
await ctx.send(f"Hi I was told to unmute {member.mention} because (s)he {reason}")
await member.send(f"Hi, you were unmuted on the server {guild.name} because you {reason}")
@client.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, reason=None):
guild = ctx.guild
if reason == None:
reason = 'did something bad'
await ctx.send(f"Hi I was told to kick {member.mention} because (s)he {reason}")
await member.send(f"Hi, you were kicked on the server {guild.name} because you {reason}")
await member.kick()
@client.command()
@commands.has_permissions(create_instant_invite = True)
async def invite(ctx, member: discord.Member, message):
invite = await discord.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=1)
await member.send(f'Hi {ctx.author.name} sent you an invite! \nHe said: \n{message} \n {invite}')
@client.command()
@commands.has_permissions(ban_members=True)
async def ban (ctx, member: discord.Member, reason=None):
if member == None or member == ctx.message.author:
await ctx.channel.send("You cannot ban yourself")
return
if reason is None:
await member.send(f'Hi, you have been banned from {ctx.guild.name}. They didn\'t say why :(.')
await ctx.channel.send(f'Hi, {member.name} has been banned by {ctx.author.name} for no particular reason.')
await member.ban()
else:
await member.send(f'Hi, {member.name} , you have been banned from {ctx.guild.name()}. The reason for this was {reason}.')
await ctx.channel.send(f'Hi, {member.name} has been banned by {ctx.author.name} the reason specified was {reason}.')
await member.ban()
@client.command()
@commands.has_permissions(administrator=True)
async def shutdown(ctx):
await client.close()
@client.event
async def on_command_error(ctx, error):
print(error)
if str(error) == 'You are missing Mute Members permission(s) to run this command.':
await ctx.send('Sorry (s)he is already muted ')
elif isinstance(error, commands.MissingPermissions):
await ctx.send(f"Sorry but you're not allowed to do that, ok? <:Basil_smile:996486112442863686>")
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('Please remember to put everything in your sentence or I can\'t understand it <:Basil_smile:996486112442863686>')
@client.event
async def on_message(ctx, message):
author = message.author
guild = ctx.guild
muted = get(guild.roles, name='Muted')
counter = 0
with open("list.txt", "r+") as file:
for lines in file:
if lines.strip("\n") == str (author.id):
counter+=1
file.writelines(f"{str(author.id)}\n")
if counter > 5:
if not muted:
muted = await guild.create_role(name='Muted')
for channel in guild.channels:
await channel.set_premissions(muted, speak=False, send_messages=False)
await author.add_roles(muted, reason='Spam')
ctx.send(f'Hi, I have muted {author} for 5 minutes for spam.')
await asyncio.sleep(600)
await author.remove_roles(muted)
await ctx.send(f'{author.mention} has been unmuted (Yay!)')
@client.event
async def on_ready():
print("Everything is going to be ok")
while True:
await asyncio.sleep(10)
with open("list.txt", "r+") as file:
file.truncate(0)
keep_alive()
client.run(os.environ["key"])