예제 #1
0
import discord
from discord.ext import commands
from discord.ext.commands import bot
import random
import time

bot = commands.Bot(command_prefix='#')

bot.remove_command("help")

USER_TOKEN = 'PUT THE TOKEN HERE'


@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print(discord.__version__)
    print('------')


@bot.command()
async def ping(ctx):
    start = time.perf_counter()
    message = await ctx.send("Ping...")
    end = time.perf_counter()
    duration = (end - start) * 1000
    await message.edit(content='Latency is {:.2f}ms'.format(duration))
    await ctx.message.delete()
예제 #2
0
#Lif3 Bot by ItzAfroBoy

#Setup
import discord
from discord.ext import commands
from discord.ext.commands import bot
import time

#Prefix
bot = commands.Bot(command_prefix='#')
bot.remove_command('help')

#Launching Messgae
print("")
print("Launching Lif3 Bot ...")
print("----------------------")
print("")

#Events


@bot.event
async def on_ready():
    #    await bot.change_presence(game=discord.Game(name='STATUS'))
    print("Bot Version: 1.0.1")
    time.sleep(1)
    print("Discord Version: " + discord.__version__)
    time.sleep(0.9)
    print(bot.user.name + " Online")
    print("-----------------------")
    print("")
예제 #3
0
import discord
from discord.ext import commands
from discord.ext.commands import bot
import asyncio
import datetime as DT  # Imports datetime as DT so instead of typing 'datetime.datetime.now()' you type 'DT.datetime.now()' it saves time and looks less dumb than 'datetime.datetime.now()'
import time
from time import sleep

# Checks time that bot was started
botStartTime = DT.datetime.now()

# Prefix to be entered before commmands. Ex. !test
bot = commands.Bot(
    command_prefix='!'
)  # In this case the prefix is '!' so before typing a command you type '!' and then 'test'
bot.remove_command('help')  # Removes the default help command


# Handles what needs to be printed in the console
def consoleOutput(commandName, commandTime):  # Defines consoleOutput()
    startTime = commandTime  # Passes startTime from the beginning of the command into the function
    timeToRun = DT.datetime.now() - startTime
    print('')
    print('---------TeaBot----------')  # Divider to make console readable
    print('Time to Run:',
          timeToRun)  # Prints how long it took the bot to run the command
    print(
        'Current Time:', DT.datetime.now()
    )  # Prints time command was run in the console, from the variable 'currentDT'
    print(commandName, 'has been run')  # Prints 'test has been run' in console
    print('-------------------------')  # Divider to make console readable
예제 #4
0
import discord
from discord.ext import commands
from discord.ext.commands import bot
import asyncio
from itertools import cycle
import time
import youtube_dl
import json
my_token = 'Your token'
bot = commands.Bot(command_prefix='>')
bot.remove_command('help')

@bot.event
async def on_ready():
    print('The bot is online and is connected to discord')

@bot.command(pass_context=True)
async def tweet(ctx, *, tet: str = None):
    if tet == None:
        await bot.say(
            f"{ctx.message.author} ```Proper usage is\n\n>tweet<text>```")
    else:
        await bot.say(
            "Omg DonaldTrump is tweeting, i will take a picture wait...")
        url = f"https://nekobot.xyz/api/imagegen?type=trumptweet&text={tet}"
        async with aiohttp.ClientSession() as cs:
            async with cs.get(url) as r:
                res = await r.json()
                embed = discord.Embed(title="tweet.png",
                                      description="",
예제 #5
0
 def __init__(self, bot):
     self.bot = bot
     bot.remove_command('help')