PackedUP32
PackedUP32

Reputation: 17

send terminal output to channel (discord.py)

i want to make a ping request to a IP then output it in a message from a discord bot

example

import discord
import os

@client.command()
async def ping(ctx):
os.system('ping XX.XX.XX.XX')

i want the output from XX.XX.XX.XX to be sent in a channel.

Upvotes: 0

Views: 705

Answers (1)

loloToster
loloToster

Reputation: 1415

You should do this like this:

from subprocess import run
import discord

@client.command()
async def ping(ctx):
   x = run("ping XX.XX.XX.XX", capture_output=True).stdout
   await ctx.send(x)

Upvotes: 1

Related Questions