Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python discord

import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'ping':
            await message.channel.send('pong')

client = MyClient()
client.run('token')
Comment

discord.py

#Replace "nextcord" with "discord" if you use discord.py!
#If something doesnt work message me @ Discord: VeryAppropriateName#0195

@bot.command()
@commands.cooldown(1, 3, commands.BucketType.user)
@has_permissions(administrator=True)
async def ban(ctx, member: nextcord.Member = None, *, reason="No reason provided"):
    if member is None:
        embed = nextcord.Embed(title="Command: !ban",
                               description=f"**Description:** Ban a member, optional reason
**Cooldown:** 3 Seconds",
                               color=0x2596be)
        embed.add_field(name="Usage:", value=f"!ban [user] [reason]", inline=False)
        embed.add_field(name="Example:", value=f"!ban bean squishing bugs", inline=False)
        await ctx.send(embed=embed)
    else:
        embed = nextcord.Embed(title="You got banned!",
                               description=f"You got banned from {ctx.guild.name}, for {reason}! Better behave next time!",
                               color=0x2596be)
        embed.set_image(url="https://i.gifer.com/41zO.gif")
        await member.send(embed=embed)
        embed = nextcord.Embed(title="", description=f"Banned {member.mention} for {reason}", color=0x2596be)
        embed.set_image(url="https://i.gifer.com/41zO.gif")
        await ctx.send(embed=embed)
        await member.ban(reason=reason)


@bot.command()
@commands.cooldown(1, 3, commands.BucketType.user)
@has_permissions(administrator=True)
async def kick(ctx, member: nextcord.Member = None, *, reason="No reason provided"):
    if member is None:
        embed = nextcord.Embed(title="Command: !kick",
                               description=f"**Description:** Kick a member, optional reason
**Cooldown:** 3 Seconds",
                               color=0x2596be)
        embed.add_field(name="Usage:", value=f"!kick [user] [reason]", inline=False)
        embed.add_field(name="Example:", value=f"!kick bean squishing bugs", inline=False)
        await ctx.send(embed=embed)
    else:
        embed = nextcord.Embed(title="You got kicked!",
                               description=f"You got kicked from {ctx.guild.name}, for {reason}! Better behave next time!",
                               color=0x2596be)
        await member.send(embed=embed)
        embed = nextcord.Embed(title="", description=f"Kicked {member.mention} for {reason}", color=0x2596be)
        await ctx.send(embed=embed)
        await member.kick(reason=reason)
Comment

discord.py

@bot.command()
@has_permissions(administrator=True)
async def mute(ctx, member: nextcord.Member=None, time=None, *, reason="No reason specified"):
    if member is None:
        embed = nextcord.Embed(title="Command: !mute",
                               description=f"**Description:** Mute a member, optional reason
**Cooldown:** 3 Seconds",
                               color=0x2596be)
        embed.add_field(name="Usage:", value=f"!mute [user] [time] (reason)", inline=False)
        embed.add_field(name="Example", value=f"!mute bean 5m Squishing Small ants", inline=False)
        await ctx.send(embed=embed)
    if time is None:
        embed = nextcord.Embed(title="Command: !mute",
                               description=f"**Description:** Mute a member, optional reason
**Cooldown:** 3 Seconds",
                               color=0x2596be)
        embed.add_field(name="Usage:", value=f"!mute [user] [time] (reason)", inline=False)
        embed.add_field(name="Example", value=f"!mute bean 5m Squishing Small ants", inline=False)
        await ctx.send(embed=embed)
    else:
        desctime = time
        guild = ctx.guild
        mutedRole = nextcord.utils.get(guild.roles, name="Muted")
        time_convert = {"s":1, "m":60, "h":3600, "d":86400, "w":604800, "mo":31536000}
        tempmute = int(time[0]) * time_convert[time[-1]]
        if not mutedRole:
            embed = nextcord.Embed(title="Setup Muted Role", description="No Muted role was found, please create one!")
            embed.set_footer(text="Due to issues I can't create one myself...")
            await ctx.send(embed=embed)
        else:
            embed = nextcord.Embed(title="Muted", description=f"{member.mention} was muted for {desctime}")
            embed.set_image(url="https://c.tenor.com/l1yJ91orR_kAAAAd/yt-battles-youre-muted.gif")
            embed.add_field(name="Reason", value=reason, inline=False)
            await ctx.send(embed=embed)
            embed = nextcord.Embed(title="Muted", description=f"You were muted in {ctx.guild.name} for {desctime}")
            embed.add_field(name="Reason", value=reason)
            embed.set_image(url="https://c.tenor.com/l1yJ91orR_kAAAAd/yt-battles-youre-muted.gif")
            embed.add_field(name="Times", value="s = seconds
m = minutes
h = hours
d = days
w = weeks
mo = months")
            await member.send(embed=embed)
            await member.add_roles(mutedRole, reason=reason)
            await asyncio.sleep(tempmute)
            embed = nextcord.Embed(title="Unmuted", description=f"You were unmuted in {ctx.guild.name}")
            await member.send(embed=embed)
            embed = nextcord.Embed(title="Unmuted", description=f"Unmuted {member.mention}")
            await ctx.send(embed=embed)
            await member.remove_roles(mutedRole)

@bot.command()
@has_permissions(administrator=True)
async def unmute(ctx, member: nextcord.Member):
    mutedRole = nextcord.utils.get(member.roles, name="Muted")
    if not mutedRole:
        embed = nextcord.Embed(title="Can't unmute", description="This user is not muted!")
        embed.set_footer(text="Did you mean !mute?")
        await ctx.send(embed=embed)
    else:
        embed = nextcord.Embed(title="Unmuted", description=f"You were unmuted in {ctx.guild.name}")
        await member.send(embed=embed)
        embed = nextcord.Embed(title="Unmuted", description=f"Unmuted {member.mention}")
        await ctx.send(embed=embed)
        await member.remove_roles(mutedRole)
Comment

discord.py

wallet_amt = users[str(user.id)]["wallet"]
Comment

PREVIOUS NEXT
Code Example
Python :: list append python 3 
Python :: print multiple strings in python 
Python :: insert multiple column pandas 
Python :: how to make a calculator in python 
Python :: python string: immutable string 
Python :: read list of dictionaries from file python 
Python :: Convert .tif images files to .jpeg in python 
Python :: how to create an auto clicker in python 
Python :: odd number in python 
Python :: ten minute mail 
Python :: python palindrome program 
Python :: python class declaration 
Python :: install multiple versions of python 
Python :: Dependency on app with no migrations: 
Python :: comment multiple lines python 
Python :: python mad libs 
Python :: how to check if string ends with specific characters in python 
Python :: pandas splitting the data based on the day type 
Python :: combine for and if python 
Python :: AttributeError: __enter__ in python cde 
Python :: remove percentage in python 
Python :: converting multipage tiff to pdf python 
Python :: how to make hidden folders python 
Python :: iniciar un projecto de python con pyenv 
Python :: iterate over meta tag python 
Python :: check if inf pandas dataframe 
Shell :: ubuntu list running services 
Shell :: find which pid is listening on a particular port 
Shell :: install git-lfs ubuntu 18.04 
Shell :: git list user and email 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =