I have the usual familiar avatar command.
let target = interaction.options.getMember("target");
let embed = new MessageEmbed();
embed.setColor('RANDOM');
embed.setTitle(`Avatar by ${target.user.tag}`);
embed.setDescription(`Download Avatar\n[[PNG]](${target.user.displayAvatarURL({format: 'png', size: 4096, dynamic: false})})┃[[JPG]](${target.user.displayAvatarURL({format: 'jpg', size: 4096, dynamic: false})})┃[[GIF]](${target.user.displayAvatarURL({format: 'gif', size: 4096, dynamic: true})})`);
embed.setImage(target.user.displayAvatarURL({size: 4096, dynamic: true}));
interaction.followUp({embeds: [embed]});
Everything is fine, of course, everything works. Help is worth downloading avatars.
But if I click on the image that is embedded and copy the link, then the "images-ext-2.discordapp.net/external/" link is copied, and when I follow this link, the avatar starts downloading immediately without first looking at it in the browser. In the description no such the link, it starts with "cdn.discordapp.com/avatars/", and when I click on this link, I can see the avatar, but downloading avatar does not start immediately, for this I need to click two more times to download from the browser.
How can I make it so that by clicking on the link in the description downloading avatar starts immediately?
Hey there!
I'm pretty sure you're asking how to download something with one link of discord.
A simple fix to this is leading to a link that saves discord avatars, I don't know any examples at the top of my head, however, you can link it to the discord avatar link: cdn.discord.com/avatars/${USER_ID}/
Related
Scenario: the user picks a few choices, downloads a PDF. The user then changes a few choices, and downloads a new PDF.
Problem: everything works on the first run, but attempting to download a second PDF gives the user the same, old PDF.
Is there some way to "clear" or "kill" the old PDF? I tried setting the var doc to null before running the function again, and that didn't help. Somehow the first PDF being generated is all I'm able to serve.
Here is the code that makes the PDF. Those frontImg and backImg vars contain the dataURI.
$(".button").click(function(){
var doc = new jsPDF('landscape');
doc.addImage(frontImg, 'PNG', 0, 0, 300, 210);
doc.addPage('a6','l');
doc.addImage(backImg, 'PNG', 0, 0, 300, 210);
doc.save('file.pdf');
});
Anyone have any ideas here? Once the user takes actions that update the frontImg and backImg vars, shouldn't the PDF update too?
The new discord update added the feature to mark images and text as spoilers for text: you just have to type || text ||. For images, there is a check mark at the bottom of the attachment prompt:
Is there a way to mark images as spoiler or is the feature too new?
This does not work:
let image = new Attachment('./img/image.jpg');
message.channel.send("|| " + image + " ||");`
a quick way of doing it would be starting the filename with SPOILER_
for example img.png would become SPOILER_img.png
message.channel.send({
files: [{
attachment: 'IMG LINK',
name: 'SPOILER_NAME.jpg'
}]
})
This is what the API has listed for the image for embeds and it doesn't seem to mention marking as a spoiler so perhaps it is yet to be added for bots. I can't find anything about spoilers in the API, maybe you'll have more luck.
I want to upload an image file in protractor. the problem is i can not get "input[type = "file"]" element without clicking on upload button.
when I click upload button, file upload dialogue popup opens.
i have tried
browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); but it does not work.
This is what I am doing:
var image = '../images/image1.png';
var absPathImg = path.resolve(__dirname, image);
element(by.id('uploadImage')).click();
browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
element(by.css('input[type=file]')).sendKeys(absPathImg);
element(by.id('upload')).click();
How can i close that file upload dialogue to upload an image?
Try it like this. I used this for Protractor, but I think it's similar for Selenium.
I also have a problem for Windows File dialog not closing.
This is how I solved that:
element(by.css('elementForOpenDialog')).sendKeys(absPathImg);
Send Keys to the element which will open file dialog, not click on element to open file dialog. Just send to that element absolute path and it will upload without opening dialog.
It's worked for me. Good Luck!
This is an old thread but I'll answer in case anyone else runs to this problem.
I had to solve this same problem today. I was able to work around opening the upload dialog, because I am quite sure it cannot be closed without some external libraries and that would not work in headless mode.
You need to inspect the javascript linked to the upload button's click event and execute some script before sending keys to the file input.
This is individual to each case, but in my case i had to do this (Python):
script = (
"var url = '/Contacting/UploadCsv'; "
"$('#buttonFileUpload').data('url', url);"
)
driver.execute_script(script)
driver.find_element_by_id('buttonFileUpload').send_keys(csv_path)
I picked that script from the JS function linked to the button.
I landed here because I was searching on HOW TO CLOSE AN IMAGE WHEN CLICKED
In case that helps someone.
So what I did.
var Img = Driver.FindElement(XPath.News.YourImg);
Img.Click();
try
{
Img.Click();
Assert.IsFalse(feedImg.Displayed);
}catch(Exception ex)
{
}
This way you can check if the image is closed by trying to click on it again.
Instead of clicking on to ESCAPE, why not simulate the ENTER key press to simulate a person entering the path and pressing the ENTER key to upload the image.
I am doing this in my code and this works perfectly fine.
var path = require('path')
this.fileUploadOne = element(by.css('locator_to_element'));
var fileUpload = 'path_of_file_to_upload'
absolutePath = path.resolve(__dirname,fileUpload);
console.log(absolutePath);
this.fileUploadOne.sendKeys(absolutePath);
browser.actions().sendKeys(protractor.Key.ENTER).perform();
//just for debugging purposes.
browser.sleep(20000);
Can someone help me How to check if file got downloaded from browser using selenium2library,RobotFramework.In my current test I am able to click the download button and file is getting downloaded but what happens if the file didn't get downloaded eventhough button is clicked. Any sample code is helpful.
In chrome I open the chrome://downloads page and then retrieve the downloaded files list from shadow DOM like this:
const docs = document
.querySelector('downloads-manager')
.shadowRoot.querySelector('#downloads-list')
.getElementsByTagName('downloads-item');
This solution is restrained to chrome, the data also contains information like file path and download date.
Check out this link -
http://ardesco.lazerycode.com/testing/webdriver/2012/07/25/how-to-download-files-with-selenium-and-why-you-shouldnt.html
Also, here's how you can auto-download the file to a particular directory -
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("browser.download.folderList",2);
profile.SetPreference("browser.download.dir", #"c:\path\to\downloads \folder");
FirefoxDriver driver = new FirefoxDriver(profile);
u can use following python function to download file without showing dialog box.
Also u can set preference for which type of files save file dialog box should not get displayed.
def create_profile():
from selenium import webdriver
fp =webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.dir",'C:/Users/mra001/Downloads/Cambium_Builds')
fp.set_preference("browser.helperApps.neverAsk.saveToDisk",'text/csv/xls')
fp.update_preferences()
return fp.path
I want to insert a timelineitem with video attachment and if user selects a specific menu item, glass to play the video. I'm doing all from .net app like this, please correct me, if i'm doing wrong.
TimelineItem item = new TimelineItem()
item.MenuItems.Insert(0, new MenuItem(){Action="what is the action to use?";...});
request = Service.Timeline.Insert(item, attachment, contentType);
request.Upload();
I would like to know, do i need a menu item, if yes, what is the action i should use?
Currently i'm sending the video attachment, but there is no way to play the video.
Any help is greatly appreciated.
You don't need to specify any menuItems but your timeline item should not contain html content.
Make sure that your video is of a supported format: once it's inserted, and Glass has synced and fully downloaded the attached video, it should start playing right when you land on the item in your timeline.
This works using the QuickStart project for Java (mirror-java-starter-demo):
https://github.com/googleglass/mirror-quickstart-java
Replace the lines near line 119 in MainServlet.java with this:
URL url = new URL(req.getParameter("imageUrl"));
String contentType = req.getParameter("contentType");
url = new URL("http://localhost:8888/static/videos/video.mp4");
contentType = "video/mp4";
byte[] b = ByteStreams.toByteArray(url.openStream());
int i = b.length;
InputStream temp = url.openStream();
MirrorClient.insertTimelineItem(credential, timelineItem, contentType, temp);
Then run the project and click the "A Picture" button to upload a video from a new folder inside static called videos called video.mp4. I used a 10 second clip I recorded with glass (6.30 MB).
Note that when running with App Engine 1.76 on a windows machine I got this error when uploading, but changing to 1.80 made this issue go away:
Here is Windows metadata about the video that might be useful:
Depending on your network connection it might take a little bit for the video to show in your timeline, but mine plays.