Answers for "bots discord"

1

Discord.py bot example

#Anything commented out is optional

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='prefix here')

@bot.event
async def on_ready():
#   await bot.change_presence(activity=discord.Game(name="Rich Presence Here"))
    print('Logged in as: ' + bot.user.name)
    print('Ready!n')
    
@bot.command()
async def commandname(ctx, *, somevariable)
#If you don't need a variable, then you only need (ctx)
#	"""Command description"""
	Code goes here
	await ctx.send('Message')

bot.run('yourtoken')
Posted by: Guest on January-09-2021
1

How to setup discord.py bot

#Import essentials
import discord
from discord.ext import commands
import asyncio
#Some things that makes your life easier! (aliases to make code shorter)
client = commands.Bot(command_prefix='!') #change it if you want
token = 'YOUR TOKEN HERE' #Put your token here
#Making a first text command! (Respond's when a user triggers it on Discord)
@client.command()
async def hello(ctx):
    await ctx.send('Hello I am a Test Bot!')
#Tell's us if the bot is running / Runs the bot on Discord
@client.event
async def on_ready():
    print('Hello, I am now running')
    
    
    
client.run(token)
Posted by: Guest on November-27-2020
1

Discord Bot

Import-Module PoshBot
$pbc = New-PoshBotConfiguration
$pbc.BotAdmins = @('<YOUR USERNAME>')

$backendConfig = @{
    Name     = 'DiscordBackend'
    Token    = '<TOKEN>'
    ClientId = '<CLIENT ID>'
    GuildId  = '<SERVER ID>'
}
$backend = New-PoshBotDiscordBackend -Configuration $backendConfig
Posted by: Guest on November-16-2021
6

discord bots

#go to -- https://python.org 
#Download and install python
#go to CMD and install -- pip install discord
import discord
from discord.ext import commands

Token_1 = input("put your bot token here :")
Prefix_1 = input("put the prefix for your bot here :")
id_1 = input("put your bot id here :")
print("Link to invite -->  https://discord.com/api/oauth2/authorize?client_id=785328945691885608&permissions=8&scope=bot")

client = commands.Bot(command_prefix = Prefix_1)

@client.event
async def on_ready(): #Bot on
    print (f"Your bot is, Ready n type   {Prefix_1}hi   in a server in which your bot is added ")
    
@client.command()
async def hi(ctx):
    await ctx.send("hi This is a bot made by ALPHA")
    embed=discord.Embed(title="[OP]", description="super OP bot", color=0x00ff00)
    embed.add_field(name="hi !", value="hi This is a bot made by ALPHA", inline=False)
    embed.add_field(name="Invite me !", value="To invite --> [click here](https://discord.com/api/oauth2/authorize?client_id=785328945691885608&permissions=8&scope=bot)", inline=False)
    await ctx.send(embed=embed)
    
client.run(Token_1)
Posted by: Guest on May-24-2021
0

what are discord bots

import discord
from discord.ext import commands

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

@client.event
async def on_ready():
	print('Bot is Connected!')
    
@client.command() # An example message command
async def ping(ctx):
  await ctx.send('Pong!')
  
@client.command() # An example timer
async def timer(ctx, timeSecond):
  try:
    timeSeconds = int(timeSecond)
    timer_msg = await ctx.send(f'**{timeSeconds}** seconds remaining!')
	while timeSecond != 0:
      timeSeconds -= 1
      timer_msg.edit(content=f'**{timeSeconds}** seconds remaining!')
    await ctx.send(f'{ctx.author.mention} **TIMER ENDED!!!**')
  except ValueError:
    await ctx.send('Sorry, it must be a number!')
  
client.run('TOKEN') # <--------- Your Discord bot Token Here
Posted by: Guest on May-12-2021
0

discord bot

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
	console.log(`Logged in as ${client.user.tag}!`);
});

client.on('interactionCreate', async interaction => {
	if (!interaction.isCommand()) return;
	if (interaction.commandName === 'ping') {
		await interaction.reply('Pong!');
	}
});

client.login('token');
Posted by: Guest on July-28-2021

Python Answers by Framework

Browse Popular Code Answers by Language