Answers for "python send message to discord"

1

send message to discord wrbhook python

from discord_webhook import DiscordWebhook, DiscordEmbed

webhook = DiscordWebhook(url='your webhook url', username="New Webhook Username")

embed = DiscordEmbed(title='Embed Title', description='Your Embed Description', color='03b2f8')
embed.set_author(name='Author Name', url='https://github.com/lovvskillz', icon_url='https://avatars0.githubusercontent.com/u/14542790')
embed.set_footer(text='Embed Footer Text')
embed.set_timestamp()
embed.add_embed_field(name='Field 1', value='Lorem ipsum')
embed.add_embed_field(name='Field 2', value='dolor sit')
embed.add_embed_field(name='Field 3', value='amet consetetur')
embed.add_embed_field(name='Field 4', value='sadipscing elitr')

webhook.add_embed(embed)
response = webhook.execute()
Posted by: Guest on June-05-2021
4

python discord bot moderate chat

import discord

class MyClient(discord.Client):

    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        word_list = ['cheat', 'cheats', 'hack', 'hacks', 'internal', 'external', 'ddos', 'denial of service']

        # don't respond to ourselves
        if message.author == self.user:
            return

        messageContent = message.content
        if len(messageContent) > 0:
            for word in word_list:
                if word in messageContent:
                    await message.delete()
                    await message.channel.send('Do not say that!')
            
        messageattachments = message.attachments
        if len(messageattachments) > 0:
            for attachment in messageattachments:
                if attachment.filename.endswith(".dll"):
                    await message.delete()
                    await message.channel.send("No DLL's allowed!")
                elif attachment.filename.endswith('.exe'):
                    await message.delete()
                    await message.channel.send("No EXE's allowed!")
                else:
                    break

client = MyClient()
client.run('token here')
Posted by: Guest on March-19-2020
1

how to make a discord bot send a message python

import discord
from discord.ext import commands
client = commands.Bot(command_prefix='!!') # This sets the prefix change if you want

TOKEN = 'insert token here' # tutorial at the bottom

@client.event
def on_ready():
  print('Ready. Logged in as: {0.user}'.format(client)) # lets you know the bot is online and ready
  

# Now to see how to send a message to discord itself 
@client.command(brief='Echoes back what user says.')
async def echo(ctx, *, user_message):
    # The ctx is so that we can send the message on discord
    # The astrix is so we can take multiple strings for the user message
    # The string is the users message
    await ctx.send('User said --> ' + user_message) 
    
client.run(TOKEN)
    
# Now you can do any command you would like 
# Using the ctx argument.

# HOW TO GET BOT TOKEN
# To get your bot's token simply go to:
# https://discord.com/developers/applications 
# Login, and press new application (If you already have a bot skip this part)
# Press bot, and press yes you want to make it a bot
# Under token you will see copy, or regenerate 
# Press copy and give the TOKEN variable the value of your token
Posted by: Guest on May-07-2021
0

reply to a message discord.py

await ctx.reply('Hello!')
Posted by: Guest on May-30-2021

Code answers related to "python send message to discord"

Python Answers by Framework

Browse Popular Code Answers by Language