@HUDSON_REYREY/

ParrotBOT

Python

Arif's Favourite.

fork
loading
Files
  • main.py
  • D:\backup.txt
  • D:\userwarnings.txt
  • keep_alive.py
  • requirements.txt
  • Unecessary.txt
main.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import discord
from discord import Game
from keep_alive import keep_alive
import os
import re
import asyncio
import requests
import random
from random import randint
from flask import Flask
from threading import Thread
print('HI')
#role_id = 123
#role = get(guild.roles, id=role_id)
#541970446778761234 < Admin ID
# Reading the datas
app = Flask('discord bot')
client = discord.Client()

MMM = None
botonverify = None
usermess = None
bot_status = discord.Status.online
@client.event
async def on_ready():
    global botonverify
    global usermess
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print(
        'https://discordapp.com/oauth2/authorize?client_id={}&scope=bot&permissions=8'
        .format('543412199368949762'))
    print('--------------')
    await client.change_presence(activity=Game(name="EVERYONE'S MICROHPONE", type = 2),
        status=bot_status, afk=False)
    while True:
      backk = open('D:\\backup.txt', 'w')
      usser = open('D:\\userwarnings.txt', 'r')
      currentt = usser.read()
      backk.write(currentt)
      await asyncio.sleep(1)
      


verify = [
  'epic', 'mining', 'dig', 'TNT', 'creepers', 'spiders', 'skeletons', 'zombie', 'sword', 'bow', 'shears', 'stick', 'emerald', 'diamond', 'gold', 'iron', 'stone', 'pickaxe', 'axe', 'hoe', 'shovel', 'bread', 'fish', 'stew', 'mushrooms', 'pigman', 'enderman', 'ender_dragon', 'wolf', 'sheep', 'ocelot', 'cat', 'nether', 'jungle', 'grass'
]
toyou = [
    'Ping me and I will teleport you to the lava! ', 'I will grief your house when you sleep, ',
    'Do not attempt to ping or mention my name. ', 'You want a creeper at your house? ', 'Want a TNT to explode on your face?', "I'll fling you with a knockback sword. "
]
welcoming = ['Welcome to the server,', 'Hello,', 'Heck yeah! You are here', "Greetings", "Hey", "Nice pickaxe,", "Good items you got", "You respawned at this server,"]
welcomT = [
  'Keep mining!', "Run there's a creeper!", "Get us some food!", "Where is your home?", "Got any compass? We're lost.", "Got any sword? No? We'll provide you a strong one!", "Quit messing around!", "Let's go mining!", "Let's mine some ores!", "Good lord!!! We have found diamonds!", "Got here just in time!"
]

dices = ['1', '2', '3', '4', '5', '6']
@client.event
async def on_member_join(member):
    welcChan = client.get_channel('544468571867316234')
    await client.send_message(welcChan, "**{} {}! {}**".format(random.choice(welcoming), member.mention, random.choice(welcomT) ))

@client.event
async def on_message(message):
    msg = message.content.lower()
    if message.content.startswith('!EMstop'):
        await client.send_typing(message.channel)
        await asyncio.sleep(2)
        await client.send_message(message.channel, 'To confirm shutting down, send "Y" to confirm and "N" to cancel.')
        sayback = await client.wait_for_message(
        author=message.author,
        channel=message.channel)
        if sayback.content == "Y":
          await client.send_message(message.channel, "**``--Shutting down.--``**")
          await asyncio.sleep(2)
          await client.logout()
        elif sayback.content == "N":
          await client.send_message(message.channel, "Operation Shutdown has been cancelled.")


    #         Spam delete
    elif message.content.startswith('!purge'):
        if '544498833204314143' in [rr.id for rr in message.author.roles]:
            await client.purge_from(message.channel)
        elif not '544498833204314143' in [
                rr.id for rr in message.author.roles
        ]:
            None

    
    #Change user's nickname!
    elif msg.split()[0] == "!gnick":
      if '544498833204314143' in [rr.id for rr in message.author.roles]:
        print(msg)
        print(message.mentions[0])
        await client.change_nickname(message.mentions[0], message.content.split(" ", 2)[2])

    elif msg.split()[0] == '!warn':
      if '544498833204314143' in [rr.id for rr in message.author.roles]:
        lineno = len(open('D:\\userwarnings.txt').read().splitlines())
        print('there are {} lines'.format(lineno))
        print('warned ' + message.mentions[0].name)
        db = open('D:\\userwarnings.txt', 'r+')
        content = [line.strip() for line in db]
        listof = ''
        for l in content:
          listof += l + '\n'
        if str(message.mentions[0].id) in listof:
          print("Data has been found!")
          for l in content:
            if message.mentions[0].id in l:
              print(str(l)) # Prints ur required line
              print('Line number {0}'.format(content.index(l) + 1)) # Prints the line number
              addwarn = None
              print(str(l).split()[0] + " < User ID")
              print(str(l).split()[1] + " Warnings")
              E = open('D:\\userwarnings.txt', "r+")
              g = open('D:\\userwarnings.txt', "r")
              if str(l).split()[1] == "0":
                  addwarn = 1
                  print('A user getting a 2nd warning!')
                  await client.send_message(message.channel, message.mentions[0].mention + " has 1/3 warnings (*Reset*)")
              elif str(l).split()[1] == "1":
                  addwarn = 2
                  print('A user getting a 2nd warning!')
                  await client.send_message(message.channel, message.mentions[0].mention + " has 2/3 warnings. **You have violated the rules.**")
              elif str(l).split()[1] == "2":
                  addwarn = 3
                  print('A user getting a 3rd warning!')
                  await client.send_message(message.channel, message.mentions[0].mention + " has 3/3 warnings. ***One more move!!!***")
              elif str(l).split()[1] == "3":
                  addwarn = 0
                  print(message.mentions[0].name + ' will get a role soon')
                  await client.send_message(message.channel, message.mentions[0].mention + " is punished! ***You did a good job getting a punishment!***")
                  # Bad roles and punished roles.
                  badrole = discord.utils.get(message.server.roles, id='544871875877011466')
                  verirole = discord.utils.get(message.server.roles, name="VERIFIED")
                  await asyncio.sleep(2)
                  await client.remove_roles(message.mentions[0], verirole)
                  await asyncio.sleep(1)
                  await client.add_roles(message.mentions[0], badrole)
              text = g.read()
              x = text.replace(str(l), "{} {}".format(message.mentions[0].id, str(addwarn)))
              E.write(str(x))
              print('--------------Warned---------------')
              print(' ')
              g.close()
              db.close()
              E.close()
        elif not str(message.mentions[0].id) in listof:
          print("IT AIN'T FOUND!")
          db.write('{} 1 \n'.format(message.mentions[0].id))
          print('{} has 1st warning'.format(message.mentions[0].name))
          await client.send_message(message.channel, message.mentions[0].mention + " is given a first ever warning.")
          db.close()
      elif not '541970446778761234' in [rr.id for rr in message.author.roles]:
        await client.send_message(message.channel, message.author.mention + "! ***You do not have the permission to warn a user!***")

    #         Soft delete
    elif message.content.startswith('!clear'):
      if '544498833204314143' in [rr.id for rr in message.author.roles]:
        async for msgs in client.logs_from(message.channel):
          if not msgs.pinned:
              await client.delete_message(msgs)
          elif msgs.pinned:
              None
    #        Do verification with the user.

    elif message.channel.id == '544524543629197314':
        if message.content.startswith('^verify'):
            if '544854070838558730' not in [r.id for r in message.author.roles]:
              if '544871875877011466' not in [p.id for p in message.author.roles]:
                botV = await discord.abc.Messageable.send(
                    message.channel, 'Verify by reacting ' + '\U0001F44B' + ' '
                    + message.author.mention)
                await client.add_reaction(botV, '\U0001F44B')
                dreact = await client.wait_for_reaction(
                    '\U0001F44B', user=message.author, message=botV)
                print('Verifying')
                await asyncio.sleep(1)
                roleee = discord.utils.get(
                    message.server.roles, id = '544854070838558730')
                # Role has been got! Now for the verifying
                await client.start_private_message(message.author)
                await client.send_message(
                    message.author,
                    'Copy and paste this at the verify room to get verified! Hurry up!!!'
                )
                returninn = await client.send_message(
                    message.author, '{} {} {} {} {}'.format(
                        random.choice(verify), random.choice(verify),
                        random.choice(verify),
                        random.choice(verify),
                        random.choice(verify)))
                ## Wait for the person to say back! V
                botonverify = returninn
                sayback = await client.wait_for_message(
                    author=message.author,
                    channel=message.channel,
                    content=returninn.content)
                await asyncio.sleep(1)
                usermess = sayback
                await client.delete_message(botV)
                await client.delete_message(message)
                #await client.delete_message(usermess)
                await client.send_message(
                    message.author,
                    'You have been verified at ' + message.channel.server.name)
                await client.add_roles(message.author, roleee)
              else:
                await client.delete_message(message)
            elif '544854070838558730' in [r.id for r in message.author.roles]:
                await client.delete_message(message)
        elif not message.content.startswith('^verify'):
            if message.author.id != '543412199368949762':
                await asyncio.sleep(0.3)
                await client.delete_message(message)
    elif msg.startswith("ping"):
      await client.add_reaction(message, '\U0001F3D3')
    elif msg.startswith("hi") or msg.startswith("hello"):
      await client.add_reaction(message, '\U0001F44B')
    elif msg.startswith('ok'):
      await client.add_reaction(message, '\U0001F44C')
    elif (message.mentions):
      for mem in message.mentions:
        if mem.id == '543412199368949762':
          await client.send_typing(message.channel)
          await asyncio.sleep(2)
          await client.send_message(message.channel, "{} ".format(random.choice(toyou)) + message.author.mention + '!')
keep_alive()
token = os.environ.get("DISCORD_BOT_SECRET")
client.run('NTQzNDEyMTk5MzY4OTQ5NzYy.XXJYog.h6kxHzTqT2kgd5_i5zoe3SBBKIw')