Deleting unwanted messages from a publicly visible channel on Discord can be done by taking the following steps:
Open the Discord channel where the unwanted message is located.
Right-click on the message you want to delete.
Select "Delete" from the context menu.
Confirm the deletion by clicking "Delete" in the pop-up window.
Note that only the person who posted the message, or a server administrator, can delete messages. So, if the unwanted message is posted by someone else, you will need to reach out to the server administrator to delete the message.
If the unwanted message is posted by a bot, you will need to contact the bot developer or the server administrator to delete the message.
Also, if you want to delete multiple messages at once, you can use the "Bulk Delete" feature. This feature is available to server administrators, and it allows them to delete multiple messages at once.
Select the messages you want to delete by clicking the checkbox next to each message.
Click the three-dots icon at the top of the chat and select "Delete"
Confirm the deletion by clicking "Delete" in the pop-up window.
It's important to keep in mind that once a message is deleted, it cannot be recovered, so be sure to double-check the messages you are deleting before you confirm.
In addition, if you want to prevent unwanted messages on your server, you can use the server's moderation tools such as setting up roles, permissions and using the server's built-in anti-spam and anti-raid features.