-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
186 lines (170 loc) · 5.44 KB
/
bot.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
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
### Modules ###
import os
import sys
import time
import praw
import math
import random
import pickle
import string
import os.path
import discord
import json
import asyncio
import datetime
import requests
import threading
import traceback
import itertools
import youtube_dl
from time import sleep
import multiprocessing
from random import randint
from functools import partial
from discord.utils import get
from discord.ext import tasks
from discord import TextChannel
from discord.ext import commands
from youtube_dl import YoutubeDL
from async_timeout import timeout
from discord.ext.commands import *
from discord import FFmpegPCMAudio
from discord.voice_client import VoiceClient
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
### Modules end ###
### Startup/variables ###
console = False
log = True
intents = discord.Intents.all()
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
client = commands.Bot(command_prefix=".", intents=intents)
slash = SlashCommand(client, sync_commands=False)
global startTime
startTime = time.time()
client.remove_command('help')
cwd = os.getcwd()
global owner_id
owner_id = #paste your discord id here
def foo():
v = 1
while True:
print(f"hit {v}")
v += 1
time.sleep(300)
b = threading.Thread(target=foo)
b.daemon = True
b.start()
## Events ###
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{str(len(client.guilds))} guilds | .help"))
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
else:
client.load_extension(f'cogs.{filename[:-3]}')
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
print('Bot is online')
print('==================')
print('Bot config:')
print('------------------')
print(f'Ping: {round(client.latency * 1000)}')
print('------------------')
boot = str(datetime.timedelta(seconds=int(round(time.time()-startTime))))
print(f'Startup time: {boot}')
print('------------------')
print(f'Server count: {str(len(client.guilds))}')
print('------------------')
@client.event
async def on_message_edit(message_before, message_after):
global author
author = message_before.author
guild = message_before.guild.id
channel = message_before.channel
global before
before = message_before.content
global after
after = message_after.content
snipe_message_author = {}
snipe_message_content = {}
@client.event
async def on_message_delete(message):
if message.content.startswith(".say"):
return
else:
pass
if not message.author.bot:
pass
else:
return
now = datetime.datetime.now()
current_time = now.strftime("%H:%M:%S")
guild = client.guilds[0]
channel = message.channel
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
@client.event
async def on_guild_join(guild):
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{str(len(client.guilds))} guilds | .help"))
@client.event
async def on_guild_remove(guild):
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{str(len(client.guilds))} guilds | .help"))
### Events end ###
@client.command()
async def snipe(ctx):
bad = [
"fuck",
"dick",
"nigga",
"nigger",
"cock",
"asshole",
"bitch"
]
channel = ctx.channel
try:
if any(x in snipe_message_content[channel.id].lower() for x in bad):
em = discord.Embed(name = f"Last deleted message in #{channel.name}", description =f"||{snipe_message_content[channel.id]}||")
em.set_footer(text = f"This message was sent by {snipe_message_author[channel.id]}\nWarning: this message contains banned words")
await ctx.send(embed = em)
else:
em = discord.Embed(name = f"Last deleted message in #{channel.name}", description = snipe_message_content[channel.id])
em.set_footer(text = f"This message was sent by {snipe_message_author[channel.id]}")
await ctx.send(embed = em)
except:
await ctx.send(f"There are no recently deleted messages in #{channel.name}")
@client.command()
async def load(ctx, *, arg1):
if ctx.message.author.id == owner_id:
pass
else:
await ctx.reply(f"You can\'t use this command")
return
client.load_extension(f'cogs.{arg1}')
await ctx.send("Loaded Cog")
@client.command()
async def unload(ctx, *, arg1):
if ctx.message.author.id == owner_id:
pass
else:
await ctx.reply(f"You can\'t use this command")
return
client.unload_extension(f'cogs.{arg1}')
await ctx.send("Unloaded Cog")
@client.command()
async def reload(ctx, *, arg1):
if ctx.message.author.id == owner_id:
pass
else:
await ctx.reply(f"You can\'t use this command")
return
client.unload_extension(f'cogs.{arg1}')
client.load_extension(f'cogs.{arg1}')
await ctx.send("Reloaded Cog")
client.run("") #paste your token inside the quotes