Skip to content

Instantly share code, notes, and snippets.

@4Kaylum
Last active September 8, 2020 12:52
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4Kaylum/2a3c976ef8b8f5f86170710957293674 to your computer and use it in GitHub Desktop.
Save 4Kaylum/2a3c976ef8b8f5f86170710957293674 to your computer and use it in GitHub Desktop.
import discord
from discord.ext import commands
from asyncio import sleep
me = commands.Bot(command_prefix='.', self_bot=True)
@me.event
async def on_ready():
print("----------")
print("Logged in as:")
print(" "+str(me.user.name))
print(" "+str(me.user.id))
print("----------")
def makeEmbed(*, name=None, icon=None, colour=0xDEADBF, values={}):
'''Creates an embed messasge with specified inputs'''
# Create an embed object with the specified colour
embedObj = discord.Embed(colour=colour)
# Set the author and URL
embedObj.set_author(name=name, icon_url=icon)
# Create all of the fields
for i in values:
if values[i] == '':
values[i] = 'None'
embedObj.add_field(name=i, value='{}'.format(values[i]))
# Return to user
return embedObj
@me.event
async def on_message(message):
if message.author.id != me.user.id:
return
if len(message.embeds) > 0:
return
actualDict = {}
name = message.clean_content
actualObj = makeEmbed(name=name, icon=me.user.avatar_url, values=actualDict)
sleep(0.4)
await me.edit_message(message, ' ', embed=actualObj)
token = "UserToken" # Replace this with your user token
me.run(token, bot=False)
@paris-ci
Copy link

No please no.

Don't use sleep(0.4) on async programs. Use asyncio sleep

@EJIDAStudios
Copy link

cool

@4Kaylum
Copy link
Author

4Kaylum commented Aug 6, 2017

@paris-ci I've learned quite a lot of new stuff since writing this code. A lot of blocking things that I used before (sleep, requests) have been phased out for other stuff. I realise there's a lot of things I could do better in many ways, most of them due to lack of experience. I apologise for not having seen your comment sooner. You would really have helped me with stuff. Thanks for commenting anyway, though!

@azyzal
Copy link

azyzal commented Sep 14, 2017

i wNT TOME selfbot for line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment