How I can make channel text discord only allow send image, video or link?
Assistant
User
yes please help me
Assistant
User
check port running ubuntu
Assistant
To check if a port is running (i.e., if any service is listening on a particular port) on Ubuntu, you have several options. Here are the most common ways:
1. Using ss (Socket Statistics)
ss is the modern replacement for netstat and is usually installed by default.
Check if a specific port (for example, port 3000) is listening:
bash
ss -tuln | grep :3000
Explanation:
-t: TCP sockets
-u: UDP sockets
-l: listening sockets
-n: show numerical addresses and ports (don’t try to resolve service names)
grep :3000: filters lines showing port 3000
Discord does not provide native granular channel permissions to restrict message content types (such as only allowing images, videos, or links while blocking plain text). However, you can achieve this behavior by using a Discord bot that monitors messages and deletes any message that does not meet your criteria.
How to make a Discord channel that only allows sending images, videos, or links
Approach: Use a bot to moderate messages
Create a bot / use an existing bot with message filtering
You need a bot that listens to messages sent in a particular channel and deletes any message that:
Does not contain an embed or attachment (image/video), AND
Does not contain a URL/link in the message content.
Basic logic the bot should use:
If message has one or more attachments (image, video, etc.) → allow
Else if message contains one or more URLs → allow
Else delete the message and optionally send a warning/toast message.
Example with Discord.js (Node.js)
js
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
// Replace with your channel ID and bot token
const allowedChannelId = 'YOUR_CHANNEL_ID';
client.on('messageCreate', message => {
// Ignore messages by bots
if (message.author.bot) return;
// Only check messages in the specified channel
if (message.channel.id !== allowedChannelId) return;
const urlRegex = /(https?:\/\/[^\s]+)/g;
const hasAttachments = message.attachments.size > 0;
const hasLinks = urlRegex.test(message.content);
if (!hasAttachments && !hasLinks) {
// Delete the message because it doesn't contain image/video or link
message.delete()
.then(() => {
message.channel.send(`${message.author}, only images, videos, or links are allowed in this channel.`)
.then(msg => setTimeout(() => msg.delete(), 5000))
.catch(console.error);
})
.catch(console.error);
}
});
client.login('YOUR_BOT_TOKEN');
Additional tips
Channels permissions: You cannot prevent users from sending plain text messages via Discord's built-in permission system alone.
Bots like MEE6, Dyno, or Carl-bot may have custom commands or automod features that could be configured to do something similar, but custom code or a custom bot gives you better control.
Make sure your bot has the appropriate permissions: MANAGE_MESSAGES to delete messages, and READ_MESSAGE_CONTENT (important after recent Discord intents changes) to read user messages.
You can improve URL detection to avoid false positives or catch more cases with more advanced regex or URL parsers.
Be mindful of spamming notifications — you may want to DM users instead of sending a warning message publicly.
If you want, I can help you create or set up such a bot or show you how to do it with Python or another language!
Great! I’ll help you create a simple Discord bot that only allows users to send images, videos, or links in a specific channel. We'll use Discord.js v14 (the latest version as of mid-2024) with Node.js.
Create a new application → Bot → Add Bot → copy the bot token
Your Discord server ID (for the server where the bot is used)
The channel ID where you want to enforce this rule
Step-by-step guide
1. Create your project
Open a folder for your bot and run these commands in your terminal:
bash
npm init -y
npm install discord.js
2. Basic bot code (index.js)
Create a file index.js with this code:
js
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent, // We need this to read message text
],
partials: [Partials.Channel]
});
// Replace with your actual channel ID
const allowedChannelId = 'YOUR_CHANNEL_ID';
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('messageCreate', async (message) => {
// Ignore bots (including the bot itself)
if (message.author.bot) return;
// Only check the specified channel
if (message.channel.id !== allowedChannelId) return;
// Simple URL regex to detect links
const urlRegex = /(https?:\/\/[^\s]+)/gi;
const hasAttachments = message.attachments.size > 0;
const hasLinks = urlRegex.test(message.content);
if (!hasAttachments && !hasLinks) {
try {
await message.delete();
// Optional: notify the user they can only send image, video, or links
const warningMsg = await message.channel.send(`${message.author}, only images, videos, or links are allowed in this channel.`);
// Delete the warning after 5 seconds
setTimeout(() => warningMsg.delete().catch(() => {}), 5000);
} catch (err) {
console.error('Failed to delete message or send warning:', err);
}
}
});
client.login('YOUR_BOT_TOKEN');
3. Fill your credentials
Replace 'YOUR_CHANNEL_ID' with the target channel ID where restrictions apply.
Replace 'YOUR_BOT_TOKEN' with your bot token.
4. Invite your bot to your server
Go to the Developer Portal → OAuth2 → URL Generator
Pick these scopes:
bot
applications.commands (optional, for slash commands if you want to add later)
Permissions (under Bot Permissions), select:
Read Messages/View Channels
Send Messages
Manage Messages (to delete users' messages)
Read Message Content (important so the bot can see the message text)
Copy the generated invite link, open it in a browser, and invite the bot to your server.
5. Run your bot
In your terminal/command prompt, run:
bash
node index.js
You should see Logged in as YourBotName#1234! if everything works.
How this works
Whenever a user sends a message in the specified channel, the bot checks:
Does the message have attachments (like an uploaded image or video)? ✅ Allow
Does the message contain a link? ✅ Allow
Else ❌ Delete the message and warn the user.
Extra suggestions
You can extend the bot to allow certain domains only.
You can DM users instead of sending public warnings.
Add logging or moderation commands.
Deploy your bot on a server or a hosting platform to run 24/7.
If you want, I can help you with those as well! Let me know if you want to test or customize the bot further.
If you see output, something is listening on that port.
2. Using netstat (may require installing net-tools)
bash
sudo apt install net-tools # if netstat is not installed
netstat -tuln | grep :3000
Same explanation as with ss.
3. Using lsof
lsof lists open files, network connections included.
bash
sudo lsof -i :3000
If a process is listening on port 3000, it will show here.
4. Using nc (netcat) to test connectivity (if port is listening locally)
bash
nc -zv localhost 3000
This attempts to "connect" to port 3000; if successful, you’ll see a message indicating the port is open.
Summary example — check if port 80 is listening:
bash
ss -tuln | grep :80
If you want to check what program is using the port, lsof or netstat -p can help.
Let me know if you want help with a specific port or service!