mail@pastecode.io avatar
2 years ago
6.2 kB
import os
import discord
from discord.ext import commands, tasks
import random
import asyncio
import praw
import keep_alive
from requests import get
import aiohttp
from dotenv import load_dotenv
from discord import FFmpegPCMAudio
from youtube_dl import YoutubeDL

Reddit = praw.Reddit(client_id = "",
                     client_secret = "",
                     username = "",
                     password = "",
                     user_agent = "")

client = commands.Bot(command_prefix='S!')

async def meme(ctx):
    embed = discord.Embed(title="Ask, you shall receive", description="HAHA, meme go brr")

    async with aiohttp.ClientSession() as cs:
        async with cs.get('https://www.reddit.com/r/dankmemes/new.json?sort=hot') as r:
            res = await r.json()
            embed.set_image(url=res['data']['children'][random.randint(0, 25)]['data']['url'])
            await ctx.send(embed=embed)

illegal_words = ["Hitler"]

async def on_message(message):
    if any(word in message.content for word in illegal_words):
        await message.delete()
        await message.channel.send("""this is a capitalistic word""")
        await client.process_commands(message)

async def quote(ctx):
  quotes = ["It is enough that the people know there was an election. The people who cast the votes decide nothing. The people who count the votes decide everything.", "The death of one man is a tragedy. The death of millions is a statistic.", "Ideas are more powerful than guns. We would not let our enemies have guns, why should we let them have ideas.", "Education is a weapon whose effects depend on who holds it in his hands and at whom it is aimed.", "When we hang the capitalists they will sell us the rope we use.", "Gratitude is a sickness suffered by dogs.", "You cannot make a revolution with silk gloves.", "Mankind is divided into rich and poor, into property owners and exploited; and to abstract oneself from this fundamental division; and from the antagonism between poor and rich means abstracting oneself from fundamental facts.", "History shows that there are no invincible armies.", "The writer is the engineer of the human soul.", "A sincere diplomat is like dry water or wooden iron.", "Everyone imposes his own system as far as his army can reach.", "If any foreign minister begins to defend to the death a 'peace conference', you can be sure his government has already placed its orders for new battleships and airplanes.", ""]

  await ctx.send(random.choice(quotes))

async def join(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(client.voice_clients, guild=ctx.guild)
    if voice and voice.is_connected():
        await voice.move_to(channel)
        voice = await channel.connect()

async def play(ctx, url):
    YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'}
        'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
    voice = get(client.voice_clients, guild=ctx.guild)

    if not voice.is_playing():
        with YoutubeDL(YDL_OPTIONS) as ydl:
            info = ydl.extract_info(url, download=False)
        URL = info['url']
        voice.play(FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
        await ctx.send('Bot is playing')

        await ctx.send("Bot is already playing")

async def resume(ctx):
    voice = get(client.voice_clients, guild=ctx.guild)

    if not voice.is_playing():
        await ctx.send('Bot is resuming')

async def mariela(ctx):
  await ctx.send('Mariela slushai Niki ili toi shte te ddos-ne')

async def pause(ctx):
    voice = get(client.voice_clients, guild=ctx.guild)

    if voice.is_playing():
        await ctx.send('Bot has been paused')

async def stop(ctx):
    voice = get(client.voice_clients, guild=ctx.guild)

    if voice.is_playing():
        await ctx.send('Stopping...')

async def on_ready():
    print('We have logged in as {0.user}'.format(client))

async def on_member_join(member):
    print(f'(member) has become a communist.')

async def on_member_remove(member):
    print(f'(member) has become a capitalist.')

async def ping(ctx):
   await ctx.send(f'pong! {round(client.latency * 1000)}ms')

@client.command(aliases= ['purge','delete'])
async def clear(ctx, amount=None): # Set default value as None
    if amount == None:
        await ctx.channel.purge(limit=1000000)
        except: # Error handler
            await ctx.send('Please enter a valid integer as amount.')
            await ctx.channel.purge(limit=amount)

async def deport(ctx, member : discord.Member,*, reason=None):
    await member.kick(reason=reason)
    await ctx.send(f'{member} was deported out of Soviet Russia')

async def gulag(ctx, member : discord.Member,*, reason=None):
    await member.ban(reason=reason)
    await ctx.send(f'{member} was sent to gulag')

async def ungulag(ctx, *, member):
    banned_users = await ctx.guild.bans()
    member_name, member_discriminator = member.split("#")

    for ban_entry in banned_users:
        user = ban_entry.user

        if (user.name, user.discriminator) == (member_name, member_discriminator):
            await ctx.guild.unban(user)
            await ctx.send(f'**{user}** was freed from gulag')